This patch fixes bug Failure to simplify (A^B)|~A --> ~(A&B) reported here:
https://bugs.llvm.org/show_bug.cgi?id=52478
Details
- Reviewers
spatel foad rampitec - Commits
- rG7daa95c8fac2: [InstCombine] Fold (A^B)|~A-->~(A&B)
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp | ||
---|---|---|
2676 | This surprised me, but this seems to work. Note that 'not' is also an 'xor' operation. | |
llvm/test/Transforms/InstCombine/or-xor.ll | ||
62 | We need another test where X and Y are commuted. |
llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp | ||
---|---|---|
2676 | I think it's ok, but it would be nice to add the explanation to the code comment. So something like this: | |
llvm/test/Transforms/InstCombine/or-xor.ll | ||
62 | Tests look good. Do you have commit access? If so, please pre-commit the tests with the baseline results, so we will show how the code changes in this patch. |
Add a comment to clarify the Op0 in the or operation is guaranteed to be not in the foldable pattern due to the swap that is happening before.
llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp | ||
---|---|---|
2676 | Thank you; I have added your suggested comment. | |
llvm/test/Transforms/InstCombine/or-xor.ll | ||
62 | No, I do not have commit access; But I prepared another patch to pre-commit the tests with baseline results here: https://reviews.llvm.org/D113846 If it's possible, Can you please commit it for me? |
LGTM
Do you have enough commits/reviews now to request commit access? ( https://llvm.org/docs/DeveloperPolicy.html#obtaining-commit-access )
This surprised me, but this seems to work. Note that 'not' is also an 'xor' operation.
But canonicalization rules will always put the 'not' operand on the right (operand 1). So the swap above here then guarantees that the 'not' is operand 0.