1 ;; Both functions in this testcase should codegen to the same function, and
2 ;; neither of them should require spilling anything to the stack.
4 ; RUN: llvm-upgrade < %s | llvm-as | llc -march=x86 -stats |& \
5 ; RUN: not grep {Number of register spills}
7 ;; This can be compiled to use three registers if the loads are not
8 ;; folded into the multiplies, 2 registers otherwise.
9 int %regpressure1(int* %P) {
11 %Bp = getelementptr int* %P, int 1
14 %Cp = getelementptr int* %P, int 2
17 %Dp = getelementptr int* %P, int 3
20 %Ep = getelementptr int* %P, int 4
23 %Fp = getelementptr int* %P, int 5
26 %Gp = getelementptr int* %P, int 6
29 %Hp = getelementptr int* %P, int 7
32 %Ip = getelementptr int* %P, int 8
35 %Jp = getelementptr int* %P, int 9
41 ;; This testcase should produce identical code to the test above.
42 int %regpressure2(int* %P) {
44 %Bp = getelementptr int* %P, int 1
46 %Cp = getelementptr int* %P, int 2
48 %Dp = getelementptr int* %P, int 3
50 %Ep = getelementptr int* %P, int 4
52 %Fp = getelementptr int* %P, int 5
54 %Gp = getelementptr int* %P, int 6
56 %Hp = getelementptr int* %P, int 7
58 %Ip = getelementptr int* %P, int 8
60 %Jp = getelementptr int* %P, int 9
74 ;; adds should be the same as muls.
75 int %regpressure3(short* %P, bool %Cond, int* %Other) {
77 %Bp = getelementptr short* %P, int 1
79 %Cp = getelementptr short* %P, int 2
81 %Dp = getelementptr short* %P, int 3
83 %Ep = getelementptr short* %P, int 4
85 %Fp = getelementptr short* %P, int 5
87 %Gp = getelementptr short* %P, int 6
89 %Hp = getelementptr short* %P, int 7
91 %Ip = getelementptr short* %P, int 8
93 %Jp = getelementptr short* %P, int 9
96 ;; These casts prevent folding the loads into the adds.
97 %A = cast short %A to int
98 %B = cast short %B to int
99 %D = cast short %D to int
100 %C = cast short %C to int
101 %E = cast short %E to int
102 %F = cast short %F to int
103 %G = cast short %G to int
104 %H = cast short %H to int
105 %I = cast short %I to int
106 %J = cast short %J to int
108 %s2 = add int %C, %s1
109 %s3 = add int %D, %s2
110 %s4 = add int %E, %s3
111 %s5 = add int %F, %s4
112 %s6 = add int %G, %s5
113 %s7 = add int %H, %s6
114 %s8 = add int %I, %s7
115 %s9 = add int %J, %s8