[llvm] r299472 - [InstCombine] Turn subtract of vectors of i1 into xor like we do for scalar i1. Matches what we already do for add.
Craig Topper via llvm-commits
llvm-commits at lists.llvm.org
Tue Apr 4 14:44:56 PDT 2017
Author: ctopper
Date: Tue Apr 4 16:44:56 2017
New Revision: 299472
URL: http://llvm.org/viewvc/llvm-project?rev=299472&view=rev
Log:
[InstCombine] Turn subtract of vectors of i1 into xor like we do for scalar i1. Matches what we already do for add.
Modified:
llvm/trunk/lib/Transforms/InstCombine/InstCombineAddSub.cpp
llvm/trunk/test/Transforms/InstCombine/sub.ll
Modified: llvm/trunk/lib/Transforms/InstCombine/InstCombineAddSub.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/InstCombine/InstCombineAddSub.cpp?rev=299472&r1=299471&r2=299472&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/InstCombine/InstCombineAddSub.cpp (original)
+++ llvm/trunk/lib/Transforms/InstCombine/InstCombineAddSub.cpp Tue Apr 4 16:44:56 2017
@@ -1563,7 +1563,7 @@ Instruction *InstCombiner::visitSub(Bina
return Res;
}
- if (I.getType()->isIntegerTy(1))
+ if (I.getType()->getScalarType()->isIntegerTy(1))
return BinaryOperator::CreateXor(Op0, Op1);
// Replace (-1 - A) with (~A).
Modified: llvm/trunk/test/Transforms/InstCombine/sub.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/InstCombine/sub.ll?rev=299472&r1=299471&r2=299472&view=diff
==============================================================================
--- llvm/trunk/test/Transforms/InstCombine/sub.ll (original)
+++ llvm/trunk/test/Transforms/InstCombine/sub.ll Tue Apr 4 16:44:56 2017
@@ -744,3 +744,12 @@ define i32 @test52(i32 %X) {
%res = and i32 %sub, 127
ret i32 %res
}
+
+define <2 x i1> @test53(<2 x i1> %A, <2 x i1> %B) {
+ %sub = sub <2 x i1> %A, %B
+ ret <2 x i1> %sub
+; CHECK-LABEL: @test53(
+; CHECK-NEXT: %sub = xor <2 x i1> %A, %B
+; CHECK-NEXT: ret <2 x i1> %sub
+}
+
More information about the llvm-commits
mailing list