[PATCH] Added InstCombine transform for pattern "(A ^ B) | ((~A) ^ B) -> True".
sonam kumari
sonam.kumari at samsung.com
Wed Jul 30 04:13:58 PDT 2014
Hi Majnemer,
Thanks for your valuable review comments.
I have made the changes as you mentioned.
Please help in reviewing the patch.
Thanks,
Sonam.
http://reviews.llvm.org/D4691
Files:
lib/Analysis/InstructionSimplify.cpp
test/Transforms/InstSimplify/AndOrXor.ll
Index: lib/Analysis/InstructionSimplify.cpp
===================================================================
--- lib/Analysis/InstructionSimplify.cpp
+++ lib/Analysis/InstructionSimplify.cpp
@@ -1603,6 +1603,11 @@
(A == Op0 || B == Op0))
return Constant::getAllOnesValue(Op0->getType());
+ // (A^B) | (~(A)^B) -> 1
+ if (match(Op0, m_Xor(m_Value(A), m_Value(B))) &&
+ match(Op1, m_Xor(m_Not(m_Specific(A)), m_Specific(B))))
+ return Constant::getAllOnesValue(Op0->getType());
+
// Try some generic simplifications for associative operations.
if (Value *V = SimplifyAssociativeBinOp(Instruction::Or, Op0, Op1, Q,
MaxRecurse))
Index: test/Transforms/InstSimplify/AndOrXor.ll
===================================================================
--- test/Transforms/InstSimplify/AndOrXor.ll
+++ test/Transforms/InstSimplify/AndOrXor.ll
@@ -20,3 +20,13 @@
ret i64 %e2
; CHECK: ret i64 %e
}
+
+define i32 @test(i32 %x, i32 %y) {
+ ; CHECK-LABEL: @test39(
+ %xor = xor i32 %x, %y
+ %nega = xor i32 %x, -1
+ %xor1 = xor i32 %nega, %y
+ %or = or i32 %xor, %xor1
+ ret i32 %or
+; CHECK: ret i32 -1
+}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D4691.12015.patch
Type: text/x-patch
Size: 1177 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20140730/68c37195/attachment.bin>
More information about the llvm-commits
mailing list