From 16a42ca274f95e5b4eb04719109f1af028b3b159 Mon Sep 17 00:00:00 2001 From: Sanjay Patel Date: Sat, 30 Jun 2018 14:11:46 +0000 Subject: [PATCH] [InstCombine] add tests for negate vector with undef elts; NFC llvm-svn: 336050 --- llvm/test/Transforms/InstCombine/add.ll | 30 ++++++++++++++++++++++--- 1 file changed, 27 insertions(+), 3 deletions(-) diff --git a/llvm/test/Transforms/InstCombine/add.ll b/llvm/test/Transforms/InstCombine/add.ll index 04a510871328..c673a77e9e5f 100644 --- a/llvm/test/Transforms/InstCombine/add.ll +++ b/llvm/test/Transforms/InstCombine/add.ll @@ -119,6 +119,30 @@ define i32 @test5(i32 %A, i32 %B) { ret i32 %D } +define <2 x i8> @neg_op0_vec_undef_elt(<2 x i8> %a, <2 x i8> %b) { +; CHECK-LABEL: @neg_op0_vec_undef_elt( +; CHECK-NEXT: [[NEGA:%.*]] = sub <2 x i8> , [[A:%.*]] +; CHECK-NEXT: [[R:%.*]] = add <2 x i8> [[NEGA]], [[B:%.*]] +; CHECK-NEXT: ret <2 x i8> [[R]] +; + %nega = sub <2 x i8> , %a + %r = add <2 x i8> %nega, %b + ret <2 x i8> %r +} + +define <2 x i8> @neg_neg_vec_undef_elt(<2 x i8> %a, <2 x i8> %b) { +; CHECK-LABEL: @neg_neg_vec_undef_elt( +; CHECK-NEXT: [[NEGA:%.*]] = sub <2 x i8> , [[A:%.*]] +; CHECK-NEXT: [[NEGB:%.*]] = sub <2 x i8> , [[B:%.*]] +; CHECK-NEXT: [[R:%.*]] = add <2 x i8> [[NEGA]], [[NEGB]] +; CHECK-NEXT: ret <2 x i8> [[R]] +; + %nega = sub <2 x i8> , %a + %negb = sub <2 x i8> , %b + %r = add <2 x i8> %nega, %negb + ret <2 x i8> %r +} + ; C = 7*A+A == 8*A == A << 3 define i32 @test6(i32 %A) { ; CHECK-LABEL: @test6( @@ -806,7 +830,7 @@ final: ; E = (A + 1) + ~B = A - B define i32 @add_not_increment(i32 %A, i32 %B) { ; CHECK-LABEL: @add_not_increment( -; CHECK-NEXT: [[E:%.*]] = sub i32 %A, %B +; CHECK-NEXT: [[E:%.*]] = sub i32 [[A:%.*]], [[B:%.*]] ; CHECK-NEXT: ret i32 [[E]] ; %C = xor i32 %B, -1 @@ -818,7 +842,7 @@ define i32 @add_not_increment(i32 %A, i32 %B) { ; E = (A + 1) + ~B = A - B define <2 x i32> @add_not_increment_vec(<2 x i32> %A, <2 x i32> %B) { ; CHECK-LABEL: @add_not_increment_vec( -; CHECK-NEXT: [[E:%.*]] = sub <2 x i32> %A, %B +; CHECK-NEXT: [[E:%.*]] = sub <2 x i32> [[A:%.*]], [[B:%.*]] ; CHECK-NEXT: ret <2 x i32> [[E]] ; %C = xor <2 x i32> %B, @@ -830,7 +854,7 @@ define <2 x i32> @add_not_increment_vec(<2 x i32> %A, <2 x i32> %B) { ; E = ~B + (1 + A) = A - B define i32 @add_not_increment_commuted(i32 %A, i32 %B) { ; CHECK-LABEL: @add_not_increment_commuted( -; CHECK-NEXT: [[E:%.*]] = sub i32 %A, %B +; CHECK-NEXT: [[E:%.*]] = sub i32 [[A:%.*]], [[B:%.*]] ; CHECK-NEXT: ret i32 [[E]] ; %C = xor i32 %B, -1