1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt -S -mtriple=x86_64-- -expand-large-fp-convert < %s | FileCheck %s
3 ; RUN: opt -S -mtriple=x86_64-- -passes=expand-large-fp-convert < %s | FileCheck %s
5 define half @si129tohalf(i129 %a) {
6 ; CHECK-LABEL: @si129tohalf(
7 ; CHECK-NEXT: itofp-entry:
8 ; CHECK-NEXT: [[TMP0:%.*]] = icmp eq i129 [[A:%.*]], 0
9 ; CHECK-NEXT: br i1 [[TMP0]], label [[ITOFP_RETURN:%.*]], label [[ITOFP_IF_END:%.*]]
10 ; CHECK: itofp-if-end:
11 ; CHECK-NEXT: [[TMP1:%.*]] = ashr i129 [[A]], 128
12 ; CHECK-NEXT: [[TMP2:%.*]] = xor i129 [[TMP1]], [[A]]
13 ; CHECK-NEXT: [[TMP3:%.*]] = sub i129 [[TMP2]], [[TMP1]]
14 ; CHECK-NEXT: [[TMP4:%.*]] = call i129 @llvm.ctlz.i129(i129 [[TMP3]], i1 true)
15 ; CHECK-NEXT: [[TMP5:%.*]] = trunc i129 [[TMP4]] to i32
16 ; CHECK-NEXT: [[TMP6:%.*]] = sub i32 129, [[TMP5]]
17 ; CHECK-NEXT: [[TMP7:%.*]] = sub i32 128, [[TMP5]]
18 ; CHECK-NEXT: [[TMP8:%.*]] = icmp sgt i32 [[TMP7]], 24
19 ; CHECK-NEXT: br i1 [[TMP8]], label [[ITOFP_IF_THEN4:%.*]], label [[ITOFP_IF_ELSE:%.*]]
20 ; CHECK: itofp-if-then4:
21 ; CHECK-NEXT: switch i32 [[TMP6]], label [[ITOFP_SW_DEFAULT:%.*]] [
22 ; CHECK-NEXT: i32 25, label [[ITOFP_SW_BB:%.*]]
23 ; CHECK-NEXT: i32 26, label [[ITOFP_SW_EPILOG:%.*]]
26 ; CHECK-NEXT: [[TMP9:%.*]] = shl i129 [[TMP3]], 1
27 ; CHECK-NEXT: br label [[ITOFP_SW_EPILOG]]
28 ; CHECK: itofp-sw-default:
29 ; CHECK-NEXT: [[TMP10:%.*]] = sub i32 103, [[TMP5]]
30 ; CHECK-NEXT: [[TMP11:%.*]] = zext i32 [[TMP10]] to i129
31 ; CHECK-NEXT: [[TMP12:%.*]] = lshr i129 [[TMP3]], [[TMP11]]
32 ; CHECK-NEXT: [[TMP13:%.*]] = add i32 [[TMP5]], 26
33 ; CHECK-NEXT: [[TMP14:%.*]] = zext i32 [[TMP13]] to i129
34 ; CHECK-NEXT: [[TMP15:%.*]] = lshr i129 -1, [[TMP14]]
35 ; CHECK-NEXT: [[TMP16:%.*]] = and i129 [[TMP15]], [[TMP3]]
36 ; CHECK-NEXT: [[TMP17:%.*]] = icmp ne i129 [[TMP16]], 0
37 ; CHECK-NEXT: [[TMP18:%.*]] = zext i1 [[TMP17]] to i129
38 ; CHECK-NEXT: [[TMP19:%.*]] = or i129 [[TMP12]], [[TMP18]]
39 ; CHECK-NEXT: br label [[ITOFP_SW_EPILOG]]
40 ; CHECK: itofp-sw-epilog:
41 ; CHECK-NEXT: [[TMP20:%.*]] = phi i129 [ [[TMP19]], [[ITOFP_SW_DEFAULT]] ], [ [[TMP3]], [[ITOFP_IF_THEN4]] ], [ [[TMP9]], [[ITOFP_SW_BB]] ]
42 ; CHECK-NEXT: [[TMP21:%.*]] = trunc i129 [[TMP20]] to i32
43 ; CHECK-NEXT: [[TMP22:%.*]] = lshr i32 [[TMP21]], 2
44 ; CHECK-NEXT: [[TMP23:%.*]] = and i32 [[TMP22]], 1
45 ; CHECK-NEXT: [[TMP24:%.*]] = zext i32 [[TMP23]] to i129
46 ; CHECK-NEXT: [[TMP25:%.*]] = or i129 [[TMP20]], [[TMP24]]
47 ; CHECK-NEXT: [[TMP26:%.*]] = add i129 [[TMP25]], 1
48 ; CHECK-NEXT: [[TMP27:%.*]] = ashr i129 [[TMP26]], 2
49 ; CHECK-NEXT: [[A3:%.*]] = and i129 [[TMP26]], 67108864
50 ; CHECK-NEXT: [[TMP28:%.*]] = icmp eq i129 [[A3]], 0
51 ; CHECK-NEXT: [[TMP29:%.*]] = trunc i129 [[TMP27]] to i32
52 ; CHECK-NEXT: [[TMP30:%.*]] = lshr i129 [[TMP27]], 32
53 ; CHECK-NEXT: [[TMP31:%.*]] = trunc i129 [[TMP30]] to i32
54 ; CHECK-NEXT: br i1 [[TMP28]], label [[ITOFP_IF_END26:%.*]], label [[ITOFP_IF_THEN20:%.*]]
55 ; CHECK: itofp-if-then20:
56 ; CHECK-NEXT: [[TMP32:%.*]] = ashr i129 [[TMP26]], 3
57 ; CHECK-NEXT: [[TMP33:%.*]] = trunc i129 [[TMP32]] to i32
58 ; CHECK-NEXT: [[TMP34:%.*]] = lshr i129 [[TMP32]], 32
59 ; CHECK-NEXT: [[TMP35:%.*]] = trunc i129 [[TMP34]] to i32
60 ; CHECK-NEXT: br label [[ITOFP_IF_END26]]
61 ; CHECK: itofp-if-else:
62 ; CHECK-NEXT: [[TMP36:%.*]] = add i32 [[TMP5]], -105
63 ; CHECK-NEXT: [[TMP37:%.*]] = zext i32 [[TMP36]] to i129
64 ; CHECK-NEXT: [[TMP38:%.*]] = shl i129 [[TMP3]], [[TMP37]]
65 ; CHECK-NEXT: [[TMP39:%.*]] = trunc i129 [[TMP38]] to i32
66 ; CHECK-NEXT: [[TMP40:%.*]] = lshr i129 [[TMP38]], 32
67 ; CHECK-NEXT: [[TMP41:%.*]] = trunc i129 [[TMP40]] to i32
68 ; CHECK-NEXT: br label [[ITOFP_IF_END26]]
69 ; CHECK: itofp-if-end26:
70 ; CHECK-NEXT: [[TMP42:%.*]] = phi i32 [ [[TMP33]], [[ITOFP_IF_THEN20]] ], [ [[TMP29]], [[ITOFP_SW_EPILOG]] ], [ [[TMP39]], [[ITOFP_IF_ELSE]] ]
71 ; CHECK-NEXT: [[TMP43:%.*]] = phi i32 [ [[TMP6]], [[ITOFP_IF_THEN20]] ], [ [[TMP7]], [[ITOFP_SW_EPILOG]] ], [ [[TMP7]], [[ITOFP_IF_ELSE]] ]
72 ; CHECK-NEXT: [[TMP44:%.*]] = trunc i129 [[TMP1]] to i32
73 ; CHECK-NEXT: [[TMP45:%.*]] = and i32 [[TMP44]], -2147483648
74 ; CHECK-NEXT: [[TMP46:%.*]] = shl i32 [[TMP43]], 23
75 ; CHECK-NEXT: [[TMP47:%.*]] = add i32 [[TMP46]], 1065353216
76 ; CHECK-NEXT: [[TMP48:%.*]] = and i32 [[TMP42]], 8388607
77 ; CHECK-NEXT: [[TMP49:%.*]] = or i32 [[TMP48]], [[TMP45]]
78 ; CHECK-NEXT: [[TMP50:%.*]] = or i32 [[TMP49]], [[TMP47]]
79 ; CHECK-NEXT: [[TMP51:%.*]] = bitcast i32 [[TMP50]] to float
80 ; CHECK-NEXT: [[TMP52:%.*]] = fptrunc float [[TMP51]] to half
81 ; CHECK-NEXT: br label [[ITOFP_RETURN]]
82 ; CHECK: itofp-return:
83 ; CHECK-NEXT: [[TMP53:%.*]] = phi half [ [[TMP52]], [[ITOFP_IF_END26]] ], [ 0xH0000, [[ITOFP_ENTRY:%.*]] ]
84 ; CHECK-NEXT: ret half [[TMP53]]
86 %conv = sitofp i129 %a to half
90 define float @si129tofloat(i129 %a) {
91 ; CHECK-LABEL: @si129tofloat(
92 ; CHECK-NEXT: itofp-entry:
93 ; CHECK-NEXT: [[TMP0:%.*]] = icmp eq i129 [[A:%.*]], 0
94 ; CHECK-NEXT: br i1 [[TMP0]], label [[ITOFP_RETURN:%.*]], label [[ITOFP_IF_END:%.*]]
95 ; CHECK: itofp-if-end:
96 ; CHECK-NEXT: [[TMP1:%.*]] = ashr i129 [[A]], 128
97 ; CHECK-NEXT: [[TMP2:%.*]] = xor i129 [[TMP1]], [[A]]
98 ; CHECK-NEXT: [[TMP3:%.*]] = sub i129 [[TMP2]], [[TMP1]]
99 ; CHECK-NEXT: [[TMP4:%.*]] = call i129 @llvm.ctlz.i129(i129 [[TMP3]], i1 true)
100 ; CHECK-NEXT: [[TMP5:%.*]] = trunc i129 [[TMP4]] to i32
101 ; CHECK-NEXT: [[TMP6:%.*]] = sub i32 129, [[TMP5]]
102 ; CHECK-NEXT: [[TMP7:%.*]] = sub i32 128, [[TMP5]]
103 ; CHECK-NEXT: [[TMP8:%.*]] = icmp sgt i32 [[TMP7]], 24
104 ; CHECK-NEXT: br i1 [[TMP8]], label [[ITOFP_IF_THEN4:%.*]], label [[ITOFP_IF_ELSE:%.*]]
105 ; CHECK: itofp-if-then4:
106 ; CHECK-NEXT: switch i32 [[TMP6]], label [[ITOFP_SW_DEFAULT:%.*]] [
107 ; CHECK-NEXT: i32 25, label [[ITOFP_SW_BB:%.*]]
108 ; CHECK-NEXT: i32 26, label [[ITOFP_SW_EPILOG:%.*]]
110 ; CHECK: itofp-sw-bb:
111 ; CHECK-NEXT: [[TMP9:%.*]] = shl i129 [[TMP3]], 1
112 ; CHECK-NEXT: br label [[ITOFP_SW_EPILOG]]
113 ; CHECK: itofp-sw-default:
114 ; CHECK-NEXT: [[TMP10:%.*]] = sub i32 103, [[TMP5]]
115 ; CHECK-NEXT: [[TMP11:%.*]] = zext i32 [[TMP10]] to i129
116 ; CHECK-NEXT: [[TMP12:%.*]] = lshr i129 [[TMP3]], [[TMP11]]
117 ; CHECK-NEXT: [[TMP13:%.*]] = add i32 [[TMP5]], 26
118 ; CHECK-NEXT: [[TMP14:%.*]] = zext i32 [[TMP13]] to i129
119 ; CHECK-NEXT: [[TMP15:%.*]] = lshr i129 -1, [[TMP14]]
120 ; CHECK-NEXT: [[TMP16:%.*]] = and i129 [[TMP15]], [[TMP3]]
121 ; CHECK-NEXT: [[TMP17:%.*]] = icmp ne i129 [[TMP16]], 0
122 ; CHECK-NEXT: [[TMP18:%.*]] = zext i1 [[TMP17]] to i129
123 ; CHECK-NEXT: [[TMP19:%.*]] = or i129 [[TMP12]], [[TMP18]]
124 ; CHECK-NEXT: br label [[ITOFP_SW_EPILOG]]
125 ; CHECK: itofp-sw-epilog:
126 ; CHECK-NEXT: [[TMP20:%.*]] = phi i129 [ [[TMP19]], [[ITOFP_SW_DEFAULT]] ], [ [[TMP3]], [[ITOFP_IF_THEN4]] ], [ [[TMP9]], [[ITOFP_SW_BB]] ]
127 ; CHECK-NEXT: [[TMP21:%.*]] = trunc i129 [[TMP20]] to i32
128 ; CHECK-NEXT: [[TMP22:%.*]] = lshr i32 [[TMP21]], 2
129 ; CHECK-NEXT: [[TMP23:%.*]] = and i32 [[TMP22]], 1
130 ; CHECK-NEXT: [[TMP24:%.*]] = zext i32 [[TMP23]] to i129
131 ; CHECK-NEXT: [[TMP25:%.*]] = or i129 [[TMP20]], [[TMP24]]
132 ; CHECK-NEXT: [[TMP26:%.*]] = add i129 [[TMP25]], 1
133 ; CHECK-NEXT: [[TMP27:%.*]] = ashr i129 [[TMP26]], 2
134 ; CHECK-NEXT: [[A3:%.*]] = and i129 [[TMP26]], 67108864
135 ; CHECK-NEXT: [[TMP28:%.*]] = icmp eq i129 [[A3]], 0
136 ; CHECK-NEXT: [[TMP29:%.*]] = trunc i129 [[TMP27]] to i32
137 ; CHECK-NEXT: [[TMP30:%.*]] = lshr i129 [[TMP27]], 32
138 ; CHECK-NEXT: [[TMP31:%.*]] = trunc i129 [[TMP30]] to i32
139 ; CHECK-NEXT: br i1 [[TMP28]], label [[ITOFP_IF_END26:%.*]], label [[ITOFP_IF_THEN20:%.*]]
140 ; CHECK: itofp-if-then20:
141 ; CHECK-NEXT: [[TMP32:%.*]] = ashr i129 [[TMP26]], 3
142 ; CHECK-NEXT: [[TMP33:%.*]] = trunc i129 [[TMP32]] to i32
143 ; CHECK-NEXT: [[TMP34:%.*]] = lshr i129 [[TMP32]], 32
144 ; CHECK-NEXT: [[TMP35:%.*]] = trunc i129 [[TMP34]] to i32
145 ; CHECK-NEXT: br label [[ITOFP_IF_END26]]
146 ; CHECK: itofp-if-else:
147 ; CHECK-NEXT: [[TMP36:%.*]] = add i32 [[TMP5]], -105
148 ; CHECK-NEXT: [[TMP37:%.*]] = zext i32 [[TMP36]] to i129
149 ; CHECK-NEXT: [[TMP38:%.*]] = shl i129 [[TMP3]], [[TMP37]]
150 ; CHECK-NEXT: [[TMP39:%.*]] = trunc i129 [[TMP38]] to i32
151 ; CHECK-NEXT: [[TMP40:%.*]] = lshr i129 [[TMP38]], 32
152 ; CHECK-NEXT: [[TMP41:%.*]] = trunc i129 [[TMP40]] to i32
153 ; CHECK-NEXT: br label [[ITOFP_IF_END26]]
154 ; CHECK: itofp-if-end26:
155 ; CHECK-NEXT: [[TMP42:%.*]] = phi i32 [ [[TMP33]], [[ITOFP_IF_THEN20]] ], [ [[TMP29]], [[ITOFP_SW_EPILOG]] ], [ [[TMP39]], [[ITOFP_IF_ELSE]] ]
156 ; CHECK-NEXT: [[TMP43:%.*]] = phi i32 [ [[TMP6]], [[ITOFP_IF_THEN20]] ], [ [[TMP7]], [[ITOFP_SW_EPILOG]] ], [ [[TMP7]], [[ITOFP_IF_ELSE]] ]
157 ; CHECK-NEXT: [[TMP44:%.*]] = trunc i129 [[TMP1]] to i32
158 ; CHECK-NEXT: [[TMP45:%.*]] = and i32 [[TMP44]], -2147483648
159 ; CHECK-NEXT: [[TMP46:%.*]] = shl i32 [[TMP43]], 23
160 ; CHECK-NEXT: [[TMP47:%.*]] = add i32 [[TMP46]], 1065353216
161 ; CHECK-NEXT: [[TMP48:%.*]] = and i32 [[TMP42]], 8388607
162 ; CHECK-NEXT: [[TMP49:%.*]] = or i32 [[TMP48]], [[TMP45]]
163 ; CHECK-NEXT: [[TMP50:%.*]] = or i32 [[TMP49]], [[TMP47]]
164 ; CHECK-NEXT: [[TMP51:%.*]] = bitcast i32 [[TMP50]] to float
165 ; CHECK-NEXT: br label [[ITOFP_RETURN]]
166 ; CHECK: itofp-return:
167 ; CHECK-NEXT: [[TMP52:%.*]] = phi float [ [[TMP51]], [[ITOFP_IF_END26]] ], [ 0.000000e+00, [[ITOFP_ENTRY:%.*]] ]
168 ; CHECK-NEXT: ret float [[TMP52]]
170 %conv = sitofp i129 %a to float
174 define double @si129todouble(i129 %a) {
175 ; CHECK-LABEL: @si129todouble(
176 ; CHECK-NEXT: itofp-entry:
177 ; CHECK-NEXT: [[TMP0:%.*]] = icmp eq i129 [[A:%.*]], 0
178 ; CHECK-NEXT: br i1 [[TMP0]], label [[ITOFP_RETURN:%.*]], label [[ITOFP_IF_END:%.*]]
179 ; CHECK: itofp-if-end:
180 ; CHECK-NEXT: [[TMP1:%.*]] = ashr i129 [[A]], 128
181 ; CHECK-NEXT: [[TMP2:%.*]] = xor i129 [[TMP1]], [[A]]
182 ; CHECK-NEXT: [[TMP3:%.*]] = sub i129 [[TMP2]], [[TMP1]]
183 ; CHECK-NEXT: [[TMP4:%.*]] = call i129 @llvm.ctlz.i129(i129 [[TMP3]], i1 true)
184 ; CHECK-NEXT: [[TMP5:%.*]] = trunc i129 [[TMP4]] to i32
185 ; CHECK-NEXT: [[TMP6:%.*]] = sub i32 129, [[TMP5]]
186 ; CHECK-NEXT: [[TMP7:%.*]] = sub i32 128, [[TMP5]]
187 ; CHECK-NEXT: [[TMP8:%.*]] = icmp sgt i32 [[TMP7]], 53
188 ; CHECK-NEXT: br i1 [[TMP8]], label [[ITOFP_IF_THEN4:%.*]], label [[ITOFP_IF_ELSE:%.*]]
189 ; CHECK: itofp-if-then4:
190 ; CHECK-NEXT: switch i32 [[TMP6]], label [[ITOFP_SW_DEFAULT:%.*]] [
191 ; CHECK-NEXT: i32 54, label [[ITOFP_SW_BB:%.*]]
192 ; CHECK-NEXT: i32 55, label [[ITOFP_SW_EPILOG:%.*]]
194 ; CHECK: itofp-sw-bb:
195 ; CHECK-NEXT: [[TMP9:%.*]] = shl i129 [[TMP3]], 1
196 ; CHECK-NEXT: br label [[ITOFP_SW_EPILOG]]
197 ; CHECK: itofp-sw-default:
198 ; CHECK-NEXT: [[TMP10:%.*]] = sub i32 74, [[TMP5]]
199 ; CHECK-NEXT: [[TMP11:%.*]] = zext i32 [[TMP10]] to i129
200 ; CHECK-NEXT: [[TMP12:%.*]] = lshr i129 [[TMP3]], [[TMP11]]
201 ; CHECK-NEXT: [[TMP13:%.*]] = add i32 [[TMP5]], 55
202 ; CHECK-NEXT: [[TMP14:%.*]] = zext i32 [[TMP13]] to i129
203 ; CHECK-NEXT: [[TMP15:%.*]] = lshr i129 -1, [[TMP14]]
204 ; CHECK-NEXT: [[TMP16:%.*]] = and i129 [[TMP15]], [[TMP3]]
205 ; CHECK-NEXT: [[TMP17:%.*]] = icmp ne i129 [[TMP16]], 0
206 ; CHECK-NEXT: [[TMP18:%.*]] = zext i1 [[TMP17]] to i129
207 ; CHECK-NEXT: [[TMP19:%.*]] = or i129 [[TMP12]], [[TMP18]]
208 ; CHECK-NEXT: br label [[ITOFP_SW_EPILOG]]
209 ; CHECK: itofp-sw-epilog:
210 ; CHECK-NEXT: [[TMP20:%.*]] = phi i129 [ [[TMP19]], [[ITOFP_SW_DEFAULT]] ], [ [[TMP3]], [[ITOFP_IF_THEN4]] ], [ [[TMP9]], [[ITOFP_SW_BB]] ]
211 ; CHECK-NEXT: [[TMP21:%.*]] = trunc i129 [[TMP20]] to i32
212 ; CHECK-NEXT: [[TMP22:%.*]] = lshr i32 [[TMP21]], 2
213 ; CHECK-NEXT: [[TMP23:%.*]] = and i32 [[TMP22]], 1
214 ; CHECK-NEXT: [[TMP24:%.*]] = zext i32 [[TMP23]] to i129
215 ; CHECK-NEXT: [[TMP25:%.*]] = or i129 [[TMP20]], [[TMP24]]
216 ; CHECK-NEXT: [[TMP26:%.*]] = add i129 [[TMP25]], 1
217 ; CHECK-NEXT: [[TMP27:%.*]] = ashr i129 [[TMP26]], 2
218 ; CHECK-NEXT: [[A3:%.*]] = and i129 [[TMP26]], 36028797018963968
219 ; CHECK-NEXT: [[TMP28:%.*]] = icmp eq i129 [[A3]], 0
220 ; CHECK-NEXT: [[TMP29:%.*]] = trunc i129 [[TMP27]] to i64
221 ; CHECK-NEXT: [[TMP30:%.*]] = lshr i129 [[TMP27]], 32
222 ; CHECK-NEXT: [[TMP31:%.*]] = trunc i129 [[TMP30]] to i32
223 ; CHECK-NEXT: br i1 [[TMP28]], label [[ITOFP_IF_END26:%.*]], label [[ITOFP_IF_THEN20:%.*]]
224 ; CHECK: itofp-if-then20:
225 ; CHECK-NEXT: [[TMP32:%.*]] = ashr i129 [[TMP26]], 3
226 ; CHECK-NEXT: [[TMP33:%.*]] = trunc i129 [[TMP32]] to i64
227 ; CHECK-NEXT: [[TMP34:%.*]] = lshr i129 [[TMP32]], 32
228 ; CHECK-NEXT: [[TMP35:%.*]] = trunc i129 [[TMP34]] to i32
229 ; CHECK-NEXT: br label [[ITOFP_IF_END26]]
230 ; CHECK: itofp-if-else:
231 ; CHECK-NEXT: [[TMP36:%.*]] = add i32 [[TMP5]], -76
232 ; CHECK-NEXT: [[TMP37:%.*]] = zext i32 [[TMP36]] to i129
233 ; CHECK-NEXT: [[TMP38:%.*]] = shl i129 [[TMP3]], [[TMP37]]
234 ; CHECK-NEXT: [[TMP39:%.*]] = trunc i129 [[TMP38]] to i64
235 ; CHECK-NEXT: [[TMP40:%.*]] = lshr i129 [[TMP38]], 32
236 ; CHECK-NEXT: [[TMP41:%.*]] = trunc i129 [[TMP40]] to i32
237 ; CHECK-NEXT: br label [[ITOFP_IF_END26]]
238 ; CHECK: itofp-if-end26:
239 ; CHECK-NEXT: [[TMP42:%.*]] = phi i64 [ [[TMP33]], [[ITOFP_IF_THEN20]] ], [ [[TMP29]], [[ITOFP_SW_EPILOG]] ], [ [[TMP39]], [[ITOFP_IF_ELSE]] ]
240 ; CHECK-NEXT: [[TMP43:%.*]] = phi i32 [ [[TMP35]], [[ITOFP_IF_THEN20]] ], [ [[TMP31]], [[ITOFP_SW_EPILOG]] ], [ [[TMP41]], [[ITOFP_IF_ELSE]] ]
241 ; CHECK-NEXT: [[TMP44:%.*]] = phi i32 [ [[TMP6]], [[ITOFP_IF_THEN20]] ], [ [[TMP7]], [[ITOFP_SW_EPILOG]] ], [ [[TMP7]], [[ITOFP_IF_ELSE]] ]
242 ; CHECK-NEXT: [[TMP45:%.*]] = trunc i129 [[TMP1]] to i32
243 ; CHECK-NEXT: [[TMP46:%.*]] = and i32 [[TMP45]], -2147483648
244 ; CHECK-NEXT: [[TMP47:%.*]] = shl i32 [[TMP44]], 20
245 ; CHECK-NEXT: [[TMP48:%.*]] = add i32 [[TMP47]], 1072693248
246 ; CHECK-NEXT: [[TMP49:%.*]] = and i32 [[TMP43]], 1048575
247 ; CHECK-NEXT: [[TMP50:%.*]] = or i32 [[TMP49]], [[TMP46]]
248 ; CHECK-NEXT: [[TMP51:%.*]] = or i32 [[TMP50]], [[TMP48]]
249 ; CHECK-NEXT: [[TMP52:%.*]] = zext i32 [[TMP51]] to i64
250 ; CHECK-NEXT: [[TMP53:%.*]] = shl i64 [[TMP52]], 32
251 ; CHECK-NEXT: [[TMP54:%.*]] = and i64 [[TMP42]], 4294967295
252 ; CHECK-NEXT: [[TMP55:%.*]] = or i64 [[TMP53]], [[TMP54]]
253 ; CHECK-NEXT: [[TMP56:%.*]] = bitcast i64 [[TMP55]] to double
254 ; CHECK-NEXT: br label [[ITOFP_RETURN]]
255 ; CHECK: itofp-return:
256 ; CHECK-NEXT: [[TMP57:%.*]] = phi double [ [[TMP56]], [[ITOFP_IF_END26]] ], [ 0.000000e+00, [[ITOFP_ENTRY:%.*]] ]
257 ; CHECK-NEXT: ret double [[TMP57]]
259 %conv = sitofp i129 %a to double
263 define x86_fp80 @si129tox86_fp80(i129 %a) {
264 ; CHECK-LABEL: @si129tox86_fp80(
265 ; CHECK-NEXT: itofp-entry:
266 ; CHECK-NEXT: [[TMP0:%.*]] = icmp eq i129 [[A:%.*]], 0
267 ; CHECK-NEXT: br i1 [[TMP0]], label [[ITOFP_RETURN:%.*]], label [[ITOFP_IF_END:%.*]]
268 ; CHECK: itofp-if-end:
269 ; CHECK-NEXT: [[TMP1:%.*]] = ashr i129 [[A]], 128
270 ; CHECK-NEXT: [[TMP2:%.*]] = xor i129 [[TMP1]], [[A]]
271 ; CHECK-NEXT: [[TMP3:%.*]] = sub i129 [[TMP2]], [[TMP1]]
272 ; CHECK-NEXT: [[TMP4:%.*]] = call i129 @llvm.ctlz.i129(i129 [[TMP3]], i1 true)
273 ; CHECK-NEXT: [[TMP5:%.*]] = trunc i129 [[TMP4]] to i32
274 ; CHECK-NEXT: [[TMP6:%.*]] = sub i129 129, [[TMP4]]
275 ; CHECK-NEXT: [[TMP7:%.*]] = sub i129 128, [[TMP4]]
276 ; CHECK-NEXT: [[TMP8:%.*]] = icmp sgt i129 [[TMP7]], 113
277 ; CHECK-NEXT: br i1 [[TMP8]], label [[ITOFP_IF_THEN4:%.*]], label [[ITOFP_IF_ELSE:%.*]]
278 ; CHECK: itofp-if-then4:
279 ; CHECK-NEXT: switch i129 [[TMP6]], label [[ITOFP_SW_DEFAULT:%.*]] [
280 ; CHECK-NEXT: i129 114, label [[ITOFP_SW_BB:%.*]]
281 ; CHECK-NEXT: i129 115, label [[ITOFP_SW_EPILOG:%.*]]
283 ; CHECK: itofp-sw-bb:
284 ; CHECK-NEXT: [[TMP9:%.*]] = shl i129 [[TMP3]], 1
285 ; CHECK-NEXT: br label [[ITOFP_SW_EPILOG]]
286 ; CHECK: itofp-sw-default:
287 ; CHECK-NEXT: [[TMP10:%.*]] = sub i129 14, [[TMP4]]
288 ; CHECK-NEXT: [[TMP11:%.*]] = lshr i129 [[TMP3]], [[TMP10]]
289 ; CHECK-NEXT: [[TMP12:%.*]] = add i129 [[TMP4]], 115
290 ; CHECK-NEXT: [[TMP13:%.*]] = lshr i129 -1, [[TMP12]]
291 ; CHECK-NEXT: [[TMP14:%.*]] = and i129 [[TMP13]], [[TMP3]]
292 ; CHECK-NEXT: [[TMP15:%.*]] = icmp ne i129 [[TMP14]], 0
293 ; CHECK-NEXT: [[TMP16:%.*]] = zext i1 [[TMP15]] to i129
294 ; CHECK-NEXT: [[TMP17:%.*]] = or i129 [[TMP11]], [[TMP16]]
295 ; CHECK-NEXT: br label [[ITOFP_SW_EPILOG]]
296 ; CHECK: itofp-sw-epilog:
297 ; CHECK-NEXT: [[TMP18:%.*]] = phi i129 [ [[TMP17]], [[ITOFP_SW_DEFAULT]] ], [ [[TMP3]], [[ITOFP_IF_THEN4]] ], [ [[TMP9]], [[ITOFP_SW_BB]] ]
298 ; CHECK-NEXT: [[TMP19:%.*]] = trunc i129 [[TMP18]] to i32
299 ; CHECK-NEXT: [[TMP20:%.*]] = lshr i32 [[TMP19]], 2
300 ; CHECK-NEXT: [[TMP21:%.*]] = and i32 [[TMP20]], 1
301 ; CHECK-NEXT: [[TMP22:%.*]] = zext i32 [[TMP21]] to i129
302 ; CHECK-NEXT: [[TMP23:%.*]] = or i129 [[TMP18]], [[TMP22]]
303 ; CHECK-NEXT: [[TMP24:%.*]] = add i129 [[TMP23]], 1
304 ; CHECK-NEXT: [[TMP25:%.*]] = ashr i129 [[TMP24]], 2
305 ; CHECK-NEXT: [[A3:%.*]] = and i129 [[TMP24]], 41538374868278621028243970633760768
306 ; CHECK-NEXT: [[TMP26:%.*]] = icmp eq i129 [[A3]], 0
307 ; CHECK-NEXT: [[TMP27:%.*]] = trunc i129 [[TMP25]] to i128
308 ; CHECK-NEXT: [[TMP28:%.*]] = lshr i129 [[TMP25]], 32
309 ; CHECK-NEXT: [[TMP29:%.*]] = trunc i129 [[TMP7]] to i64
310 ; CHECK-NEXT: br i1 [[TMP26]], label [[ITOFP_IF_END26:%.*]], label [[ITOFP_IF_THEN20:%.*]]
311 ; CHECK: itofp-if-then20:
312 ; CHECK-NEXT: [[TMP30:%.*]] = ashr i129 [[TMP24]], 3
313 ; CHECK-NEXT: [[TMP31:%.*]] = trunc i129 [[TMP30]] to i128
314 ; CHECK-NEXT: [[TMP32:%.*]] = lshr i129 [[TMP30]], 32
315 ; CHECK-NEXT: [[TMP33:%.*]] = trunc i129 [[TMP6]] to i64
316 ; CHECK-NEXT: br label [[ITOFP_IF_END26]]
317 ; CHECK: itofp-if-else:
318 ; CHECK-NEXT: [[TMP34:%.*]] = add i129 [[TMP4]], 4294967280
319 ; CHECK-NEXT: [[TMP35:%.*]] = shl i129 [[TMP3]], [[TMP34]]
320 ; CHECK-NEXT: [[TMP36:%.*]] = trunc i129 [[TMP35]] to i128
321 ; CHECK-NEXT: [[TMP37:%.*]] = lshr i129 [[TMP35]], 32
322 ; CHECK-NEXT: [[TMP38:%.*]] = trunc i129 [[TMP7]] to i64
323 ; CHECK-NEXT: br label [[ITOFP_IF_END26]]
324 ; CHECK: itofp-if-end26:
325 ; CHECK-NEXT: [[TMP39:%.*]] = phi i128 [ [[TMP31]], [[ITOFP_IF_THEN20]] ], [ [[TMP27]], [[ITOFP_SW_EPILOG]] ], [ [[TMP36]], [[ITOFP_IF_ELSE]] ]
326 ; CHECK-NEXT: [[TMP40:%.*]] = phi i64 [ [[TMP33]], [[ITOFP_IF_THEN20]] ], [ [[TMP29]], [[ITOFP_SW_EPILOG]] ], [ [[TMP38]], [[ITOFP_IF_ELSE]] ]
327 ; CHECK-NEXT: [[AND29:%.*]] = and i129 [[TMP1]], 9223372036854775808
328 ; CHECK-NEXT: [[TMP41:%.*]] = shl i64 [[TMP40]], 48
329 ; CHECK-NEXT: [[TMP42:%.*]] = add i64 [[TMP41]], 4611404543450677248
330 ; CHECK-NEXT: [[TMP43:%.*]] = zext i64 [[TMP42]] to i128
331 ; CHECK-NEXT: [[TMP44:%.*]] = trunc i129 [[AND29]] to i128
332 ; CHECK-NEXT: [[TMP45:%.*]] = or i128 [[TMP44]], [[TMP43]]
333 ; CHECK-NEXT: [[TMP46:%.*]] = shl i128 [[TMP45]], 64
334 ; CHECK-NEXT: [[TMP47:%.*]] = and i128 [[TMP39]], 5192296858534827628530496329220095
335 ; CHECK-NEXT: [[TMP48:%.*]] = or i128 [[TMP46]], [[TMP47]]
336 ; CHECK-NEXT: [[TMP49:%.*]] = bitcast i128 [[TMP48]] to fp128
337 ; CHECK-NEXT: [[TMP50:%.*]] = fptrunc fp128 [[TMP49]] to x86_fp80
338 ; CHECK-NEXT: br label [[ITOFP_RETURN]]
339 ; CHECK: itofp-return:
340 ; CHECK-NEXT: [[TMP51:%.*]] = phi x86_fp80 [ [[TMP50]], [[ITOFP_IF_END26]] ], [ 0xK00000000000000000000, [[ITOFP_ENTRY:%.*]] ]
341 ; CHECK-NEXT: ret x86_fp80 [[TMP51]]
343 %conv = sitofp i129 %a to x86_fp80
347 define fp128 @si129tofp128(i129 %a) {
348 ; CHECK-LABEL: @si129tofp128(
349 ; CHECK-NEXT: itofp-entry:
350 ; CHECK-NEXT: [[TMP0:%.*]] = icmp eq i129 [[A:%.*]], 0
351 ; CHECK-NEXT: br i1 [[TMP0]], label [[ITOFP_RETURN:%.*]], label [[ITOFP_IF_END:%.*]]
352 ; CHECK: itofp-if-end:
353 ; CHECK-NEXT: [[TMP1:%.*]] = ashr i129 [[A]], 128
354 ; CHECK-NEXT: [[TMP2:%.*]] = xor i129 [[TMP1]], [[A]]
355 ; CHECK-NEXT: [[TMP3:%.*]] = sub i129 [[TMP2]], [[TMP1]]
356 ; CHECK-NEXT: [[TMP4:%.*]] = call i129 @llvm.ctlz.i129(i129 [[TMP3]], i1 true)
357 ; CHECK-NEXT: [[TMP5:%.*]] = trunc i129 [[TMP4]] to i32
358 ; CHECK-NEXT: [[TMP6:%.*]] = sub i129 129, [[TMP4]]
359 ; CHECK-NEXT: [[TMP7:%.*]] = sub i129 128, [[TMP4]]
360 ; CHECK-NEXT: [[TMP8:%.*]] = icmp sgt i129 [[TMP7]], 113
361 ; CHECK-NEXT: br i1 [[TMP8]], label [[ITOFP_IF_THEN4:%.*]], label [[ITOFP_IF_ELSE:%.*]]
362 ; CHECK: itofp-if-then4:
363 ; CHECK-NEXT: switch i129 [[TMP6]], label [[ITOFP_SW_DEFAULT:%.*]] [
364 ; CHECK-NEXT: i129 114, label [[ITOFP_SW_BB:%.*]]
365 ; CHECK-NEXT: i129 115, label [[ITOFP_SW_EPILOG:%.*]]
367 ; CHECK: itofp-sw-bb:
368 ; CHECK-NEXT: [[TMP9:%.*]] = shl i129 [[TMP3]], 1
369 ; CHECK-NEXT: br label [[ITOFP_SW_EPILOG]]
370 ; CHECK: itofp-sw-default:
371 ; CHECK-NEXT: [[TMP10:%.*]] = sub i129 14, [[TMP4]]
372 ; CHECK-NEXT: [[TMP11:%.*]] = lshr i129 [[TMP3]], [[TMP10]]
373 ; CHECK-NEXT: [[TMP12:%.*]] = add i129 [[TMP4]], 115
374 ; CHECK-NEXT: [[TMP13:%.*]] = lshr i129 -1, [[TMP12]]
375 ; CHECK-NEXT: [[TMP14:%.*]] = and i129 [[TMP13]], [[TMP3]]
376 ; CHECK-NEXT: [[TMP15:%.*]] = icmp ne i129 [[TMP14]], 0
377 ; CHECK-NEXT: [[TMP16:%.*]] = zext i1 [[TMP15]] to i129
378 ; CHECK-NEXT: [[TMP17:%.*]] = or i129 [[TMP11]], [[TMP16]]
379 ; CHECK-NEXT: br label [[ITOFP_SW_EPILOG]]
380 ; CHECK: itofp-sw-epilog:
381 ; CHECK-NEXT: [[TMP18:%.*]] = phi i129 [ [[TMP17]], [[ITOFP_SW_DEFAULT]] ], [ [[TMP3]], [[ITOFP_IF_THEN4]] ], [ [[TMP9]], [[ITOFP_SW_BB]] ]
382 ; CHECK-NEXT: [[TMP19:%.*]] = trunc i129 [[TMP18]] to i32
383 ; CHECK-NEXT: [[TMP20:%.*]] = lshr i32 [[TMP19]], 2
384 ; CHECK-NEXT: [[TMP21:%.*]] = and i32 [[TMP20]], 1
385 ; CHECK-NEXT: [[TMP22:%.*]] = zext i32 [[TMP21]] to i129
386 ; CHECK-NEXT: [[TMP23:%.*]] = or i129 [[TMP18]], [[TMP22]]
387 ; CHECK-NEXT: [[TMP24:%.*]] = add i129 [[TMP23]], 1
388 ; CHECK-NEXT: [[TMP25:%.*]] = ashr i129 [[TMP24]], 2
389 ; CHECK-NEXT: [[A3:%.*]] = and i129 [[TMP24]], 41538374868278621028243970633760768
390 ; CHECK-NEXT: [[TMP26:%.*]] = icmp eq i129 [[A3]], 0
391 ; CHECK-NEXT: [[TMP27:%.*]] = trunc i129 [[TMP25]] to i128
392 ; CHECK-NEXT: [[TMP28:%.*]] = lshr i129 [[TMP25]], 32
393 ; CHECK-NEXT: [[TMP29:%.*]] = trunc i129 [[TMP7]] to i64
394 ; CHECK-NEXT: br i1 [[TMP26]], label [[ITOFP_IF_END26:%.*]], label [[ITOFP_IF_THEN20:%.*]]
395 ; CHECK: itofp-if-then20:
396 ; CHECK-NEXT: [[TMP30:%.*]] = ashr i129 [[TMP24]], 3
397 ; CHECK-NEXT: [[TMP31:%.*]] = trunc i129 [[TMP30]] to i128
398 ; CHECK-NEXT: [[TMP32:%.*]] = lshr i129 [[TMP30]], 32
399 ; CHECK-NEXT: [[TMP33:%.*]] = trunc i129 [[TMP6]] to i64
400 ; CHECK-NEXT: br label [[ITOFP_IF_END26]]
401 ; CHECK: itofp-if-else:
402 ; CHECK-NEXT: [[TMP34:%.*]] = add i129 [[TMP4]], 4294967280
403 ; CHECK-NEXT: [[TMP35:%.*]] = shl i129 [[TMP3]], [[TMP34]]
404 ; CHECK-NEXT: [[TMP36:%.*]] = trunc i129 [[TMP35]] to i128
405 ; CHECK-NEXT: [[TMP37:%.*]] = lshr i129 [[TMP35]], 32
406 ; CHECK-NEXT: [[TMP38:%.*]] = trunc i129 [[TMP7]] to i64
407 ; CHECK-NEXT: br label [[ITOFP_IF_END26]]
408 ; CHECK: itofp-if-end26:
409 ; CHECK-NEXT: [[TMP39:%.*]] = phi i128 [ [[TMP31]], [[ITOFP_IF_THEN20]] ], [ [[TMP27]], [[ITOFP_SW_EPILOG]] ], [ [[TMP36]], [[ITOFP_IF_ELSE]] ]
410 ; CHECK-NEXT: [[TMP40:%.*]] = phi i64 [ [[TMP33]], [[ITOFP_IF_THEN20]] ], [ [[TMP29]], [[ITOFP_SW_EPILOG]] ], [ [[TMP38]], [[ITOFP_IF_ELSE]] ]
411 ; CHECK-NEXT: [[AND29:%.*]] = and i129 [[TMP1]], 9223372036854775808
412 ; CHECK-NEXT: [[TMP41:%.*]] = shl i64 [[TMP40]], 48
413 ; CHECK-NEXT: [[TMP42:%.*]] = add i64 [[TMP41]], 4611404543450677248
414 ; CHECK-NEXT: [[TMP43:%.*]] = zext i64 [[TMP42]] to i128
415 ; CHECK-NEXT: [[TMP44:%.*]] = trunc i129 [[AND29]] to i128
416 ; CHECK-NEXT: [[TMP45:%.*]] = or i128 [[TMP44]], [[TMP43]]
417 ; CHECK-NEXT: [[TMP46:%.*]] = shl i128 [[TMP45]], 64
418 ; CHECK-NEXT: [[TMP47:%.*]] = and i128 [[TMP39]], 5192296858534827628530496329220095
419 ; CHECK-NEXT: [[TMP48:%.*]] = or i128 [[TMP46]], [[TMP47]]
420 ; CHECK-NEXT: [[TMP49:%.*]] = bitcast i128 [[TMP48]] to fp128
421 ; CHECK-NEXT: br label [[ITOFP_RETURN]]
422 ; CHECK: itofp-return:
423 ; CHECK-NEXT: [[TMP50:%.*]] = phi fp128 [ [[TMP49]], [[ITOFP_IF_END26]] ], [ 0xL00000000000000000000000000000000, [[ITOFP_ENTRY:%.*]] ]
424 ; CHECK-NEXT: ret fp128 [[TMP50]]
426 %conv = sitofp i129 %a to fp128