1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
| ; RUN: opt -mtriple=thumbv8.1m.main-arm-none-eabi -mattr=+fp-armv8 -hardware-loops %s -S -o - | FileCheck %s --check-prefix=CHECK --check-prefix=CHECK-FP
; RUN: opt -mtriple=thumbv8.1m.main-arm-none-eabi -mattr=+soft-float -hardware-loops %s -S -o - | FileCheck %s --check-prefix=CHECK --check-prefix=CHECK-SOFT
; CHECK-LABEL: test_fptosi
; CHECK-SOFT-NOT: call void @llvm.set.loop.iterations
; CHECK: entry:
; CHECK-FP: [[CMP:%[^ ]+]] = icmp ugt i32 %n, 1
; CHECK-FP: [[COUNT:%[^ ]+]] = select i1 [[CMP]], i32 %n, i32 1
; CHECK: while.body.lr.ph:
; CHECK-FP: call void @llvm.set.loop.iterations.i32(i32 [[COUNT]])
; CHECK-FP-NEXT: br label %while.body
; CHECK-FP: [[REM:%[^ ]+]] = phi i32 [ [[COUNT]], %while.body.lr.ph ], [ [[LOOP_DEC:%[^ ]+]], %if.end4 ]
; CHECK-FP: [[LOOP_DEC]] = call i32 @llvm.loop.decrement.reg.i32.i32.i32(i32 [[REM]], i32 1)
; CHECK-FP: [[CMP:%[^ ]+]] = icmp ne i32 [[LOOP_DEC]], 0
; CHECK-FP: br i1 [[CMP]], label %while.body, label %cleanup.loopexit
define void @test_fptosi(i32 %n, i32** %g, double** %d) {
entry:
%n.off = add i32 %n, -1
%0 = icmp ult i32 %n.off, 500
br i1 %0, label %while.body.lr.ph, label %cleanup
while.body.lr.ph:
%1 = load double*, double** %d, align 4
%2 = load i32*, i32** %g, align 4
br label %while.body
while.body:
%i.012 = phi i32 [ 0, %while.body.lr.ph ], [ %inc, %if.end4 ]
%rem = urem i32 %i.012, 10
%tobool = icmp eq i32 %rem, 0
br i1 %tobool, label %if.end4, label %if.then2
if.then2:
%arrayidx = getelementptr inbounds double, double* %1, i32 %i.012
%3 = load double, double* %arrayidx, align 8
%conv = fptosi double %3 to i32
%arrayidx3 = getelementptr inbounds i32, i32* %2, i32 %i.012
store i32 %conv, i32* %arrayidx3, align 4
br label %if.end4
if.end4:
%inc = add nuw i32 %i.012, 1
%cmp1 = icmp ult i32 %inc, %n
br i1 %cmp1, label %while.body, label %cleanup.loopexit
cleanup.loopexit:
br label %cleanup
cleanup:
ret void
}
; CHECK-LABEL: test_fptoui
; CHECK: entry:
; CHECK-FP: [[CMP:%[^ ]+]] = icmp ugt i32 %n, 1
; CHECK-FP: [[COUNT:%[^ ]+]] = select i1 [[CMP]], i32 %n, i32 1
; CHECK-FP: while.body.lr.ph:
; CHECK-FP: call void @llvm.set.loop.iterations.i32(i32 [[COUNT]])
; CHECK-FP-NEXT: br label %while.body
; CHECK-FP: [[REM:%[^ ]+]] = phi i32 [ [[COUNT]], %while.body.lr.ph ], [ [[LOOP_DEC:%[^ ]+]], %if.end4 ]
; CHECK-FP: [[LOOP_DEC]] = call i32 @llvm.loop.decrement.reg.i32.i32.i32(i32 [[REM]], i32 1)
; CHECK-FP: [[CMP:%[^ ]+]] = icmp ne i32 [[LOOP_DEC]], 0
; CHECK-FP: br i1 [[CMP]], label %while.body, label %cleanup.loopexit
; CHECK-SOFT-NOT: call void @llvm.set.loop.iterations
define void @test_fptoui(i32 %n, i32** %g, double** %d) {
entry:
%n.off = add i32 %n, -1
%0 = icmp ult i32 %n.off, 500
br i1 %0, label %while.body.lr.ph, label %cleanup
while.body.lr.ph:
%1 = load double*, double** %d, align 4
%2 = load i32*, i32** %g, align 4
br label %while.body
while.body:
%i.012 = phi i32 [ 0, %while.body.lr.ph ], [ %inc, %if.end4 ]
%rem = urem i32 %i.012, 10
%tobool = icmp eq i32 %rem, 0
br i1 %tobool, label %if.end4, label %if.then2
if.then2:
%arrayidx = getelementptr inbounds double, double* %1, i32 %i.012
%3 = load double, double* %arrayidx, align 8
%conv = fptoui double %3 to i32
%arrayidx3 = getelementptr inbounds i32, i32* %2, i32 %i.012
store i32 %conv, i32* %arrayidx3, align 4
br label %if.end4
if.end4:
%inc = add nuw i32 %i.012, 1
%cmp1 = icmp ult i32 %inc, %n
br i1 %cmp1, label %while.body, label %cleanup.loopexit
cleanup.loopexit:
br label %cleanup
cleanup:
ret void
}
; CHECK-LABEL: load_store_float
; CHECK: entry:
; CHECK: [[CMP:%[^ ]+]] = icmp ugt i32 %n, 1
; CHECK: [[COUNT:%[^ ]+]] = select i1 [[CMP]], i32 %n, i32 1
; CHECK: while.body.lr.ph:
; CHECK: call void @llvm.set.loop.iterations.i32(i32 [[COUNT]])
; CHECK-NEXT: br label %while.body
; CHECK: [[REM:%[^ ]+]] = phi i32 [ [[COUNT]], %while.body.lr.ph ], [ [[LOOP_DEC:%[^ ]+]], %if.end4 ]
; CHECK: [[LOOP_DEC]] = call i32 @llvm.loop.decrement.reg.i32.i32.i32(i32 [[REM]], i32 1)
; CHECK: [[CMP:%[^ ]+]] = icmp ne i32 [[LOOP_DEC]], 0
; CHECK: br i1 [[CMP]], label %while.body, label %cleanup.loopexit
define void @load_store_float(i32 %n, double** %d, double** %g) {
entry:
%n.off = add i32 %n, -1
%0 = icmp ult i32 %n.off, 500
br i1 %0, label %while.body.lr.ph, label %cleanup
while.body.lr.ph:
%1 = load double*, double** %d, align 4
%2 = load double*, double** %g, align 4
br label %while.body
while.body:
%i.012 = phi i32 [ 0, %while.body.lr.ph ], [ %inc, %if.end4 ]
%rem = urem i32 %i.012, 10
%tobool = icmp eq i32 %rem, 0
br i1 %tobool, label %if.end4, label %if.then2
if.then2:
%arrayidx = getelementptr inbounds double, double* %1, i32 %i.012
%3 = load double, double* %arrayidx, align 8
%arrayidx3 = getelementptr inbounds double, double* %2, i32 %i.012
store double %3, double* %arrayidx3, align 8
br label %if.end4
if.end4:
%inc = add nuw i32 %i.012, 1
%cmp1 = icmp ult i32 %inc, %n
br i1 %cmp1, label %while.body, label %cleanup.loopexit
cleanup.loopexit:
br label %cleanup
cleanup:
ret void
}
; CHECK-LABEL: fp_add
; CHECK-SOFT-NOT: call void @llvm.set.loop.iterations
; CHECK: entry:
; CHECK-FP: [[CMP:%[^ ]+]] = icmp ugt i32 %n, 1
; CHECK-FP: [[COUNT:%[^ ]+]] = select i1 [[CMP]], i32 %n, i32 1
; CHECK: while.body.lr.ph:
; CHECK-FP: call void @llvm.set.loop.iterations.i32(i32 [[COUNT]])
; CHECK: br label %while.body
; CHECK-SOFT-NOT: call i32 @llvm.loop.decrement
; CHECK-FP: [[REM:%[^ ]+]] = phi i32 [ [[COUNT]], %while.body.lr.ph ], [ [[LOOP_DEC:%[^ ]+]], %if.end4 ]
; CHECK-FP: [[LOOP_DEC]] = call i32 @llvm.loop.decrement.reg.i32.i32.i32(i32 [[REM]], i32 1)
; CHECK-FP: [[CMP:%[^ ]+]] = icmp ne i32 [[LOOP_DEC]], 0
; CHECK-FP: br i1 [[CMP]], label %while.body, label %cleanup.loopexit
define void @fp_add(i32 %n, float** %d, float** %g) {
entry:
%n.off = add i32 %n, -1
%0 = icmp ult i32 %n.off, 500
br i1 %0, label %while.body.lr.ph, label %cleanup
while.body.lr.ph:
%1 = load float*, float** %d, align 4
%2 = load float*, float** %g, align 4
br label %while.body
while.body:
%i.012 = phi i32 [ 0, %while.body.lr.ph ], [ %inc, %if.end4 ]
%rem = urem i32 %i.012, 10
%tobool = icmp eq i32 %rem, 0
br i1 %tobool, label %if.end4, label %if.then2
if.then2:
%arrayidx = getelementptr inbounds float, float* %1, i32 %i.012
%3 = load float, float* %arrayidx, align 4
%arrayidx3 = getelementptr inbounds float, float* %2, i32 %i.012
%4 = load float, float* %arrayidx3, align 4
%add = fadd float %3, %4
store float %add, float* %arrayidx3, align 4
br label %if.end4
if.end4:
%inc = add nuw i32 %i.012, 1
%cmp1 = icmp ult i32 %inc, %n
br i1 %cmp1, label %while.body, label %cleanup.loopexit
cleanup.loopexit:
br label %cleanup
cleanup:
ret void
}
|