diff options
author | Benjamin Kramer <benny.kra@googlemail.com> | 2015-02-12 20:26:46 +0000 |
---|---|---|
committer | Benjamin Kramer <benny.kra@googlemail.com> | 2015-02-12 20:26:46 +0000 |
commit | 443c7967eacb73b22805bab12e45475ec15feeef (patch) | |
tree | e803b6a8d9c15509037d0ac4ff0ba8f12fbcddee | |
parent | 295eaad2b3118e8ef71035544d6de3605a4db36f (diff) | |
download | bcm5719-llvm-443c7967eacb73b22805bab12e45475ec15feeef.tar.gz bcm5719-llvm-443c7967eacb73b22805bab12e45475ec15feeef.zip |
InstCombine: Allow folding of xor into icmp by changing the predicate for vectors
The loop vectorizer can create this pattern.
llvm-svn: 228954
-rw-r--r-- | llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp | 7 | ||||
-rw-r--r-- | llvm/test/Transforms/InstCombine/not.ll | 6 |
2 files changed, 10 insertions, 3 deletions
diff --git a/llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp b/llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp index c65441e1c85..6178d9c73a1 100644 --- a/llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp +++ b/llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp @@ -2604,15 +2604,16 @@ Instruction *InstCombiner::visitXor(BinaryOperator &I) { } } - - 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))) { diff --git a/llvm/test/Transforms/InstCombine/not.ll b/llvm/test/Transforms/InstCombine/not.ll index 4012ce1ea4b..9d59edd7934 100644 --- a/llvm/test/Transforms/InstCombine/not.ll +++ b/llvm/test/Transforms/InstCombine/not.ll @@ -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 +} |