1; RUN: llc -verify-machineinstrs < %s -mtriple=armv4t   | FileCheck %s -check-prefix=CHECK-v4A32
2; RUN: llc -verify-machineinstrs < %s -mtriple=armv7a   | FileCheck %s -check-prefix=CHECK-v7A32
3; RUN: llc -verify-machineinstrs < %s -mtriple=thumbv7a | FileCheck %s -check-prefix=CHECK-THUMB2
4; FIXME: There are no tests for Thumb1 since dynamic stack alignment is not supported for
5; Thumb1.
6
7define i32 @f_bic_can_be_used_align() nounwind {
8entry:
9; CHECK-LABEL: f_bic_can_be_used_align:
10; CHECK-v7A32: bfc        sp, #0, #8
11; CHECK-v4A32: bic        sp, sp, #255
12; CHECK-THUMB2:	mov	r4, sp
13; CHECK-THUMB2-NEXT: bfc	r4, #0, #8
14; CHECK-THUMB2-NEXT: mov	sp, r4
15  %x = alloca i32, align 256
16  store volatile i32 0, i32* %x, align 256
17  ret i32 0
18}
19
20define i32 @f_too_large_for_bic_align() nounwind {
21entry:
22; CHECK-LABEL: f_too_large_for_bic_align:
23; CHECK-v7A32: bfc sp, #0, #9
24; CHECK-v4A32: lsr sp, sp, #9
25; CHECK-v4A32: lsl sp, sp, #9
26; CHECK-THUMB2:	mov	r4, sp
27; CHECK-THUMB2-NEXT:	bfc	r4, #0, #9
28; CHECK-THUMB2-NEXT:	mov	sp, r4
29  %x = alloca i32, align 512
30  store volatile i32 0, i32* %x, align 512
31  ret i32 0
32}
33
34define i8* @f_alignedDPRCS2Spills(double* %d) #0 {
35entry:
36; CHECK-LABEL: f_too_large_for_bic_align:
37; CHECK-v7A32: bfc sp, #0, #12
38; CHECK-v4A32: lsr sp, sp, #12
39; CHECK-v4A32: lsl sp, sp, #12
40; CHECK-THUMB2:      bfc	r4, #0, #12
41; CHECK-THUMB2-NEXT: mov	sp, r4
42  %a = alloca i8, align 4096
43  %0 = load double, double* %d, align 4
44  %arrayidx1 = getelementptr inbounds double, double* %d, i32 1
45  %1 = load double, double* %arrayidx1, align 4
46  %arrayidx2 = getelementptr inbounds double, double* %d, i32 2
47  %2 = load double, double* %arrayidx2, align 4
48  %arrayidx3 = getelementptr inbounds double, double* %d, i32 3
49  %3 = load double, double* %arrayidx3, align 4
50  %arrayidx4 = getelementptr inbounds double, double* %d, i32 4
51  %4 = load double, double* %arrayidx4, align 4
52  %arrayidx5 = getelementptr inbounds double, double* %d, i32 5
53  %5 = load double, double* %arrayidx5, align 4
54  %arrayidx6 = getelementptr inbounds double, double* %d, i32 6
55  %6 = load double, double* %arrayidx6, align 4
56  %arrayidx7 = getelementptr inbounds double, double* %d, i32 7
57  %7 = load double, double* %arrayidx7, align 4
58  %arrayidx8 = getelementptr inbounds double, double* %d, i32 8
59  %8 = load double, double* %arrayidx8, align 4
60  %arrayidx9 = getelementptr inbounds double, double* %d, i32 9
61  %9 = load double, double* %arrayidx9, align 4
62  %arrayidx10 = getelementptr inbounds double, double* %d, i32 10
63  %10 = load double, double* %arrayidx10, align 4
64  %arrayidx11 = getelementptr inbounds double, double* %d, i32 11
65  %11 = load double, double* %arrayidx11, align 4
66  %arrayidx12 = getelementptr inbounds double, double* %d, i32 12
67  %12 = load double, double* %arrayidx12, align 4
68  %arrayidx13 = getelementptr inbounds double, double* %d, i32 13
69  %13 = load double, double* %arrayidx13, align 4
70  %arrayidx14 = getelementptr inbounds double, double* %d, i32 14
71  %14 = load double, double* %arrayidx14, align 4
72  %arrayidx15 = getelementptr inbounds double, double* %d, i32 15
73  %15 = load double, double* %arrayidx15, align 4
74  %arrayidx16 = getelementptr inbounds double, double* %d, i32 16
75  %16 = load double, double* %arrayidx16, align 4
76  %arrayidx17 = getelementptr inbounds double, double* %d, i32 17
77  %17 = load double, double* %arrayidx17, align 4
78  %arrayidx18 = getelementptr inbounds double, double* %d, i32 18
79  %18 = load double, double* %arrayidx18, align 4
80  %arrayidx19 = getelementptr inbounds double, double* %d, i32 19
81  %19 = load double, double* %arrayidx19, align 4
82  %arrayidx20 = getelementptr inbounds double, double* %d, i32 20
83  %20 = load double, double* %arrayidx20, align 4
84  %arrayidx21 = getelementptr inbounds double, double* %d, i32 21
85  %21 = load double, double* %arrayidx21, align 4
86  %arrayidx22 = getelementptr inbounds double, double* %d, i32 22
87  %22 = load double, double* %arrayidx22, align 4
88  %arrayidx23 = getelementptr inbounds double, double* %d, i32 23
89  %23 = load double, double* %arrayidx23, align 4
90  %arrayidx24 = getelementptr inbounds double, double* %d, i32 24
91  %24 = load double, double* %arrayidx24, align 4
92  %arrayidx25 = getelementptr inbounds double, double* %d, i32 25
93  %25 = load double, double* %arrayidx25, align 4
94  %arrayidx26 = getelementptr inbounds double, double* %d, i32 26
95  %26 = load double, double* %arrayidx26, align 4
96  %arrayidx27 = getelementptr inbounds double, double* %d, i32 27
97  %27 = load double, double* %arrayidx27, align 4
98  %arrayidx28 = getelementptr inbounds double, double* %d, i32 28
99  %28 = load double, double* %arrayidx28, align 4
100  %arrayidx29 = getelementptr inbounds double, double* %d, i32 29
101  %29 = load double, double* %arrayidx29, align 4
102  %div = fdiv double %29, %28
103  %div30 = fdiv double %div, %27
104  %div31 = fdiv double %div30, %26
105  %div32 = fdiv double %div31, %25
106  %div33 = fdiv double %div32, %24
107  %div34 = fdiv double %div33, %23
108  %div35 = fdiv double %div34, %22
109  %div36 = fdiv double %div35, %21
110  %div37 = fdiv double %div36, %20
111  %div38 = fdiv double %div37, %19
112  %div39 = fdiv double %div38, %18
113  %div40 = fdiv double %div39, %17
114  %div41 = fdiv double %div40, %16
115  %div42 = fdiv double %div41, %15
116  %div43 = fdiv double %div42, %14
117  %div44 = fdiv double %div43, %13
118  %div45 = fdiv double %div44, %12
119  %div46 = fdiv double %div45, %11
120  %div47 = fdiv double %div46, %10
121  %div48 = fdiv double %div47, %9
122  %div49 = fdiv double %div48, %8
123  %div50 = fdiv double %div49, %7
124  %div51 = fdiv double %div50, %6
125  %div52 = fdiv double %div51, %5
126  %div53 = fdiv double %div52, %4
127  %div54 = fdiv double %div53, %3
128  %div55 = fdiv double %div54, %2
129  %div56 = fdiv double %div55, %1
130  %div57 = fdiv double %div56, %0
131  %div58 = fdiv double %0, %1
132  %div59 = fdiv double %div58, %2
133  %div60 = fdiv double %div59, %3
134  %div61 = fdiv double %div60, %4
135  %div62 = fdiv double %div61, %5
136  %div63 = fdiv double %div62, %6
137  %div64 = fdiv double %div63, %7
138  %div65 = fdiv double %div64, %8
139  %div66 = fdiv double %div65, %9
140  %div67 = fdiv double %div66, %10
141  %div68 = fdiv double %div67, %11
142  %div69 = fdiv double %div68, %12
143  %div70 = fdiv double %div69, %13
144  %div71 = fdiv double %div70, %14
145  %div72 = fdiv double %div71, %15
146  %div73 = fdiv double %div72, %16
147  %div74 = fdiv double %div73, %17
148  %div75 = fdiv double %div74, %18
149  %div76 = fdiv double %div75, %19
150  %div77 = fdiv double %div76, %20
151  %div78 = fdiv double %div77, %21
152  %div79 = fdiv double %div78, %22
153  %div80 = fdiv double %div79, %23
154  %div81 = fdiv double %div80, %24
155  %div82 = fdiv double %div81, %25
156  %div83 = fdiv double %div82, %26
157  %div84 = fdiv double %div83, %27
158  %div85 = fdiv double %div84, %28
159  %div86 = fdiv double %div85, %29
160  %mul = fmul double %div57, %div86
161  %conv = fptosi double %mul to i32
162  %add.ptr = getelementptr inbounds i8, i8* %a, i32 %conv
163  ret i8* %add.ptr
164}
165