[llvm] r344964 - [Reassociate] add vector tests with undef elements; NFC

Sanjay Patel via llvm-commits llvm-commits at lists.llvm.org
Mon Oct 22 15:04:14 PDT 2018


Author: spatel
Date: Mon Oct 22 15:04:13 2018
New Revision: 344964

URL: http://llvm.org/viewvc/llvm-project?rev=344964&view=rev
Log:
[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.

Modified:
    llvm/trunk/test/Transforms/Reassociate/inverses.ll
    llvm/trunk/test/Transforms/Reassociate/negation.ll
    llvm/trunk/test/Transforms/Reassociate/negation1.ll

Modified: llvm/trunk/test/Transforms/Reassociate/inverses.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/Reassociate/inverses.ll?rev=344964&r1=344963&r2=344964&view=diff
==============================================================================
--- llvm/trunk/test/Transforms/Reassociate/inverses.ll (original)
+++ llvm/trunk/test/Transforms/Reassociate/inverses.ll Mon Oct 22 15:04:13 2018
@@ -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
 }
+

Modified: llvm/trunk/test/Transforms/Reassociate/negation.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/Reassociate/negation.ll?rev=344964&r1=344963&r2=344964&view=diff
==============================================================================
--- llvm/trunk/test/Transforms/Reassociate/negation.ll (original)
+++ llvm/trunk/test/Transforms/Reassociate/negation.ll Mon Oct 22 15:04:13 2018
@@ -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
+}
+

Modified: llvm/trunk/test/Transforms/Reassociate/negation1.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/Reassociate/negation1.ll?rev=344964&r1=344963&r2=344964&view=diff
==============================================================================
--- llvm/trunk/test/Transforms/Reassociate/negation1.ll (original)
+++ llvm/trunk/test/Transforms/Reassociate/negation1.ll Mon Oct 22 15:04:13 2018
@@ -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




More information about the llvm-commits mailing list