llvm.org GIT mirror llvm / 5528b0e
[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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@344964 91177308-0d34-0410-b5e6-96231b3b80d8 Sanjay Patel 10 months ago
3 changed file(s) with 111 addition(s) and 47 deletion(s). Raw diff Collapse all Expand all
0 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
1 ; RUN: opt < %s -reassociate -die -S | FileCheck %s
12
3 ; (A&B)&~A == 0
24 define i32 @test1(i32 %a, i32 %b) {
3 %tmp.2 = and i32 %b, %a
4 %tmp.4 = xor i32 %a, -1
5 ; (A&B)&~A == 0
6 %tmp.5 = and i32 %tmp.2, %tmp.4
7 ret i32 %tmp.5
85 ; CHECK-LABEL: @test1(
9 ; CHECK: ret i32 0
6 ; CHECK-NEXT: ret i32 0
7 ;
8 %t2 = and i32 %b, %a
9 %t4 = xor i32 %a, -1
10 %t5 = and i32 %t2, %t4
11 ret i32 %t5
1012 }
1113
12 define i32 @test2(i32 %a, i32 %b) {
13 %tmp.1 = and i32 %a, 1234
14 %tmp.2 = and i32 %b, %tmp.1
15 %tmp.4 = xor i32 %a, -1
16 ; A&~A == 0
17 %tmp.5 = and i32 %tmp.2, %tmp.4
18 ret i32 %tmp.5
19 ; CHECK-LABEL: @test2(
20 ; CHECK: ret i32 0
14 define <2 x i32> @not_op_vec_undef(<2 x i32> %a, <2 x i32> %b) {
15 ; CHECK-LABEL: @not_op_vec_undef(
16 ; CHECK-NEXT: [[T2:%.*]] = and <2 x i32> [[B:%.*]], [[A:%.*]]
17 ; CHECK-NEXT: [[T4:%.*]] = xor <2 x i32> [[A]],
18 ; CHECK-NEXT: [[T5:%.*]] = and <2 x i32> [[T2]], [[T4]]
19 ; CHECK-NEXT: ret <2 x i32> [[T5]]
20 ;
21 %t2 = and <2 x i32> %b, %a
22 %t4 = xor <2 x i32> %a,
23 %t5 = and <2 x i32> %t2, %t4
24 ret <2 x i32> %t5
2125 }
2226
23 define i32 @test3(i32 %b, i32 %a) {
24 %tmp.1 = add i32 %a, 1234
25 %tmp.2 = add i32 %b, %tmp.1
26 %tmp.4 = sub i32 0, %a
27 ; (b+(a+1234))+-a -> b+1234
28 %tmp.5 = add i32 %tmp.2, %tmp.4
29 ret i32 %tmp.5
30 ; CHECK-LABEL: @test3(
31 ; CHECK: %tmp.5 = add i32 %b, 1234
32 ; CHECK: ret i32 %tmp.5
27 ; A&~A == 0
28 define i32 @test2(i32 %a, i32 %b) {
29 ; CHECK-LABEL: @test2(
30 ; CHECK-NEXT: ret i32 0
31 ;
32 %t1 = and i32 %a, 1234
33 %t2 = and i32 %b, %t1
34 %t4 = xor i32 %a, -1
35 %t5 = and i32 %t2, %t4
36 ret i32 %t5
3337 }
3438
39 ; (b+(a+1234))+-a -> b+1234
40 define i32 @test3(i32 %b, i32 %a) {
41 ; CHECK-LABEL: @test3(
42 ; CHECK-NEXT: [[T5:%.*]] = add i32 [[B:%.*]], 1234
43 ; CHECK-NEXT: ret i32 [[T5]]
44 ;
45 %t1 = add i32 %a, 1234
46 %t2 = add i32 %b, %t1
47 %t4 = sub i32 0, %a
48 %t5 = add i32 %t2, %t4
49 ret i32 %t5
50 }
51
52 ; (b+(a+1234))+~a -> b+1233
3553 define i32 @test4(i32 %b, i32 %a) {
36 %tmp.1 = add i32 %a, 1234
37 %tmp.2 = add i32 %b, %tmp.1
38 %tmp.4 = xor i32 %a, -1
39 ; (b+(a+1234))+~a -> b+1233
40 %tmp.5 = add i32 %tmp.2, %tmp.4
41 ret i32 %tmp.5
4254 ; CHECK-LABEL: @test4(
43 ; CHECK: %tmp.5 = add i32 %b, 1233
44 ; CHECK: ret i32 %tmp.5
55 ; CHECK-NEXT: [[T5:%.*]] = add i32 [[B:%.*]], 1233
56 ; CHECK-NEXT: ret i32 [[T5]]
57 ;
58 %t1 = add i32 %a, 1234
59 %t2 = add i32 %b, %t1
60 %t4 = xor i32 %a, -1
61 %t5 = add i32 %t2, %t4
62 ret i32 %t5
4563 }
64
0 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
1 ; RUN: opt < %s -reassociate -instcombine -S | FileCheck %s
12
23 ; Test that we can turn things like X*-(Y*Z) -> X*-1*Y*Z.
34
45 define i32 @test1(i32 %a, i32 %b, i32 %z) {
5 ; CHECK-LABEL: test1
6 ; CHECK-NEXT: %e = mul i32 %a, 12345
7 ; CHECK-NEXT: %f = mul i32 %e, %b
8 ; CHECK-NEXT: %g = mul i32 %f, %z
9 ; CHECK-NEXT: ret i32 %g
10
6 ; CHECK-LABEL: @test1(
7 ; CHECK-NEXT: [[E:%.*]] = mul i32 [[A:%.*]], 12345
8 ; CHECK-NEXT: [[F:%.*]] = mul i32 [[E]], [[B:%.*]]
9 ; CHECK-NEXT: [[G:%.*]] = mul i32 [[F]], [[Z:%.*]]
10 ; CHECK-NEXT: ret i32 [[G]]
11 ;
1112 %c = sub i32 0, %z
1213 %d = mul i32 %a, %b
1314 %e = mul i32 %c, %d
1718 }
1819
1920 define i32 @test2(i32 %a, i32 %b, i32 %z) {
20 ; CHECK-LABEL: test2
21 ; CHECK-NEXT: %e = mul i32 %a, 40
22 ; CHECK-NEXT: %f = mul i32 %e, %z
23 ; CHECK-NEXT: ret i32 %f
24
21 ; CHECK-LABEL: @test2(
22 ; CHECK-NEXT: [[E:%.*]] = mul i32 [[A:%.*]], 40
23 ; CHECK-NEXT: [[F:%.*]] = mul i32 [[E]], [[Z:%.*]]
24 ; CHECK-NEXT: ret i32 [[F]]
25 ;
2526 %d = mul i32 %z, 40
2627 %c = sub i32 0, %d
2728 %e = mul i32 %a, %c
2829 %f = sub i32 0, %e
2930 ret i32 %f
3031 }
32
33 define <2 x i32> @negate_vec_undefs(<2 x i32> %a, <2 x i32> %b, <2 x i32> %z) {
34 ; CHECK-LABEL: @negate_vec_undefs(
35 ; CHECK-NEXT: [[TMP1:%.*]] = mul <2 x i32> [[Z:%.*]],
36 ; CHECK-NEXT: [[E:%.*]] = mul <2 x i32> [[TMP1]], [[A:%.*]]
37 ; CHECK-NEXT: [[F:%.*]] = sub <2 x i32> , [[E]]
38 ; CHECK-NEXT: ret <2 x i32> [[F]]
39 ;
40 %d = mul <2 x i32> %z,
41 %c = sub <2 x i32> , %d
42 %e = mul <2 x i32> %a, %c
43 %f = sub <2 x i32> , %e
44 ret <2 x i32> %f
45 }
46
47 define i32 @not_not(i32 %a, i32 %b, i32 %z) {
48 ; CHECK-LABEL: @not_not(
49 ; CHECK-NEXT: [[D:%.*]] = and i32 [[Z:%.*]], 40
50 ; CHECK-NEXT: [[A_NOT:%.*]] = xor i32 [[A:%.*]], -1
51 ; CHECK-NEXT: [[F:%.*]] = and i32 [[D]], [[A_NOT]]
52 ; CHECK-NEXT: ret i32 [[F]]
53 ;
54 %d = and i32 %z, 40
55 %c = xor i32 -1, %d
56 %e = or i32 %a, %c
57 %f = xor i32 -1, %e
58 ret i32 %f
59 }
60
61 define <2 x i32> @not_vec_undefs(<2 x i32> %a, <2 x i32> %b, <2 x i32> %z) {
62 ; CHECK-LABEL: @not_vec_undefs(
63 ; CHECK-NEXT: [[D:%.*]] = or <2 x i32> [[Z:%.*]],
64 ; CHECK-NEXT: [[A_NOT:%.*]] = xor <2 x i32> [[A:%.*]],
65 ; CHECK-NEXT: [[F:%.*]] = or <2 x i32> [[D]], [[A_NOT]]
66 ; CHECK-NEXT: ret <2 x i32> [[F]]
67 ;
68 %d = or <2 x i32> %z,
69 %c = xor <2 x i32> , %d
70 %e = and <2 x i32> %a, %c
71 %f = xor <2 x i32> , %e
72 ret <2 x i32> %f
73 }
74
0 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
1 ; RUN: opt < %s -reassociate -instcombine -S | FileCheck %s
12
23 ; Test that we can turn things like A*B + X - A*B -> X.
34
45 define i32 @test1(i32 %a, i32 %b, i32 %x) {
5 ; CHECK-LABEL: test1
6 ; CHECK: ret i32 %x
7
6 ; CHECK-LABEL: @test1(
7 ; CHECK-NEXT: ret i32 [[X:%.*]]
8 ;
89 %c = mul i32 %a, %b
910 %d = add i32 %c, %x
1011 %c1 = mul i32 %a, %b