From: Craig Topper Date: Tue, 4 Apr 2017 21:44:56 +0000 (+0000) Subject: [InstCombine] Turn subtract of vectors of i1 into xor like we do for scalar i1. Match... X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=7597f2aad70262e318f0042dd2f4586cb8524563;p=llvm [InstCombine] Turn subtract of vectors of i1 into xor like we do for scalar i1. Matches what we already do for add. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@299472 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Transforms/InstCombine/InstCombineAddSub.cpp b/lib/Transforms/InstCombine/InstCombineAddSub.cpp index 4cd7cbc4e00..cb76902321a 100644 --- a/lib/Transforms/InstCombine/InstCombineAddSub.cpp +++ b/lib/Transforms/InstCombine/InstCombineAddSub.cpp @@ -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). diff --git a/test/Transforms/InstCombine/sub.ll b/test/Transforms/InstCombine/sub.ll index 03946c7dbe6..6e8ef715582 100644 --- a/test/Transforms/InstCombine/sub.ll +++ b/test/Transforms/InstCombine/sub.ll @@ -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 +} +