Uh oh!
There was an error while loading. Please reload this page.
JIT: Canonicalize '(A & pow2) == pow2' -> '(A & pow2) != 0' - #128533
Conversation
* '(A & pow2) != pow2' -> '(A & pow2) == 0'
Tagging subscribers to this area: @JulieLeeMSFT, @jakobbotsch |
MichalPetryka
commented
May 24, 2026
@MihuBot -nuget |
Uh oh!
There was an error while loading. Please reload this page.
…it-test-to-zero-on-right
There was a problem hiding this comment.
Pull request overview
Canonicalizes (A & pow2) == pow2 to (A & pow2) != 0 (and the inverse for !=) during morph relational-comparison optimization. This puts the comparison into a uniform form with 0 on the right, which immediately helps optimizeBools and sets the stage for further follow-on optimizations (e.g., the distributive transform in #126852).
Changes:
- Add a canonicalization in
fgOptimizeRelationalComparisonthat, when matching(A & pow2) ==/!= pow2, reverses the relop and bashes the RHS constant to zero, with VN updated accordingly.
…it-test-to-zero-on-right
BoyBaykiller
commented
Jun 2, 2026
@EgorBo I fixed the merge conflicts. |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
BoyBaykiller
commented
Jun 4, 2026
Are we good to merge :) ? I'd like to continue follow up work @EgorBo |
EgorBo
commented
Jun 4, 2026
/ba-g known CSharpMissingShebangInFileBasedProgram failure |
Basically so we always have 0 at the right-side:
Tthis currently helps optimizeBools, but I am also adding this with the future in mind.
Here is one example:
Note: With #126852 this would then get transformed into just
test 12.