blob: 4aa134ae7fb4c716bdd478c443600a95ce5c6b00 [file] [log] [blame]
Dan Gohman28beeea2007-08-15 13:36:28 +00001; RUN: llvm-upgrade < %s | llvm-as | opt -reassociate -gcse | llvm-dis | grep add | count 6
Chris Lattnerf4946df2005-05-08 20:56:02 +00002; Each of these functions should turn into two adds each.
3
4%e = external global int
5%a = external global int
6%b = external global int
7%c = external global int
8%f = external global int
9
10implementation
11
12void %test1() {
13 %A = load int* %a
14 %B = load int* %b
15 %C = load int* %c
16 %t1 = add int %A, %B
17 %t2 = add int %t1, %C
18 %t3 = add int %C, %A
19 %t4 = add int %t3, %B
20 store int %t2, int* %e ; e = (a+b)+c;
21 store int %t4, int* %f ; f = (a+c)+b
22 ret void
23}
24
25void %test2() {
26 %A = load int* %a
27 %B = load int* %b
28 %C = load int* %c
29 %t1 = add int %A, %B
30 %t2 = add int %t1, %C
31 %t3 = add int %C, %A
32 %t4 = add int %t3, %B
33 store int %t2, int* %e ; e = c+(a+b)
34 store int %t4, int* %f ; f = (c+a)+b
35 ret void
36}
37
38void %test3() {
39 %A = load int* %a
40 %B = load int* %b
41 %C = load int* %c
42 %t1 = add int %B, %A
43 %t2 = add int %t1, %C
44 %t3 = add int %C, %A
45 %t4 = add int %t3, %B
46 store int %t2, int* %e ; e = c+(b+a)
47 store int %t4, int* %f ; f = (c+a)+b
48 ret void
49}
50