[PATCH] D67153: [InstCombine] Fold sub (or A, B) (and A, B) to (xor A, B)
Roman Lebedev via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Sep 4 04:38:39 PDT 2019
lebedev.ri accepted this revision.
lebedev.ri added a comment.
This revision is now accepted and ready to land.
LG.
There's also `sub(and(x, y), or(x, y)) -> neg(xor(x, y))`
https://rise4fun.com/Alive/VI6
https://godbolt.org/z/OMu71B
================
Comment at: /home/xbolva00/LLVM/llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp:1724
+ if (match(Op1, m_And(m_Value(A), m_Value(B))) &&
+ (match(Op0, m_c_Or(m_Specific(A), m_Specific(B)))))
+ return BinaryOperator::CreateXor(A, B);
----------------
extra unneeded braces
================
Comment at: test/Transforms/InstCombine/sub-or-and-xor.ll:69-78
+define i32 @sub_to_xor_and_commuted(i32 %x, i32 %y) {
+; CHECK-LABEL: @sub_to_xor_and_commuted(
+; CHECK-NEXT: [[SUB:%.*]] = xor i32 [[Y:%.*]], [[X:%.*]]
+; CHECK-NEXT: ret i32 [[SUB]]
+;
+ %or = or i32 %x, %y
+ %and = and i32 %y, %x
----------------
Precommit.
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D67153/new/
https://reviews.llvm.org/D67153
More information about the llvm-commits
mailing list