Canonicalize ((x + C1) & C2) --> ((x & C2) + C1) for suitable constants
C1 and C2, instead of the other way round. This should allow more
constant ADDs to be matched as part of addressing modes for loads and
stores.
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
llvm/test/Transforms/InstCombine/add.ll | ||
---|---|---|
727 | Update the comment |
LGTM - see inline for one more test upate.
The question of other logic + math combos came up in the previous review. It looks like we don't handle those either way:
https://github.com/llvm/llvm-project/issues/56731
So this patch should be generalized as a next step (although I have no idea if that would uncover other problems).
llvm/test/Transforms/InstCombine/add.ll | ||
---|---|---|
771 | This is an existing issue, but this test doesn't add any value as-is. We should be testing if %and has an extra use, not %x. |
C->isNegatedPowerOf2() ?