[InstCombine] Turn subtract of vectors of i1 into xor like we do for scalar i1. Match...
authorCraig Topper <craig.topper@gmail.com>
Tue, 4 Apr 2017 21:44:56 +0000 (21:44 +0000)
committerCraig Topper <craig.topper@gmail.com>
Tue, 4 Apr 2017 21:44:56 +0000 (21:44 +0000)
llvm-svn: 299472

llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp
llvm/test/Transforms/InstCombine/sub.ll

index 4cd7cbc..cb76902 100644 (file)
@@ -1563,7 +1563,7 @@ Instruction *InstCombiner::visitSub(BinaryOperator &I) {
     return Res;
   }
 
-  if (I.getType()->isIntegerTy(1))
+  if (I.getType()->getScalarType()->isIntegerTy(1))
     return BinaryOperator::CreateXor(Op0, Op1);
 
   // Replace (-1 - A) with (~A).
index 03946c7..6e8ef71 100644 (file)
@@ -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
+}
+