Skip to content

C++: Disable _some_ constant folding in IR #15969

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 10 commits into from
Mar 20, 2024

Conversation

MathiasVP
Copy link
Contributor

@MathiasVP MathiasVP commented Mar 19, 2024

In #14210 Alex tried to disable close to all constant folding in IR generation. This made us hit some really complex cases (see the corresponding internal issue), which meant we had to back out of this approach.

This PR does the minimal changes necessary to fix the original issue: being able to select the dataflow node for 1 (or 2) in an expression such as 1 | 2. We do this by disabling constant folding for binary operations only. In addition, we only disable it for "small binary operations" (currently defined as an operation with less than 50 operands).

Unsurprisingly, most binary operations are "small". Here's the distribution on Wireshark (with a threshold line at 50 to make it easy to spot which ones we fold and which ones we don't):
Screenshot 2024-03-19 at 11 43 18

I imagine we could make this threshold a lot bigger, but this seems to be the safe way to go about this.

@MathiasVP MathiasVP requested a review from a team as a code owner March 19, 2024 11:47
@github-actions github-actions bot added the C++ label Mar 19, 2024
@MathiasVP MathiasVP added the no-change-note-required This PR does not need a change note label Mar 19, 2024
jketema
jketema previously approved these changes Mar 19, 2024
Copy link
Contributor

@jketema jketema left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, if DCA is happy

@MathiasVP
Copy link
Contributor Author

MathiasVP commented Mar 19, 2024

DCA showed three FPs caused by us no longer realizing some code was dead in some really ugly php code. I've pushed 458ee13 to fix this. Locally this fixes those FPs. I'm running another DCA now to confirm this 🤞

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C++ no-change-note-required This PR does not need a change note
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants