X && Z || Y && Z --> (X || Y) && Z
https://alive2.llvm.org/ce/z/nM6kZb
(X || Z) && (Y || Z) --> (X && Y) || Z
https://alive2.llvm.org/ce/z/_EWLRR
Paths
| Differential D139408
[InstCombine] Fold logic-and/logic-or by distributive laws ClosedPublic Authored by bcl5980 on Dec 6 2022, 2:45 AM.
Details Summary X && Z || Y && Z --> (X || Y) && Z (X || Z) && (Y || Z) --> (X && Y) || Z
Diff Detail
Event Timeline
bcl5980 mentioned this in D139630: [InstCombine] Fold logic-and/logic-or by distributive laws part2.Dec 8 2022, 6:38 AM bcl5980 added a child revision: D139630: [InstCombine] Fold logic-and/logic-or by distributive laws part2.
Comment Actions Did this get subsumed by https://github.com/llvm/llvm-project/commit/9ddff66d0c9c3e18d56e6b20aa26a2a8cdfb6d2b? Comment Actions
I rebase the code. @logic_and_logic_or_3 @logic_and_logic_or_4 @logic_and_logic_or_6 @logic_and_logic_or_7 If any of you think this is redundant I can abandon it. Comment Actions I'm not sure how much overlap we have vs. generality for these kinds of patterns, but this is still showing improvements, so LGTM. This revision is now accepted and ready to land.Dec 13 2022, 7:03 AM Comment Actions
Do you mean rGa888825aeef8d6592c6cf5f4e5854cc39af49633 update test will add {{[^@]+}} for every test? This revision was landed with ongoing or failed builds.Dec 13 2022, 12:43 PM Closed by commit rGc8647738cd65: [InstCombine] Fold logic-and/logic-or by distributive laws (authored by bcl5980). · Explain Why This revision was automatically updated to reflect the committed changes. bcl5980 removed a child revision: D139630: [InstCombine] Fold logic-and/logic-or by distributive laws part2.Dec 13 2022, 12:45 PM Comment Actions
No, i'm saying that the test diff was showing spurious/misleading changes.
Revision Contents
Diff 482598 llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp
llvm/test/Transforms/InstCombine/select-factorize.ll
|
Use the same names as the code for consistency:
With logical-and/or, the pattern is not commutative. I think the code is correct, but it might be better to put this kind of label just above the line that does the transform, so it is clear that order of the common operand does matter.