diff options
author | Sanjay Patel <spatel@rotateright.com> | 2018-10-22 22:04:13 +0000 |
---|---|---|
committer | Sanjay Patel <spatel@rotateright.com> | 2018-10-22 22:04:13 +0000 |
commit | 21a62e23d8730a356b22a10a3a364ea3a10d9ac2 (patch) | |
tree | 6936f673f23a5948d0a02d8716654c988ddb3e7c | |
parent | 3577af082ab7f34881f2302753a3faab4cc57bd6 (diff) | |
download | bcm5719-llvm-21a62e23d8730a356b22a10a3a364ea3a10d9ac2.tar.gz bcm5719-llvm-21a62e23d8730a356b22a10a3a364ea3a10d9ac2.zip |
[Reassociate] add vector tests with undef elements; NFC
Also, regenerate checks for these files. We should do better
on the vector tests by using the PatternMatch API instead of
BinaryOperator::isNot/isNeg.
llvm-svn: 344964
-rw-r--r-- | llvm/test/Transforms/Reassociate/inverses.ll | 77 | ||||
-rw-r--r-- | llvm/test/Transforms/Reassociate/negation.ll | 66 | ||||
-rw-r--r-- | llvm/test/Transforms/Reassociate/negation1.ll | 7 |
3 files changed, 107 insertions, 43 deletions
diff --git a/llvm/test/Transforms/Reassociate/inverses.ll b/llvm/test/Transforms/Reassociate/inverses.ll index 8500cd867fd..15c77206e72 100644 --- a/llvm/test/Transforms/Reassociate/inverses.ll +++ b/llvm/test/Transforms/Reassociate/inverses.ll @@ -1,46 +1,65 @@ +; NOTE: Assertions have been autogenerated by utils/update_test_checks.py ; RUN: opt < %s -reassociate -die -S | FileCheck %s +; (A&B)&~A == 0 define i32 @test1(i32 %a, i32 %b) { - %tmp.2 = and i32 %b, %a - %tmp.4 = xor i32 %a, -1 - ; (A&B)&~A == 0 - %tmp.5 = and i32 %tmp.2, %tmp.4 - ret i32 %tmp.5 ; CHECK-LABEL: @test1( -; CHECK: ret i32 0 +; CHECK-NEXT: ret i32 0 +; + %t2 = and i32 %b, %a + %t4 = xor i32 %a, -1 + %t5 = and i32 %t2, %t4 + ret i32 %t5 } +define <2 x i32> @not_op_vec_undef(<2 x i32> %a, <2 x i32> %b) { +; CHECK-LABEL: @not_op_vec_undef( +; CHECK-NEXT: [[T2:%.*]] = and <2 x i32> [[B:%.*]], [[A:%.*]] +; CHECK-NEXT: [[T4:%.*]] = xor <2 x i32> [[A]], <i32 -1, i32 undef> +; CHECK-NEXT: [[T5:%.*]] = and <2 x i32> [[T2]], [[T4]] +; CHECK-NEXT: ret <2 x i32> [[T5]] +; + %t2 = and <2 x i32> %b, %a + %t4 = xor <2 x i32> %a, <i32 -1, i32 undef> + %t5 = and <2 x i32> %t2, %t4 + ret <2 x i32> %t5 +} + +; A&~A == 0 define i32 @test2(i32 %a, i32 %b) { - %tmp.1 = and i32 %a, 1234 - %tmp.2 = and i32 %b, %tmp.1 - %tmp.4 = xor i32 %a, -1 - ; A&~A == 0 - %tmp.5 = and i32 %tmp.2, %tmp.4 - ret i32 %tmp.5 ; CHECK-LABEL: @test2( -; CHECK: ret i32 0 +; CHECK-NEXT: ret i32 0 +; + %t1 = and i32 %a, 1234 + %t2 = and i32 %b, %t1 + %t4 = xor i32 %a, -1 + %t5 = and i32 %t2, %t4 + ret i32 %t5 } +; (b+(a+1234))+-a -> b+1234 define i32 @test3(i32 %b, i32 %a) { - %tmp.1 = add i32 %a, 1234 - %tmp.2 = add i32 %b, %tmp.1 - %tmp.4 = sub i32 0, %a - ; (b+(a+1234))+-a -> b+1234 - %tmp.5 = add i32 %tmp.2, %tmp.4 - ret i32 %tmp.5 ; CHECK-LABEL: @test3( -; CHECK: %tmp.5 = add i32 %b, 1234 -; CHECK: ret i32 %tmp.5 +; CHECK-NEXT: [[T5:%.*]] = add i32 [[B:%.*]], 1234 +; CHECK-NEXT: ret i32 [[T5]] +; + %t1 = add i32 %a, 1234 + %t2 = add i32 %b, %t1 + %t4 = sub i32 0, %a + %t5 = add i32 %t2, %t4 + ret i32 %t5 } +; (b+(a+1234))+~a -> b+1233 define i32 @test4(i32 %b, i32 %a) { - %tmp.1 = add i32 %a, 1234 - %tmp.2 = add i32 %b, %tmp.1 - %tmp.4 = xor i32 %a, -1 - ; (b+(a+1234))+~a -> b+1233 - %tmp.5 = add i32 %tmp.2, %tmp.4 - ret i32 %tmp.5 ; CHECK-LABEL: @test4( -; CHECK: %tmp.5 = add i32 %b, 1233 -; CHECK: ret i32 %tmp.5 +; CHECK-NEXT: [[T5:%.*]] = add i32 [[B:%.*]], 1233 +; CHECK-NEXT: ret i32 [[T5]] +; + %t1 = add i32 %a, 1234 + %t2 = add i32 %b, %t1 + %t4 = xor i32 %a, -1 + %t5 = add i32 %t2, %t4 + ret i32 %t5 } + diff --git a/llvm/test/Transforms/Reassociate/negation.ll b/llvm/test/Transforms/Reassociate/negation.ll index 12d2c86192b..e1f9a421a9c 100644 --- a/llvm/test/Transforms/Reassociate/negation.ll +++ b/llvm/test/Transforms/Reassociate/negation.ll @@ -1,14 +1,15 @@ +; NOTE: Assertions have been autogenerated by utils/update_test_checks.py ; RUN: opt < %s -reassociate -instcombine -S | FileCheck %s ; Test that we can turn things like X*-(Y*Z) -> X*-1*Y*Z. define i32 @test1(i32 %a, i32 %b, i32 %z) { -; CHECK-LABEL: test1 -; CHECK-NEXT: %e = mul i32 %a, 12345 -; CHECK-NEXT: %f = mul i32 %e, %b -; CHECK-NEXT: %g = mul i32 %f, %z -; CHECK-NEXT: ret i32 %g - +; CHECK-LABEL: @test1( +; CHECK-NEXT: [[E:%.*]] = mul i32 [[A:%.*]], 12345 +; CHECK-NEXT: [[F:%.*]] = mul i32 [[E]], [[B:%.*]] +; CHECK-NEXT: [[G:%.*]] = mul i32 [[F]], [[Z:%.*]] +; CHECK-NEXT: ret i32 [[G]] +; %c = sub i32 0, %z %d = mul i32 %a, %b %e = mul i32 %c, %d @@ -18,14 +19,57 @@ define i32 @test1(i32 %a, i32 %b, i32 %z) { } define i32 @test2(i32 %a, i32 %b, i32 %z) { -; CHECK-LABEL: test2 -; CHECK-NEXT: %e = mul i32 %a, 40 -; CHECK-NEXT: %f = mul i32 %e, %z -; CHECK-NEXT: ret i32 %f - +; CHECK-LABEL: @test2( +; CHECK-NEXT: [[E:%.*]] = mul i32 [[A:%.*]], 40 +; CHECK-NEXT: [[F:%.*]] = mul i32 [[E]], [[Z:%.*]] +; CHECK-NEXT: ret i32 [[F]] +; %d = mul i32 %z, 40 %c = sub i32 0, %d %e = mul i32 %a, %c %f = sub i32 0, %e ret i32 %f } + +define <2 x i32> @negate_vec_undefs(<2 x i32> %a, <2 x i32> %b, <2 x i32> %z) { +; CHECK-LABEL: @negate_vec_undefs( +; CHECK-NEXT: [[TMP1:%.*]] = mul <2 x i32> [[Z:%.*]], <i32 -40, i32 -40> +; CHECK-NEXT: [[E:%.*]] = mul <2 x i32> [[TMP1]], [[A:%.*]] +; CHECK-NEXT: [[F:%.*]] = sub <2 x i32> <i32 0, i32 undef>, [[E]] +; CHECK-NEXT: ret <2 x i32> [[F]] +; + %d = mul <2 x i32> %z, <i32 40, i32 40> + %c = sub <2 x i32> <i32 0, i32 undef>, %d + %e = mul <2 x i32> %a, %c + %f = sub <2 x i32> <i32 0, i32 undef>, %e + ret <2 x i32> %f +} + +define i32 @not_not(i32 %a, i32 %b, i32 %z) { +; CHECK-LABEL: @not_not( +; CHECK-NEXT: [[D:%.*]] = and i32 [[Z:%.*]], 40 +; CHECK-NEXT: [[A_NOT:%.*]] = xor i32 [[A:%.*]], -1 +; CHECK-NEXT: [[F:%.*]] = and i32 [[D]], [[A_NOT]] +; CHECK-NEXT: ret i32 [[F]] +; + %d = and i32 %z, 40 + %c = xor i32 -1, %d + %e = or i32 %a, %c + %f = xor i32 -1, %e + ret i32 %f +} + +define <2 x i32> @not_vec_undefs(<2 x i32> %a, <2 x i32> %b, <2 x i32> %z) { +; CHECK-LABEL: @not_vec_undefs( +; CHECK-NEXT: [[D:%.*]] = or <2 x i32> [[Z:%.*]], <i32 40, i32 40> +; CHECK-NEXT: [[A_NOT:%.*]] = xor <2 x i32> [[A:%.*]], <i32 -1, i32 -1> +; CHECK-NEXT: [[F:%.*]] = or <2 x i32> [[D]], [[A_NOT]] +; CHECK-NEXT: ret <2 x i32> [[F]] +; + %d = or <2 x i32> %z, <i32 40, i32 40> + %c = xor <2 x i32> <i32 undef, i32 -1>, %d + %e = and <2 x i32> %a, %c + %f = xor <2 x i32> <i32 undef, i32 -1>, %e + ret <2 x i32> %f +} + diff --git a/llvm/test/Transforms/Reassociate/negation1.ll b/llvm/test/Transforms/Reassociate/negation1.ll index 34b943cf496..674e57df956 100644 --- a/llvm/test/Transforms/Reassociate/negation1.ll +++ b/llvm/test/Transforms/Reassociate/negation1.ll @@ -1,11 +1,12 @@ +; NOTE: Assertions have been autogenerated by utils/update_test_checks.py ; RUN: opt < %s -reassociate -instcombine -S | FileCheck %s ; Test that we can turn things like A*B + X - A*B -> X. define i32 @test1(i32 %a, i32 %b, i32 %x) { -; CHECK-LABEL: test1 -; CHECK: ret i32 %x - +; CHECK-LABEL: @test1( +; CHECK-NEXT: ret i32 [[X:%.*]] +; %c = mul i32 %a, %b %d = add i32 %c, %x %c1 = mul i32 %a, %b |