llvm.org GIT mirror llvm / f4946df
new testcases for PR557 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@21782 91177308-0d34-0410-b5e6-96231b3b80d8 Chris Lattner 14 years ago
2 changed file(s) with 70 addition(s) and 0 deletion(s). Raw diff Collapse all Expand all
0 ; RUN: llvm-as < %s | opt -reassociate -gcse | llvm-dis | grep add | wc -l | grep 6
1 ; Each of these functions should turn into two adds each.
2
3 %e = external global int
4 %a = external global int
5 %b = external global int
6 %c = external global int
7 %f = external global int
8
9 implementation
10
11 void %test1() {
12 %A = load int* %a
13 %B = load int* %b
14 %C = load int* %c
15 %t1 = add int %A, %B
16 %t2 = add int %t1, %C
17 %t3 = add int %C, %A
18 %t4 = add int %t3, %B
19 store int %t2, int* %e ; e = (a+b)+c;
20 store int %t4, int* %f ; f = (a+c)+b
21 ret void
22 }
23
24 void %test2() {
25 %A = load int* %a
26 %B = load int* %b
27 %C = load int* %c
28 %t1 = add int %A, %B
29 %t2 = add int %t1, %C
30 %t3 = add int %C, %A
31 %t4 = add int %t3, %B
32 store int %t2, int* %e ; e = c+(a+b)
33 store int %t4, int* %f ; f = (c+a)+b
34 ret void
35 }
36
37 void %test3() {
38 %A = load int* %a
39 %B = load int* %b
40 %C = load int* %c
41 %t1 = add int %B, %A
42 %t2 = add int %t1, %C
43 %t3 = add int %C, %A
44 %t4 = add int %t3, %B
45 store int %t2, int* %e ; e = c+(b+a)
46 store int %t4, int* %f ; f = (c+a)+b
47 ret void
48 }
49
0 ; RUN: llvm-as < %s | opt -reassociate -gcse -instcombine | llvm-dis | not grep add
1
2 %a = weak global int 0
3 %b = weak global int 0
4 %c = weak global int 0
5 %d = weak global int 0
6
7 implementation
8
9 int %foo() {
10 %tmp.0 = load int* %a
11 %tmp.1 = load int* %b
12 %tmp.2 = add int %tmp.0, %tmp.1 ; (a+b)
13 %tmp.4 = load int* %c
14 %tmp.5 = add int %tmp.2, %tmp.4 ; (a+b)+c
15 %tmp.8 = add int %tmp.0, %tmp.4 ; (a+c)
16 %tmp.11 = add int %tmp.8, %tmp.1 ; (a+c)+b
17 %RV = xor int %tmp.5, %tmp.11 ; X ^ X = 0
18 ret int %RV
19 }