[llvm] r228954 - InstCombine: Allow folding of xor into icmp by changing the predicate for vectors
Benjamin Kramer
benny.kra at googlemail.com
Thu Feb 12 12:26:46 PST 2015
Author: d0k
Date: Thu Feb 12 14:26:46 2015
New Revision: 228954
URL: http://llvm.org/viewvc/llvm-project?rev=228954&view=rev
Log:
InstCombine: Allow folding of xor into icmp by changing the predicate for vectors
The loop vectorizer can create this pattern.
Modified:
llvm/trunk/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp
llvm/trunk/test/Transforms/InstCombine/not.ll
Modified: llvm/trunk/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp?rev=228954&r1=228953&r2=228954&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp (original)
+++ llvm/trunk/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp Thu Feb 12 14:26:46 2015
@@ -2604,15 +2604,16 @@ Instruction *InstCombiner::visitXor(Bina
}
}
-
- if (ConstantInt *RHS = dyn_cast<ConstantInt>(Op1)) {
- if (RHS->isOne() && Op0->hasOneUse())
+ if (Constant *RHS = dyn_cast<Constant>(Op1)) {
+ if (RHS->isAllOnesValue() && Op0->hasOneUse())
// xor (cmp A, B), true = not (cmp A, B) = !cmp A, B
if (CmpInst *CI = dyn_cast<CmpInst>(Op0))
return CmpInst::Create(CI->getOpcode(),
CI->getInversePredicate(),
CI->getOperand(0), CI->getOperand(1));
+ }
+ if (ConstantInt *RHS = dyn_cast<ConstantInt>(Op1)) {
// fold (xor(zext(cmp)), 1) and (xor(sext(cmp)), -1) to ext(!cmp).
if (CastInst *Op0C = dyn_cast<CastInst>(Op0)) {
if (CmpInst *CI = dyn_cast<CmpInst>(Op0C->getOperand(0))) {
Modified: llvm/trunk/test/Transforms/InstCombine/not.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/InstCombine/not.ll?rev=228954&r1=228953&r2=228954&view=diff
==============================================================================
--- llvm/trunk/test/Transforms/InstCombine/not.ll (original)
+++ llvm/trunk/test/Transforms/InstCombine/not.ll Thu Feb 12 14:26:46 2015
@@ -52,3 +52,9 @@ entry:
%retval67 = zext i1 %tmp3 to i8 ; <i8> [#uses=1]
ret i8 %retval67
}
+
+define <2 x i1> @test7(<2 x i32> %A, <2 x i32> %B) {
+ %cond = icmp sle <2 x i32> %A, %B
+ %Ret = xor <2 x i1> %cond, <i1 true, i1 true>
+ ret <2 x i1> %Ret
+}
More information about the llvm-commits
mailing list