Fixes #57531
This transformation may be particularly useful on x86-64, because x & (x - 1) can be performed by a single blsr instruction.
Differential D133362
[InstCombine] Fold x + (x | -x) to x & (x - 1) marcauberer on Sep 6 2022, 8:34 AM. Authored by
Details Fixes #57531 This transformation may be particularly useful on x86-64, because x & (x - 1) can be performed by a single blsr instruction.
Diff Detail
Event Timeline
Comment Actions
Comment Actions @spatel sorry, forgot to refresh the test ref. Now the change is ready for the final review ... |
This shows the expected set of commuted variants of the general pattern, but I don't think the match is handling all of them.
You'll want to add tests for each of these variations, and that's going to require some bonus instructions to make the patterns stick until we reach this point in visitAdd().
Here are some tests that I recently added that can serve as templates - note especially the lines with "thwart complexity-based canoinicalization":
d4a4004c0f9d3070