1; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2; RUN: llc < %s -mtriple=i386-unknown | FileCheck %s --check-prefix=X86
3; RUN: llc < %s -mtriple=x86_64-unknown | FileCheck %s --check-prefixes=X64,X64-X87
4; RUN: llc < %s -mtriple=x86_64-unknown -mattr=+ssse3 | FileCheck %s --check-prefixes=X64,X64-SSSE3
5
6;
7; fptosi
8;
9
10define i16 @fptosi_i16_fp80(x86_fp80 %a0) nounwind {
11; X86-LABEL: fptosi_i16_fp80:
12; X86:       # %bb.0:
13; X86-NEXT:    subl $8, %esp
14; X86-NEXT:    fldt {{[0-9]+}}(%esp)
15; X86-NEXT:    fnstcw {{[0-9]+}}(%esp)
16; X86-NEXT:    movzwl {{[0-9]+}}(%esp), %eax
17; X86-NEXT:    orl $3072, %eax # imm = 0xC00
18; X86-NEXT:    movw %ax, {{[0-9]+}}(%esp)
19; X86-NEXT:    fldcw {{[0-9]+}}(%esp)
20; X86-NEXT:    fistps {{[0-9]+}}(%esp)
21; X86-NEXT:    fldcw {{[0-9]+}}(%esp)
22; X86-NEXT:    movzwl {{[0-9]+}}(%esp), %eax
23; X86-NEXT:    addl $8, %esp
24; X86-NEXT:    retl
25;
26; X64-X87-LABEL: fptosi_i16_fp80:
27; X64-X87:       # %bb.0:
28; X64-X87-NEXT:    fldt {{[0-9]+}}(%rsp)
29; X64-X87-NEXT:    fnstcw -{{[0-9]+}}(%rsp)
30; X64-X87-NEXT:    movzwl -{{[0-9]+}}(%rsp), %eax
31; X64-X87-NEXT:    orl $3072, %eax # imm = 0xC00
32; X64-X87-NEXT:    movw %ax, -{{[0-9]+}}(%rsp)
33; X64-X87-NEXT:    fldcw -{{[0-9]+}}(%rsp)
34; X64-X87-NEXT:    fistps -{{[0-9]+}}(%rsp)
35; X64-X87-NEXT:    fldcw -{{[0-9]+}}(%rsp)
36; X64-X87-NEXT:    movzwl -{{[0-9]+}}(%rsp), %eax
37; X64-X87-NEXT:    retq
38;
39; X64-SSSE3-LABEL: fptosi_i16_fp80:
40; X64-SSSE3:       # %bb.0:
41; X64-SSSE3-NEXT:    fldt {{[0-9]+}}(%rsp)
42; X64-SSSE3-NEXT:    fisttps -{{[0-9]+}}(%rsp)
43; X64-SSSE3-NEXT:    movzwl -{{[0-9]+}}(%rsp), %eax
44; X64-SSSE3-NEXT:    retq
45  %1 = fptosi x86_fp80 %a0 to i16
46  ret i16  %1
47}
48
49define i16 @fptosi_i16_fp80_ld(x86_fp80 *%a0) nounwind {
50; X86-LABEL: fptosi_i16_fp80_ld:
51; X86:       # %bb.0:
52; X86-NEXT:    subl $8, %esp
53; X86-NEXT:    movl {{[0-9]+}}(%esp), %eax
54; X86-NEXT:    fldt (%eax)
55; X86-NEXT:    fnstcw {{[0-9]+}}(%esp)
56; X86-NEXT:    movzwl {{[0-9]+}}(%esp), %eax
57; X86-NEXT:    orl $3072, %eax # imm = 0xC00
58; X86-NEXT:    movw %ax, {{[0-9]+}}(%esp)
59; X86-NEXT:    fldcw {{[0-9]+}}(%esp)
60; X86-NEXT:    fistps {{[0-9]+}}(%esp)
61; X86-NEXT:    fldcw {{[0-9]+}}(%esp)
62; X86-NEXT:    movzwl {{[0-9]+}}(%esp), %eax
63; X86-NEXT:    addl $8, %esp
64; X86-NEXT:    retl
65;
66; X64-X87-LABEL: fptosi_i16_fp80_ld:
67; X64-X87:       # %bb.0:
68; X64-X87-NEXT:    fldt (%rdi)
69; X64-X87-NEXT:    fnstcw -{{[0-9]+}}(%rsp)
70; X64-X87-NEXT:    movzwl -{{[0-9]+}}(%rsp), %eax
71; X64-X87-NEXT:    orl $3072, %eax # imm = 0xC00
72; X64-X87-NEXT:    movw %ax, -{{[0-9]+}}(%rsp)
73; X64-X87-NEXT:    fldcw -{{[0-9]+}}(%rsp)
74; X64-X87-NEXT:    fistps -{{[0-9]+}}(%rsp)
75; X64-X87-NEXT:    fldcw -{{[0-9]+}}(%rsp)
76; X64-X87-NEXT:    movzwl -{{[0-9]+}}(%rsp), %eax
77; X64-X87-NEXT:    retq
78;
79; X64-SSSE3-LABEL: fptosi_i16_fp80_ld:
80; X64-SSSE3:       # %bb.0:
81; X64-SSSE3-NEXT:    fldt (%rdi)
82; X64-SSSE3-NEXT:    fisttps -{{[0-9]+}}(%rsp)
83; X64-SSSE3-NEXT:    movzwl -{{[0-9]+}}(%rsp), %eax
84; X64-SSSE3-NEXT:    retq
85  %1 = load x86_fp80, x86_fp80 *%a0
86  %2 = fptosi x86_fp80 %1 to i16
87  ret i16  %2
88}
89
90define i32 @fptosi_i32_fp80(x86_fp80 %a0) nounwind {
91; X86-LABEL: fptosi_i32_fp80:
92; X86:       # %bb.0:
93; X86-NEXT:    subl $8, %esp
94; X86-NEXT:    fldt {{[0-9]+}}(%esp)
95; X86-NEXT:    fnstcw (%esp)
96; X86-NEXT:    movzwl (%esp), %eax
97; X86-NEXT:    orl $3072, %eax # imm = 0xC00
98; X86-NEXT:    movw %ax, {{[0-9]+}}(%esp)
99; X86-NEXT:    fldcw {{[0-9]+}}(%esp)
100; X86-NEXT:    fistpl {{[0-9]+}}(%esp)
101; X86-NEXT:    fldcw (%esp)
102; X86-NEXT:    movl {{[0-9]+}}(%esp), %eax
103; X86-NEXT:    addl $8, %esp
104; X86-NEXT:    retl
105;
106; X64-X87-LABEL: fptosi_i32_fp80:
107; X64-X87:       # %bb.0:
108; X64-X87-NEXT:    fldt {{[0-9]+}}(%rsp)
109; X64-X87-NEXT:    fnstcw -{{[0-9]+}}(%rsp)
110; X64-X87-NEXT:    movzwl -{{[0-9]+}}(%rsp), %eax
111; X64-X87-NEXT:    orl $3072, %eax # imm = 0xC00
112; X64-X87-NEXT:    movw %ax, -{{[0-9]+}}(%rsp)
113; X64-X87-NEXT:    fldcw -{{[0-9]+}}(%rsp)
114; X64-X87-NEXT:    fistpl -{{[0-9]+}}(%rsp)
115; X64-X87-NEXT:    fldcw -{{[0-9]+}}(%rsp)
116; X64-X87-NEXT:    movl -{{[0-9]+}}(%rsp), %eax
117; X64-X87-NEXT:    retq
118;
119; X64-SSSE3-LABEL: fptosi_i32_fp80:
120; X64-SSSE3:       # %bb.0:
121; X64-SSSE3-NEXT:    fldt {{[0-9]+}}(%rsp)
122; X64-SSSE3-NEXT:    fisttpl -{{[0-9]+}}(%rsp)
123; X64-SSSE3-NEXT:    movl -{{[0-9]+}}(%rsp), %eax
124; X64-SSSE3-NEXT:    retq
125  %1 = fptosi x86_fp80 %a0 to i32
126  ret i32  %1
127}
128
129define i32 @fptosi_i32_fp80_ld(x86_fp80 *%a0) nounwind {
130; X86-LABEL: fptosi_i32_fp80_ld:
131; X86:       # %bb.0:
132; X86-NEXT:    subl $8, %esp
133; X86-NEXT:    movl {{[0-9]+}}(%esp), %eax
134; X86-NEXT:    fldt (%eax)
135; X86-NEXT:    fnstcw (%esp)
136; X86-NEXT:    movzwl (%esp), %eax
137; X86-NEXT:    orl $3072, %eax # imm = 0xC00
138; X86-NEXT:    movw %ax, {{[0-9]+}}(%esp)
139; X86-NEXT:    fldcw {{[0-9]+}}(%esp)
140; X86-NEXT:    fistpl {{[0-9]+}}(%esp)
141; X86-NEXT:    fldcw (%esp)
142; X86-NEXT:    movl {{[0-9]+}}(%esp), %eax
143; X86-NEXT:    addl $8, %esp
144; X86-NEXT:    retl
145;
146; X64-X87-LABEL: fptosi_i32_fp80_ld:
147; X64-X87:       # %bb.0:
148; X64-X87-NEXT:    fldt (%rdi)
149; X64-X87-NEXT:    fnstcw -{{[0-9]+}}(%rsp)
150; X64-X87-NEXT:    movzwl -{{[0-9]+}}(%rsp), %eax
151; X64-X87-NEXT:    orl $3072, %eax # imm = 0xC00
152; X64-X87-NEXT:    movw %ax, -{{[0-9]+}}(%rsp)
153; X64-X87-NEXT:    fldcw -{{[0-9]+}}(%rsp)
154; X64-X87-NEXT:    fistpl -{{[0-9]+}}(%rsp)
155; X64-X87-NEXT:    fldcw -{{[0-9]+}}(%rsp)
156; X64-X87-NEXT:    movl -{{[0-9]+}}(%rsp), %eax
157; X64-X87-NEXT:    retq
158;
159; X64-SSSE3-LABEL: fptosi_i32_fp80_ld:
160; X64-SSSE3:       # %bb.0:
161; X64-SSSE3-NEXT:    fldt (%rdi)
162; X64-SSSE3-NEXT:    fisttpl -{{[0-9]+}}(%rsp)
163; X64-SSSE3-NEXT:    movl -{{[0-9]+}}(%rsp), %eax
164; X64-SSSE3-NEXT:    retq
165  %1 = load x86_fp80, x86_fp80 *%a0
166  %2 = fptosi x86_fp80 %1 to i32
167  ret i32  %2
168}
169
170define i64 @fptosi_i64_fp80(x86_fp80 %a0) nounwind {
171; X86-LABEL: fptosi_i64_fp80:
172; X86:       # %bb.0:
173; X86-NEXT:    pushl %ebp
174; X86-NEXT:    movl %esp, %ebp
175; X86-NEXT:    andl $-8, %esp
176; X86-NEXT:    subl $16, %esp
177; X86-NEXT:    fldt 8(%ebp)
178; X86-NEXT:    fnstcw {{[0-9]+}}(%esp)
179; X86-NEXT:    movzwl {{[0-9]+}}(%esp), %eax
180; X86-NEXT:    orl $3072, %eax # imm = 0xC00
181; X86-NEXT:    movw %ax, {{[0-9]+}}(%esp)
182; X86-NEXT:    fldcw {{[0-9]+}}(%esp)
183; X86-NEXT:    fistpll {{[0-9]+}}(%esp)
184; X86-NEXT:    fldcw {{[0-9]+}}(%esp)
185; X86-NEXT:    movl {{[0-9]+}}(%esp), %eax
186; X86-NEXT:    movl {{[0-9]+}}(%esp), %edx
187; X86-NEXT:    movl %ebp, %esp
188; X86-NEXT:    popl %ebp
189; X86-NEXT:    retl
190;
191; X64-X87-LABEL: fptosi_i64_fp80:
192; X64-X87:       # %bb.0:
193; X64-X87-NEXT:    fldt {{[0-9]+}}(%rsp)
194; X64-X87-NEXT:    fnstcw -{{[0-9]+}}(%rsp)
195; X64-X87-NEXT:    movzwl -{{[0-9]+}}(%rsp), %eax
196; X64-X87-NEXT:    orl $3072, %eax # imm = 0xC00
197; X64-X87-NEXT:    movw %ax, -{{[0-9]+}}(%rsp)
198; X64-X87-NEXT:    fldcw -{{[0-9]+}}(%rsp)
199; X64-X87-NEXT:    fistpll -{{[0-9]+}}(%rsp)
200; X64-X87-NEXT:    fldcw -{{[0-9]+}}(%rsp)
201; X64-X87-NEXT:    movq -{{[0-9]+}}(%rsp), %rax
202; X64-X87-NEXT:    retq
203;
204; X64-SSSE3-LABEL: fptosi_i64_fp80:
205; X64-SSSE3:       # %bb.0:
206; X64-SSSE3-NEXT:    fldt {{[0-9]+}}(%rsp)
207; X64-SSSE3-NEXT:    fisttpll -{{[0-9]+}}(%rsp)
208; X64-SSSE3-NEXT:    movq -{{[0-9]+}}(%rsp), %rax
209; X64-SSSE3-NEXT:    retq
210  %1 = fptosi x86_fp80 %a0 to i64
211  ret i64  %1
212}
213
214define i64 @fptosi_i64_fp80_ld(x86_fp80 *%a0) nounwind {
215; X86-LABEL: fptosi_i64_fp80_ld:
216; X86:       # %bb.0:
217; X86-NEXT:    pushl %ebp
218; X86-NEXT:    movl %esp, %ebp
219; X86-NEXT:    andl $-8, %esp
220; X86-NEXT:    subl $16, %esp
221; X86-NEXT:    movl 8(%ebp), %eax
222; X86-NEXT:    fldt (%eax)
223; X86-NEXT:    fnstcw {{[0-9]+}}(%esp)
224; X86-NEXT:    movzwl {{[0-9]+}}(%esp), %eax
225; X86-NEXT:    orl $3072, %eax # imm = 0xC00
226; X86-NEXT:    movw %ax, {{[0-9]+}}(%esp)
227; X86-NEXT:    fldcw {{[0-9]+}}(%esp)
228; X86-NEXT:    fistpll {{[0-9]+}}(%esp)
229; X86-NEXT:    fldcw {{[0-9]+}}(%esp)
230; X86-NEXT:    movl {{[0-9]+}}(%esp), %eax
231; X86-NEXT:    movl {{[0-9]+}}(%esp), %edx
232; X86-NEXT:    movl %ebp, %esp
233; X86-NEXT:    popl %ebp
234; X86-NEXT:    retl
235;
236; X64-X87-LABEL: fptosi_i64_fp80_ld:
237; X64-X87:       # %bb.0:
238; X64-X87-NEXT:    fldt (%rdi)
239; X64-X87-NEXT:    fnstcw -{{[0-9]+}}(%rsp)
240; X64-X87-NEXT:    movzwl -{{[0-9]+}}(%rsp), %eax
241; X64-X87-NEXT:    orl $3072, %eax # imm = 0xC00
242; X64-X87-NEXT:    movw %ax, -{{[0-9]+}}(%rsp)
243; X64-X87-NEXT:    fldcw -{{[0-9]+}}(%rsp)
244; X64-X87-NEXT:    fistpll -{{[0-9]+}}(%rsp)
245; X64-X87-NEXT:    fldcw -{{[0-9]+}}(%rsp)
246; X64-X87-NEXT:    movq -{{[0-9]+}}(%rsp), %rax
247; X64-X87-NEXT:    retq
248;
249; X64-SSSE3-LABEL: fptosi_i64_fp80_ld:
250; X64-SSSE3:       # %bb.0:
251; X64-SSSE3-NEXT:    fldt (%rdi)
252; X64-SSSE3-NEXT:    fisttpll -{{[0-9]+}}(%rsp)
253; X64-SSSE3-NEXT:    movq -{{[0-9]+}}(%rsp), %rax
254; X64-SSSE3-NEXT:    retq
255  %1 = load x86_fp80, x86_fp80 *%a0
256  %2 = fptosi x86_fp80 %1 to i64
257  ret i64  %2
258}
259
260;
261; fptoui
262;
263
264define i16 @fptoui_i16_fp80(x86_fp80 %a0) nounwind {
265; X86-LABEL: fptoui_i16_fp80:
266; X86:       # %bb.0:
267; X86-NEXT:    subl $8, %esp
268; X86-NEXT:    fldt {{[0-9]+}}(%esp)
269; X86-NEXT:    fnstcw (%esp)
270; X86-NEXT:    movzwl (%esp), %eax
271; X86-NEXT:    orl $3072, %eax # imm = 0xC00
272; X86-NEXT:    movw %ax, {{[0-9]+}}(%esp)
273; X86-NEXT:    fldcw {{[0-9]+}}(%esp)
274; X86-NEXT:    fistpl {{[0-9]+}}(%esp)
275; X86-NEXT:    fldcw (%esp)
276; X86-NEXT:    movl {{[0-9]+}}(%esp), %eax
277; X86-NEXT:    # kill: def $ax killed $ax killed $eax
278; X86-NEXT:    addl $8, %esp
279; X86-NEXT:    retl
280;
281; X64-X87-LABEL: fptoui_i16_fp80:
282; X64-X87:       # %bb.0:
283; X64-X87-NEXT:    fldt {{[0-9]+}}(%rsp)
284; X64-X87-NEXT:    fnstcw -{{[0-9]+}}(%rsp)
285; X64-X87-NEXT:    movzwl -{{[0-9]+}}(%rsp), %eax
286; X64-X87-NEXT:    orl $3072, %eax # imm = 0xC00
287; X64-X87-NEXT:    movw %ax, -{{[0-9]+}}(%rsp)
288; X64-X87-NEXT:    fldcw -{{[0-9]+}}(%rsp)
289; X64-X87-NEXT:    fistpl -{{[0-9]+}}(%rsp)
290; X64-X87-NEXT:    fldcw -{{[0-9]+}}(%rsp)
291; X64-X87-NEXT:    movl -{{[0-9]+}}(%rsp), %eax
292; X64-X87-NEXT:    # kill: def $ax killed $ax killed $eax
293; X64-X87-NEXT:    retq
294;
295; X64-SSSE3-LABEL: fptoui_i16_fp80:
296; X64-SSSE3:       # %bb.0:
297; X64-SSSE3-NEXT:    fldt {{[0-9]+}}(%rsp)
298; X64-SSSE3-NEXT:    fisttpl -{{[0-9]+}}(%rsp)
299; X64-SSSE3-NEXT:    movl -{{[0-9]+}}(%rsp), %eax
300; X64-SSSE3-NEXT:    # kill: def $ax killed $ax killed $eax
301; X64-SSSE3-NEXT:    retq
302  %1 = fptoui x86_fp80 %a0 to i16
303  ret i16  %1
304}
305
306define i16 @fptoui_i16_fp80_ld(x86_fp80 *%a0) nounwind {
307; X86-LABEL: fptoui_i16_fp80_ld:
308; X86:       # %bb.0:
309; X86-NEXT:    subl $8, %esp
310; X86-NEXT:    movl {{[0-9]+}}(%esp), %eax
311; X86-NEXT:    fldt (%eax)
312; X86-NEXT:    fnstcw (%esp)
313; X86-NEXT:    movzwl (%esp), %eax
314; X86-NEXT:    orl $3072, %eax # imm = 0xC00
315; X86-NEXT:    movw %ax, {{[0-9]+}}(%esp)
316; X86-NEXT:    fldcw {{[0-9]+}}(%esp)
317; X86-NEXT:    fistpl {{[0-9]+}}(%esp)
318; X86-NEXT:    fldcw (%esp)
319; X86-NEXT:    movl {{[0-9]+}}(%esp), %eax
320; X86-NEXT:    # kill: def $ax killed $ax killed $eax
321; X86-NEXT:    addl $8, %esp
322; X86-NEXT:    retl
323;
324; X64-X87-LABEL: fptoui_i16_fp80_ld:
325; X64-X87:       # %bb.0:
326; X64-X87-NEXT:    fldt (%rdi)
327; X64-X87-NEXT:    fnstcw -{{[0-9]+}}(%rsp)
328; X64-X87-NEXT:    movzwl -{{[0-9]+}}(%rsp), %eax
329; X64-X87-NEXT:    orl $3072, %eax # imm = 0xC00
330; X64-X87-NEXT:    movw %ax, -{{[0-9]+}}(%rsp)
331; X64-X87-NEXT:    fldcw -{{[0-9]+}}(%rsp)
332; X64-X87-NEXT:    fistpl -{{[0-9]+}}(%rsp)
333; X64-X87-NEXT:    fldcw -{{[0-9]+}}(%rsp)
334; X64-X87-NEXT:    movl -{{[0-9]+}}(%rsp), %eax
335; X64-X87-NEXT:    # kill: def $ax killed $ax killed $eax
336; X64-X87-NEXT:    retq
337;
338; X64-SSSE3-LABEL: fptoui_i16_fp80_ld:
339; X64-SSSE3:       # %bb.0:
340; X64-SSSE3-NEXT:    fldt (%rdi)
341; X64-SSSE3-NEXT:    fisttpl -{{[0-9]+}}(%rsp)
342; X64-SSSE3-NEXT:    movl -{{[0-9]+}}(%rsp), %eax
343; X64-SSSE3-NEXT:    # kill: def $ax killed $ax killed $eax
344; X64-SSSE3-NEXT:    retq
345  %1 = load x86_fp80, x86_fp80 *%a0
346  %2 = fptoui x86_fp80 %1 to i16
347  ret i16  %2
348}
349
350define i32 @fptoui_i32_fp80(x86_fp80 %a0) nounwind {
351; X86-LABEL: fptoui_i32_fp80:
352; X86:       # %bb.0:
353; X86-NEXT:    pushl %ebp
354; X86-NEXT:    movl %esp, %ebp
355; X86-NEXT:    andl $-8, %esp
356; X86-NEXT:    subl $16, %esp
357; X86-NEXT:    fldt 8(%ebp)
358; X86-NEXT:    fnstcw {{[0-9]+}}(%esp)
359; X86-NEXT:    movzwl {{[0-9]+}}(%esp), %eax
360; X86-NEXT:    orl $3072, %eax # imm = 0xC00
361; X86-NEXT:    movw %ax, {{[0-9]+}}(%esp)
362; X86-NEXT:    fldcw {{[0-9]+}}(%esp)
363; X86-NEXT:    fistpll {{[0-9]+}}(%esp)
364; X86-NEXT:    fldcw {{[0-9]+}}(%esp)
365; X86-NEXT:    movl {{[0-9]+}}(%esp), %eax
366; X86-NEXT:    movl %ebp, %esp
367; X86-NEXT:    popl %ebp
368; X86-NEXT:    retl
369;
370; X64-X87-LABEL: fptoui_i32_fp80:
371; X64-X87:       # %bb.0:
372; X64-X87-NEXT:    fldt {{[0-9]+}}(%rsp)
373; X64-X87-NEXT:    fnstcw -{{[0-9]+}}(%rsp)
374; X64-X87-NEXT:    movzwl -{{[0-9]+}}(%rsp), %eax
375; X64-X87-NEXT:    orl $3072, %eax # imm = 0xC00
376; X64-X87-NEXT:    movw %ax, -{{[0-9]+}}(%rsp)
377; X64-X87-NEXT:    fldcw -{{[0-9]+}}(%rsp)
378; X64-X87-NEXT:    fistpll -{{[0-9]+}}(%rsp)
379; X64-X87-NEXT:    fldcw -{{[0-9]+}}(%rsp)
380; X64-X87-NEXT:    movl -{{[0-9]+}}(%rsp), %eax
381; X64-X87-NEXT:    retq
382;
383; X64-SSSE3-LABEL: fptoui_i32_fp80:
384; X64-SSSE3:       # %bb.0:
385; X64-SSSE3-NEXT:    fldt {{[0-9]+}}(%rsp)
386; X64-SSSE3-NEXT:    fisttpll -{{[0-9]+}}(%rsp)
387; X64-SSSE3-NEXT:    movl -{{[0-9]+}}(%rsp), %eax
388; X64-SSSE3-NEXT:    retq
389  %1 = fptoui x86_fp80 %a0 to i32
390  ret i32  %1
391}
392
393define i32 @fptoui_i32_fp80_ld(x86_fp80 *%a0) nounwind {
394; X86-LABEL: fptoui_i32_fp80_ld:
395; X86:       # %bb.0:
396; X86-NEXT:    pushl %ebp
397; X86-NEXT:    movl %esp, %ebp
398; X86-NEXT:    andl $-8, %esp
399; X86-NEXT:    subl $16, %esp
400; X86-NEXT:    movl 8(%ebp), %eax
401; X86-NEXT:    fldt (%eax)
402; X86-NEXT:    fnstcw {{[0-9]+}}(%esp)
403; X86-NEXT:    movzwl {{[0-9]+}}(%esp), %eax
404; X86-NEXT:    orl $3072, %eax # imm = 0xC00
405; X86-NEXT:    movw %ax, {{[0-9]+}}(%esp)
406; X86-NEXT:    fldcw {{[0-9]+}}(%esp)
407; X86-NEXT:    fistpll {{[0-9]+}}(%esp)
408; X86-NEXT:    fldcw {{[0-9]+}}(%esp)
409; X86-NEXT:    movl {{[0-9]+}}(%esp), %eax
410; X86-NEXT:    movl %ebp, %esp
411; X86-NEXT:    popl %ebp
412; X86-NEXT:    retl
413;
414; X64-X87-LABEL: fptoui_i32_fp80_ld:
415; X64-X87:       # %bb.0:
416; X64-X87-NEXT:    fldt (%rdi)
417; X64-X87-NEXT:    fnstcw -{{[0-9]+}}(%rsp)
418; X64-X87-NEXT:    movzwl -{{[0-9]+}}(%rsp), %eax
419; X64-X87-NEXT:    orl $3072, %eax # imm = 0xC00
420; X64-X87-NEXT:    movw %ax, -{{[0-9]+}}(%rsp)
421; X64-X87-NEXT:    fldcw -{{[0-9]+}}(%rsp)
422; X64-X87-NEXT:    fistpll -{{[0-9]+}}(%rsp)
423; X64-X87-NEXT:    fldcw -{{[0-9]+}}(%rsp)
424; X64-X87-NEXT:    movl -{{[0-9]+}}(%rsp), %eax
425; X64-X87-NEXT:    retq
426;
427; X64-SSSE3-LABEL: fptoui_i32_fp80_ld:
428; X64-SSSE3:       # %bb.0:
429; X64-SSSE3-NEXT:    fldt (%rdi)
430; X64-SSSE3-NEXT:    fisttpll -{{[0-9]+}}(%rsp)
431; X64-SSSE3-NEXT:    movl -{{[0-9]+}}(%rsp), %eax
432; X64-SSSE3-NEXT:    retq
433  %1 = load x86_fp80, x86_fp80 *%a0
434  %2 = fptoui x86_fp80 %1 to i32
435  ret i32  %2
436}
437
438define i64 @fptoui_i64_fp80(x86_fp80 %a0) nounwind {
439; X86-LABEL: fptoui_i64_fp80:
440; X86:       # %bb.0:
441; X86-NEXT:    pushl %ebp
442; X86-NEXT:    movl %esp, %ebp
443; X86-NEXT:    andl $-8, %esp
444; X86-NEXT:    subl $16, %esp
445; X86-NEXT:    fldt 8(%ebp)
446; X86-NEXT:    flds {{\.LCPI.*}}
447; X86-NEXT:    fucom %st(1)
448; X86-NEXT:    fnstsw %ax
449; X86-NEXT:    xorl %edx, %edx
450; X86-NEXT:    # kill: def $ah killed $ah killed $ax
451; X86-NEXT:    sahf
452; X86-NEXT:    setbe %al
453; X86-NEXT:    fldz
454; X86-NEXT:    jbe .LBB10_2
455; X86-NEXT:  # %bb.1:
456; X86-NEXT:    fstp %st(1)
457; X86-NEXT:    fldz
458; X86-NEXT:  .LBB10_2:
459; X86-NEXT:    fstp %st(0)
460; X86-NEXT:    fsubrp %st, %st(1)
461; X86-NEXT:    fnstcw {{[0-9]+}}(%esp)
462; X86-NEXT:    movzwl {{[0-9]+}}(%esp), %ecx
463; X86-NEXT:    orl $3072, %ecx # imm = 0xC00
464; X86-NEXT:    movw %cx, {{[0-9]+}}(%esp)
465; X86-NEXT:    fldcw {{[0-9]+}}(%esp)
466; X86-NEXT:    fistpll {{[0-9]+}}(%esp)
467; X86-NEXT:    fldcw {{[0-9]+}}(%esp)
468; X86-NEXT:    movb %al, %dl
469; X86-NEXT:    shll $31, %edx
470; X86-NEXT:    xorl {{[0-9]+}}(%esp), %edx
471; X86-NEXT:    movl {{[0-9]+}}(%esp), %eax
472; X86-NEXT:    movl %ebp, %esp
473; X86-NEXT:    popl %ebp
474; X86-NEXT:    retl
475;
476; X64-X87-LABEL: fptoui_i64_fp80:
477; X64-X87:       # %bb.0:
478; X64-X87-NEXT:    fldt {{[0-9]+}}(%rsp)
479; X64-X87-NEXT:    flds {{.*}}(%rip)
480; X64-X87-NEXT:    xorl %eax, %eax
481; X64-X87-NEXT:    fucomi %st(1), %st
482; X64-X87-NEXT:    setbe %al
483; X64-X87-NEXT:    fldz
484; X64-X87-NEXT:    fcmovbe %st(1), %st
485; X64-X87-NEXT:    fstp %st(1)
486; X64-X87-NEXT:    fsubrp %st, %st(1)
487; X64-X87-NEXT:    fnstcw -{{[0-9]+}}(%rsp)
488; X64-X87-NEXT:    movzwl -{{[0-9]+}}(%rsp), %ecx
489; X64-X87-NEXT:    orl $3072, %ecx # imm = 0xC00
490; X64-X87-NEXT:    movw %cx, -{{[0-9]+}}(%rsp)
491; X64-X87-NEXT:    fldcw -{{[0-9]+}}(%rsp)
492; X64-X87-NEXT:    fistpll -{{[0-9]+}}(%rsp)
493; X64-X87-NEXT:    fldcw -{{[0-9]+}}(%rsp)
494; X64-X87-NEXT:    shlq $63, %rax
495; X64-X87-NEXT:    xorq -{{[0-9]+}}(%rsp), %rax
496; X64-X87-NEXT:    retq
497;
498; X64-SSSE3-LABEL: fptoui_i64_fp80:
499; X64-SSSE3:       # %bb.0:
500; X64-SSSE3-NEXT:    fldt {{[0-9]+}}(%rsp)
501; X64-SSSE3-NEXT:    flds {{.*}}(%rip)
502; X64-SSSE3-NEXT:    xorl %eax, %eax
503; X64-SSSE3-NEXT:    fucomi %st(1), %st
504; X64-SSSE3-NEXT:    fldz
505; X64-SSSE3-NEXT:    fcmovbe %st(1), %st
506; X64-SSSE3-NEXT:    fstp %st(1)
507; X64-SSSE3-NEXT:    fsubrp %st, %st(1)
508; X64-SSSE3-NEXT:    fisttpll -{{[0-9]+}}(%rsp)
509; X64-SSSE3-NEXT:    setbe %al
510; X64-SSSE3-NEXT:    shlq $63, %rax
511; X64-SSSE3-NEXT:    xorq -{{[0-9]+}}(%rsp), %rax
512; X64-SSSE3-NEXT:    retq
513  %1 = fptoui x86_fp80 %a0 to i64
514  ret i64  %1
515}
516
517define i64 @fptoui_i64_fp80_ld(x86_fp80 *%a0) nounwind {
518; X86-LABEL: fptoui_i64_fp80_ld:
519; X86:       # %bb.0:
520; X86-NEXT:    pushl %ebp
521; X86-NEXT:    movl %esp, %ebp
522; X86-NEXT:    andl $-8, %esp
523; X86-NEXT:    subl $16, %esp
524; X86-NEXT:    movl 8(%ebp), %eax
525; X86-NEXT:    fldt (%eax)
526; X86-NEXT:    flds {{\.LCPI.*}}
527; X86-NEXT:    fucom %st(1)
528; X86-NEXT:    fnstsw %ax
529; X86-NEXT:    xorl %edx, %edx
530; X86-NEXT:    # kill: def $ah killed $ah killed $ax
531; X86-NEXT:    sahf
532; X86-NEXT:    setbe %al
533; X86-NEXT:    fldz
534; X86-NEXT:    jbe .LBB11_2
535; X86-NEXT:  # %bb.1:
536; X86-NEXT:    fstp %st(1)
537; X86-NEXT:    fldz
538; X86-NEXT:  .LBB11_2:
539; X86-NEXT:    fstp %st(0)
540; X86-NEXT:    fsubrp %st, %st(1)
541; X86-NEXT:    fnstcw {{[0-9]+}}(%esp)
542; X86-NEXT:    movzwl {{[0-9]+}}(%esp), %ecx
543; X86-NEXT:    orl $3072, %ecx # imm = 0xC00
544; X86-NEXT:    movw %cx, {{[0-9]+}}(%esp)
545; X86-NEXT:    fldcw {{[0-9]+}}(%esp)
546; X86-NEXT:    fistpll {{[0-9]+}}(%esp)
547; X86-NEXT:    fldcw {{[0-9]+}}(%esp)
548; X86-NEXT:    movb %al, %dl
549; X86-NEXT:    shll $31, %edx
550; X86-NEXT:    xorl {{[0-9]+}}(%esp), %edx
551; X86-NEXT:    movl {{[0-9]+}}(%esp), %eax
552; X86-NEXT:    movl %ebp, %esp
553; X86-NEXT:    popl %ebp
554; X86-NEXT:    retl
555;
556; X64-X87-LABEL: fptoui_i64_fp80_ld:
557; X64-X87:       # %bb.0:
558; X64-X87-NEXT:    fldt (%rdi)
559; X64-X87-NEXT:    flds {{.*}}(%rip)
560; X64-X87-NEXT:    xorl %eax, %eax
561; X64-X87-NEXT:    fucomi %st(1), %st
562; X64-X87-NEXT:    setbe %al
563; X64-X87-NEXT:    fldz
564; X64-X87-NEXT:    fcmovbe %st(1), %st
565; X64-X87-NEXT:    fstp %st(1)
566; X64-X87-NEXT:    fsubrp %st, %st(1)
567; X64-X87-NEXT:    fnstcw -{{[0-9]+}}(%rsp)
568; X64-X87-NEXT:    movzwl -{{[0-9]+}}(%rsp), %ecx
569; X64-X87-NEXT:    orl $3072, %ecx # imm = 0xC00
570; X64-X87-NEXT:    movw %cx, -{{[0-9]+}}(%rsp)
571; X64-X87-NEXT:    fldcw -{{[0-9]+}}(%rsp)
572; X64-X87-NEXT:    fistpll -{{[0-9]+}}(%rsp)
573; X64-X87-NEXT:    fldcw -{{[0-9]+}}(%rsp)
574; X64-X87-NEXT:    shlq $63, %rax
575; X64-X87-NEXT:    xorq -{{[0-9]+}}(%rsp), %rax
576; X64-X87-NEXT:    retq
577;
578; X64-SSSE3-LABEL: fptoui_i64_fp80_ld:
579; X64-SSSE3:       # %bb.0:
580; X64-SSSE3-NEXT:    fldt (%rdi)
581; X64-SSSE3-NEXT:    flds {{.*}}(%rip)
582; X64-SSSE3-NEXT:    xorl %eax, %eax
583; X64-SSSE3-NEXT:    fucomi %st(1), %st
584; X64-SSSE3-NEXT:    fldz
585; X64-SSSE3-NEXT:    fcmovbe %st(1), %st
586; X64-SSSE3-NEXT:    fstp %st(1)
587; X64-SSSE3-NEXT:    fsubrp %st, %st(1)
588; X64-SSSE3-NEXT:    fisttpll -{{[0-9]+}}(%rsp)
589; X64-SSSE3-NEXT:    setbe %al
590; X64-SSSE3-NEXT:    shlq $63, %rax
591; X64-SSSE3-NEXT:    xorq -{{[0-9]+}}(%rsp), %rax
592; X64-SSSE3-NEXT:    retq
593  %1 = load x86_fp80, x86_fp80 *%a0
594  %2 = fptoui x86_fp80 %1 to i64
595  ret i64  %2
596}
597
598;
599; sitofp
600;
601
602define x86_fp80 @sitofp_fp80_i16(i16 %a0) nounwind {
603; X86-LABEL: sitofp_fp80_i16:
604; X86:       # %bb.0:
605; X86-NEXT:    pushl %eax
606; X86-NEXT:    movzwl {{[0-9]+}}(%esp), %eax
607; X86-NEXT:    movw %ax, {{[0-9]+}}(%esp)
608; X86-NEXT:    filds {{[0-9]+}}(%esp)
609; X86-NEXT:    popl %eax
610; X86-NEXT:    retl
611;
612; X64-LABEL: sitofp_fp80_i16:
613; X64:       # %bb.0:
614; X64-NEXT:    movw %di, -{{[0-9]+}}(%rsp)
615; X64-NEXT:    filds -{{[0-9]+}}(%rsp)
616; X64-NEXT:    retq
617  %1 = sitofp i16 %a0 to x86_fp80
618  ret x86_fp80 %1
619}
620
621define x86_fp80 @sitofp_fp80_i16_ld(i16 *%a0) nounwind {
622; X86-LABEL: sitofp_fp80_i16_ld:
623; X86:       # %bb.0:
624; X86-NEXT:    pushl %eax
625; X86-NEXT:    movl {{[0-9]+}}(%esp), %eax
626; X86-NEXT:    movzwl (%eax), %eax
627; X86-NEXT:    movw %ax, {{[0-9]+}}(%esp)
628; X86-NEXT:    filds {{[0-9]+}}(%esp)
629; X86-NEXT:    popl %eax
630; X86-NEXT:    retl
631;
632; X64-LABEL: sitofp_fp80_i16_ld:
633; X64:       # %bb.0:
634; X64-NEXT:    movzwl (%rdi), %eax
635; X64-NEXT:    movw %ax, -{{[0-9]+}}(%rsp)
636; X64-NEXT:    filds -{{[0-9]+}}(%rsp)
637; X64-NEXT:    retq
638  %1 = load i16, i16 *%a0
639  %2 = sitofp i16 %1 to x86_fp80
640  ret x86_fp80 %2
641}
642
643define x86_fp80 @sitofp_fp80_i32(i32 %a0) nounwind {
644; X86-LABEL: sitofp_fp80_i32:
645; X86:       # %bb.0:
646; X86-NEXT:    pushl %eax
647; X86-NEXT:    movl {{[0-9]+}}(%esp), %eax
648; X86-NEXT:    movl %eax, (%esp)
649; X86-NEXT:    fildl (%esp)
650; X86-NEXT:    popl %eax
651; X86-NEXT:    retl
652;
653; X64-LABEL: sitofp_fp80_i32:
654; X64:       # %bb.0:
655; X64-NEXT:    movl %edi, -{{[0-9]+}}(%rsp)
656; X64-NEXT:    fildl -{{[0-9]+}}(%rsp)
657; X64-NEXT:    retq
658  %1 = sitofp i32 %a0 to x86_fp80
659  ret x86_fp80 %1
660}
661
662define x86_fp80 @sitofp_fp80_i32_ld(i32 *%a0) nounwind {
663; X86-LABEL: sitofp_fp80_i32_ld:
664; X86:       # %bb.0:
665; X86-NEXT:    pushl %eax
666; X86-NEXT:    movl {{[0-9]+}}(%esp), %eax
667; X86-NEXT:    movl (%eax), %eax
668; X86-NEXT:    movl %eax, (%esp)
669; X86-NEXT:    fildl (%esp)
670; X86-NEXT:    popl %eax
671; X86-NEXT:    retl
672;
673; X64-LABEL: sitofp_fp80_i32_ld:
674; X64:       # %bb.0:
675; X64-NEXT:    movl (%rdi), %eax
676; X64-NEXT:    movl %eax, -{{[0-9]+}}(%rsp)
677; X64-NEXT:    fildl -{{[0-9]+}}(%rsp)
678; X64-NEXT:    retq
679  %1 = load i32, i32 *%a0
680  %2 = sitofp i32 %1 to x86_fp80
681  ret x86_fp80 %2
682}
683
684define x86_fp80 @sitofp_fp80_i64(i64 %a0) nounwind {
685; X86-LABEL: sitofp_fp80_i64:
686; X86:       # %bb.0:
687; X86-NEXT:    fildll {{[0-9]+}}(%esp)
688; X86-NEXT:    retl
689;
690; X64-LABEL: sitofp_fp80_i64:
691; X64:       # %bb.0:
692; X64-NEXT:    movq %rdi, -{{[0-9]+}}(%rsp)
693; X64-NEXT:    fildll -{{[0-9]+}}(%rsp)
694; X64-NEXT:    retq
695  %1 = sitofp i64 %a0 to x86_fp80
696  ret x86_fp80 %1
697}
698
699define x86_fp80 @sitofp_fp80_i64_ld(i64 *%a0) nounwind {
700; X86-LABEL: sitofp_fp80_i64_ld:
701; X86:       # %bb.0:
702; X86-NEXT:    movl {{[0-9]+}}(%esp), %eax
703; X86-NEXT:    fildll (%eax)
704; X86-NEXT:    retl
705;
706; X64-LABEL: sitofp_fp80_i64_ld:
707; X64:       # %bb.0:
708; X64-NEXT:    movq (%rdi), %rax
709; X64-NEXT:    movq %rax, -{{[0-9]+}}(%rsp)
710; X64-NEXT:    fildll -{{[0-9]+}}(%rsp)
711; X64-NEXT:    retq
712  %1 = load i64, i64 *%a0
713  %2 = sitofp i64 %1 to x86_fp80
714  ret x86_fp80 %2
715}
716
717;
718; uitofp
719;
720
721define x86_fp80 @uitofp_fp80_i16(i16 %a0) nounwind {
722; X86-LABEL: uitofp_fp80_i16:
723; X86:       # %bb.0:
724; X86-NEXT:    pushl %eax
725; X86-NEXT:    movzwl {{[0-9]+}}(%esp), %eax
726; X86-NEXT:    movl %eax, (%esp)
727; X86-NEXT:    fildl (%esp)
728; X86-NEXT:    popl %eax
729; X86-NEXT:    retl
730;
731; X64-LABEL: uitofp_fp80_i16:
732; X64:       # %bb.0:
733; X64-NEXT:    movzwl %di, %eax
734; X64-NEXT:    movl %eax, -{{[0-9]+}}(%rsp)
735; X64-NEXT:    fildl -{{[0-9]+}}(%rsp)
736; X64-NEXT:    retq
737  %1 = uitofp i16 %a0 to x86_fp80
738  ret x86_fp80 %1
739}
740
741define x86_fp80 @uitofp_fp80_i16_ld(i16 *%a0) nounwind {
742; X86-LABEL: uitofp_fp80_i16_ld:
743; X86:       # %bb.0:
744; X86-NEXT:    pushl %eax
745; X86-NEXT:    movl {{[0-9]+}}(%esp), %eax
746; X86-NEXT:    movzwl (%eax), %eax
747; X86-NEXT:    movl %eax, (%esp)
748; X86-NEXT:    fildl (%esp)
749; X86-NEXT:    popl %eax
750; X86-NEXT:    retl
751;
752; X64-LABEL: uitofp_fp80_i16_ld:
753; X64:       # %bb.0:
754; X64-NEXT:    movzwl (%rdi), %eax
755; X64-NEXT:    movl %eax, -{{[0-9]+}}(%rsp)
756; X64-NEXT:    fildl -{{[0-9]+}}(%rsp)
757; X64-NEXT:    retq
758  %1 = load i16, i16 *%a0
759  %2 = uitofp i16 %1 to x86_fp80
760  ret x86_fp80 %2
761}
762
763define x86_fp80 @uitofp_fp80_i32(i32 %a0) nounwind {
764; X86-LABEL: uitofp_fp80_i32:
765; X86:       # %bb.0:
766; X86-NEXT:    pushl %ebp
767; X86-NEXT:    movl %esp, %ebp
768; X86-NEXT:    andl $-8, %esp
769; X86-NEXT:    subl $8, %esp
770; X86-NEXT:    movl 8(%ebp), %eax
771; X86-NEXT:    movl %eax, (%esp)
772; X86-NEXT:    movl $0, {{[0-9]+}}(%esp)
773; X86-NEXT:    fildll (%esp)
774; X86-NEXT:    movl %ebp, %esp
775; X86-NEXT:    popl %ebp
776; X86-NEXT:    retl
777;
778; X64-LABEL: uitofp_fp80_i32:
779; X64:       # %bb.0:
780; X64-NEXT:    movl %edi, %eax
781; X64-NEXT:    movq %rax, -{{[0-9]+}}(%rsp)
782; X64-NEXT:    fildll -{{[0-9]+}}(%rsp)
783; X64-NEXT:    retq
784  %1 = uitofp i32 %a0 to x86_fp80
785  ret x86_fp80 %1
786}
787
788define x86_fp80 @uitofp_fp80_i32_ld(i32 *%a0) nounwind {
789; X86-LABEL: uitofp_fp80_i32_ld:
790; X86:       # %bb.0:
791; X86-NEXT:    pushl %ebp
792; X86-NEXT:    movl %esp, %ebp
793; X86-NEXT:    andl $-8, %esp
794; X86-NEXT:    subl $8, %esp
795; X86-NEXT:    movl 8(%ebp), %eax
796; X86-NEXT:    movl (%eax), %eax
797; X86-NEXT:    movl %eax, (%esp)
798; X86-NEXT:    movl $0, {{[0-9]+}}(%esp)
799; X86-NEXT:    fildll (%esp)
800; X86-NEXT:    movl %ebp, %esp
801; X86-NEXT:    popl %ebp
802; X86-NEXT:    retl
803;
804; X64-LABEL: uitofp_fp80_i32_ld:
805; X64:       # %bb.0:
806; X64-NEXT:    movl (%rdi), %eax
807; X64-NEXT:    movq %rax, -{{[0-9]+}}(%rsp)
808; X64-NEXT:    fildll -{{[0-9]+}}(%rsp)
809; X64-NEXT:    retq
810  %1 = load i32, i32 *%a0
811  %2 = uitofp i32 %1 to x86_fp80
812  ret x86_fp80 %2
813}
814
815define x86_fp80 @uitofp_fp80_i64(i64 %a0) nounwind {
816; X86-LABEL: uitofp_fp80_i64:
817; X86:       # %bb.0:
818; X86-NEXT:    pushl %ebp
819; X86-NEXT:    movl %esp, %ebp
820; X86-NEXT:    andl $-8, %esp
821; X86-NEXT:    subl $8, %esp
822; X86-NEXT:    movl 8(%ebp), %eax
823; X86-NEXT:    movl 12(%ebp), %ecx
824; X86-NEXT:    movl %ecx, {{[0-9]+}}(%esp)
825; X86-NEXT:    movl %eax, (%esp)
826; X86-NEXT:    shrl $31, %ecx
827; X86-NEXT:    fildll (%esp)
828; X86-NEXT:    fadds {{\.LCPI.*}}(,%ecx,4)
829; X86-NEXT:    movl %ebp, %esp
830; X86-NEXT:    popl %ebp
831; X86-NEXT:    retl
832;
833; X64-LABEL: uitofp_fp80_i64:
834; X64:       # %bb.0:
835; X64-NEXT:    movq %rdi, -{{[0-9]+}}(%rsp)
836; X64-NEXT:    xorl %eax, %eax
837; X64-NEXT:    testq %rdi, %rdi
838; X64-NEXT:    sets %al
839; X64-NEXT:    fildll -{{[0-9]+}}(%rsp)
840; X64-NEXT:    fadds {{\.LCPI.*}}(,%rax,4)
841; X64-NEXT:    retq
842  %1 = uitofp i64 %a0 to x86_fp80
843  ret x86_fp80 %1
844}
845
846define x86_fp80 @uitofp_fp80_i64_ld(i64 *%a0) nounwind {
847; X86-LABEL: uitofp_fp80_i64_ld:
848; X86:       # %bb.0:
849; X86-NEXT:    pushl %ebp
850; X86-NEXT:    movl %esp, %ebp
851; X86-NEXT:    andl $-8, %esp
852; X86-NEXT:    subl $8, %esp
853; X86-NEXT:    movl 8(%ebp), %eax
854; X86-NEXT:    movl (%eax), %ecx
855; X86-NEXT:    movl 4(%eax), %eax
856; X86-NEXT:    movl %eax, {{[0-9]+}}(%esp)
857; X86-NEXT:    movl %ecx, (%esp)
858; X86-NEXT:    shrl $31, %eax
859; X86-NEXT:    fildll (%esp)
860; X86-NEXT:    fadds {{\.LCPI.*}}(,%eax,4)
861; X86-NEXT:    movl %ebp, %esp
862; X86-NEXT:    popl %ebp
863; X86-NEXT:    retl
864;
865; X64-LABEL: uitofp_fp80_i64_ld:
866; X64:       # %bb.0:
867; X64-NEXT:    movq (%rdi), %rax
868; X64-NEXT:    movq %rax, -{{[0-9]+}}(%rsp)
869; X64-NEXT:    xorl %ecx, %ecx
870; X64-NEXT:    testq %rax, %rax
871; X64-NEXT:    sets %cl
872; X64-NEXT:    fildll -{{[0-9]+}}(%rsp)
873; X64-NEXT:    fadds {{\.LCPI.*}}(,%rcx,4)
874; X64-NEXT:    retq
875  %1 = load i64, i64 *%a0
876  %2 = uitofp i64 %1 to x86_fp80
877  ret x86_fp80 %2
878}
879
880;
881; floor
882;
883
884define x86_fp80 @floor_fp80(x86_fp80 %a0) nounwind {
885; X86-LABEL: floor_fp80:
886; X86:       # %bb.0:
887; X86-NEXT:    subl $12, %esp
888; X86-NEXT:    fldt {{[0-9]+}}(%esp)
889; X86-NEXT:    fstpt (%esp)
890; X86-NEXT:    calll floorl
891; X86-NEXT:    addl $12, %esp
892; X86-NEXT:    retl
893;
894; X64-LABEL: floor_fp80:
895; X64:       # %bb.0:
896; X64-NEXT:    subq $24, %rsp
897; X64-NEXT:    fldt {{[0-9]+}}(%rsp)
898; X64-NEXT:    fstpt (%rsp)
899; X64-NEXT:    callq floorl
900; X64-NEXT:    addq $24, %rsp
901; X64-NEXT:    retq
902  %1 = call x86_fp80 @llvm.floor.f80(x86_fp80 %a0)
903  ret x86_fp80 %1
904}
905
906define x86_fp80 @floor_fp80_ld(x86_fp80 *%a0) nounwind {
907; X86-LABEL: floor_fp80_ld:
908; X86:       # %bb.0:
909; X86-NEXT:    subl $12, %esp
910; X86-NEXT:    movl {{[0-9]+}}(%esp), %eax
911; X86-NEXT:    fldt (%eax)
912; X86-NEXT:    fstpt (%esp)
913; X86-NEXT:    calll floorl
914; X86-NEXT:    addl $12, %esp
915; X86-NEXT:    retl
916;
917; X64-LABEL: floor_fp80_ld:
918; X64:       # %bb.0:
919; X64-NEXT:    subq $24, %rsp
920; X64-NEXT:    fldt (%rdi)
921; X64-NEXT:    fstpt (%rsp)
922; X64-NEXT:    callq floorl
923; X64-NEXT:    addq $24, %rsp
924; X64-NEXT:    retq
925  %1 = load x86_fp80, x86_fp80 *%a0
926  %2 = call x86_fp80 @llvm.floor.f80(x86_fp80 %1)
927  ret x86_fp80 %2
928}
929
930declare x86_fp80 @llvm.floor.f80(x86_fp80 %p)
931
932;
933; ceil
934;
935
936define x86_fp80 @ceil_fp80(x86_fp80 %a0) nounwind {
937; X86-LABEL: ceil_fp80:
938; X86:       # %bb.0:
939; X86-NEXT:    subl $12, %esp
940; X86-NEXT:    fldt {{[0-9]+}}(%esp)
941; X86-NEXT:    fstpt (%esp)
942; X86-NEXT:    calll ceill
943; X86-NEXT:    addl $12, %esp
944; X86-NEXT:    retl
945;
946; X64-LABEL: ceil_fp80:
947; X64:       # %bb.0:
948; X64-NEXT:    subq $24, %rsp
949; X64-NEXT:    fldt {{[0-9]+}}(%rsp)
950; X64-NEXT:    fstpt (%rsp)
951; X64-NEXT:    callq ceill
952; X64-NEXT:    addq $24, %rsp
953; X64-NEXT:    retq
954  %1 = call x86_fp80 @llvm.ceil.f80(x86_fp80 %a0)
955  ret x86_fp80 %1
956}
957
958define x86_fp80 @ceil_fp80_ld(x86_fp80 *%a0) nounwind {
959; X86-LABEL: ceil_fp80_ld:
960; X86:       # %bb.0:
961; X86-NEXT:    subl $12, %esp
962; X86-NEXT:    movl {{[0-9]+}}(%esp), %eax
963; X86-NEXT:    fldt (%eax)
964; X86-NEXT:    fstpt (%esp)
965; X86-NEXT:    calll ceill
966; X86-NEXT:    addl $12, %esp
967; X86-NEXT:    retl
968;
969; X64-LABEL: ceil_fp80_ld:
970; X64:       # %bb.0:
971; X64-NEXT:    subq $24, %rsp
972; X64-NEXT:    fldt (%rdi)
973; X64-NEXT:    fstpt (%rsp)
974; X64-NEXT:    callq ceill
975; X64-NEXT:    addq $24, %rsp
976; X64-NEXT:    retq
977  %1 = load x86_fp80, x86_fp80 *%a0
978  %2 = call x86_fp80 @llvm.ceil.f80(x86_fp80 %1)
979  ret x86_fp80 %2
980}
981
982declare x86_fp80 @llvm.ceil.f80(x86_fp80 %p)
983
984;
985; trunc
986;
987
988define x86_fp80 @trunc_fp80(x86_fp80 %a0) nounwind {
989; X86-LABEL: trunc_fp80:
990; X86:       # %bb.0:
991; X86-NEXT:    subl $12, %esp
992; X86-NEXT:    fldt {{[0-9]+}}(%esp)
993; X86-NEXT:    fstpt (%esp)
994; X86-NEXT:    calll truncl
995; X86-NEXT:    addl $12, %esp
996; X86-NEXT:    retl
997;
998; X64-LABEL: trunc_fp80:
999; X64:       # %bb.0:
1000; X64-NEXT:    subq $24, %rsp
1001; X64-NEXT:    fldt {{[0-9]+}}(%rsp)
1002; X64-NEXT:    fstpt (%rsp)
1003; X64-NEXT:    callq truncl
1004; X64-NEXT:    addq $24, %rsp
1005; X64-NEXT:    retq
1006  %1 = call x86_fp80 @llvm.trunc.f80(x86_fp80 %a0)
1007  ret x86_fp80 %1
1008}
1009
1010define x86_fp80 @trunc_fp80_ld(x86_fp80 *%a0) nounwind {
1011; X86-LABEL: trunc_fp80_ld:
1012; X86:       # %bb.0:
1013; X86-NEXT:    subl $12, %esp
1014; X86-NEXT:    movl {{[0-9]+}}(%esp), %eax
1015; X86-NEXT:    fldt (%eax)
1016; X86-NEXT:    fstpt (%esp)
1017; X86-NEXT:    calll truncl
1018; X86-NEXT:    addl $12, %esp
1019; X86-NEXT:    retl
1020;
1021; X64-LABEL: trunc_fp80_ld:
1022; X64:       # %bb.0:
1023; X64-NEXT:    subq $24, %rsp
1024; X64-NEXT:    fldt (%rdi)
1025; X64-NEXT:    fstpt (%rsp)
1026; X64-NEXT:    callq truncl
1027; X64-NEXT:    addq $24, %rsp
1028; X64-NEXT:    retq
1029  %1 = load x86_fp80, x86_fp80 *%a0
1030  %2 = call x86_fp80 @llvm.trunc.f80(x86_fp80 %1)
1031  ret x86_fp80 %2
1032}
1033
1034declare x86_fp80 @llvm.trunc.f80(x86_fp80 %p)
1035
1036;
1037; rint
1038;
1039
1040define x86_fp80 @rint_fp80(x86_fp80 %a0) nounwind {
1041; X86-LABEL: rint_fp80:
1042; X86:       # %bb.0:
1043; X86-NEXT:    subl $12, %esp
1044; X86-NEXT:    fldt {{[0-9]+}}(%esp)
1045; X86-NEXT:    fstpt (%esp)
1046; X86-NEXT:    calll rintl
1047; X86-NEXT:    addl $12, %esp
1048; X86-NEXT:    retl
1049;
1050; X64-LABEL: rint_fp80:
1051; X64:       # %bb.0:
1052; X64-NEXT:    subq $24, %rsp
1053; X64-NEXT:    fldt {{[0-9]+}}(%rsp)
1054; X64-NEXT:    fstpt (%rsp)
1055; X64-NEXT:    callq rintl
1056; X64-NEXT:    addq $24, %rsp
1057; X64-NEXT:    retq
1058  %1 = call x86_fp80 @llvm.rint.f80(x86_fp80 %a0)
1059  ret x86_fp80 %1
1060}
1061
1062define x86_fp80 @rint_fp80_ld(x86_fp80 *%a0) nounwind {
1063; X86-LABEL: rint_fp80_ld:
1064; X86:       # %bb.0:
1065; X86-NEXT:    subl $12, %esp
1066; X86-NEXT:    movl {{[0-9]+}}(%esp), %eax
1067; X86-NEXT:    fldt (%eax)
1068; X86-NEXT:    fstpt (%esp)
1069; X86-NEXT:    calll rintl
1070; X86-NEXT:    addl $12, %esp
1071; X86-NEXT:    retl
1072;
1073; X64-LABEL: rint_fp80_ld:
1074; X64:       # %bb.0:
1075; X64-NEXT:    subq $24, %rsp
1076; X64-NEXT:    fldt (%rdi)
1077; X64-NEXT:    fstpt (%rsp)
1078; X64-NEXT:    callq rintl
1079; X64-NEXT:    addq $24, %rsp
1080; X64-NEXT:    retq
1081  %1 = load x86_fp80, x86_fp80 *%a0
1082  %2 = call x86_fp80 @llvm.rint.f80(x86_fp80 %1)
1083  ret x86_fp80 %2
1084}
1085
1086declare x86_fp80 @llvm.rint.f80(x86_fp80 %p)
1087
1088;
1089; roundeven
1090;
1091
1092define x86_fp80 @roundeven_fp80(x86_fp80 %a0) nounwind {
1093; X86-LABEL: roundeven_fp80:
1094; X86:       # %bb.0:
1095; X86-NEXT:    subl $12, %esp
1096; X86-NEXT:    fldt {{[0-9]+}}(%esp)
1097; X86-NEXT:    fstpt (%esp)
1098; X86-NEXT:    calll roundevenl
1099; X86-NEXT:    addl $12, %esp
1100; X86-NEXT:    retl
1101;
1102; X64-LABEL: roundeven_fp80:
1103; X64:       # %bb.0:
1104; X64-NEXT:    subq $24, %rsp
1105; X64-NEXT:    fldt {{[0-9]+}}(%rsp)
1106; X64-NEXT:    fstpt (%rsp)
1107; X64-NEXT:    callq roundevenl
1108; X64-NEXT:    addq $24, %rsp
1109; X64-NEXT:    retq
1110  %1 = call x86_fp80 @llvm.roundeven.f80(x86_fp80 %a0)
1111  ret x86_fp80 %1
1112}
1113
1114define x86_fp80 @roundeven_fp80_ld(x86_fp80 *%a0) nounwind {
1115; X86-LABEL: roundeven_fp80_ld:
1116; X86:       # %bb.0:
1117; X86-NEXT:    subl $12, %esp
1118; X86-NEXT:    movl {{[0-9]+}}(%esp), %eax
1119; X86-NEXT:    fldt (%eax)
1120; X86-NEXT:    fstpt (%esp)
1121; X86-NEXT:    calll roundevenl
1122; X86-NEXT:    addl $12, %esp
1123; X86-NEXT:    retl
1124;
1125; X64-LABEL: roundeven_fp80_ld:
1126; X64:       # %bb.0:
1127; X64-NEXT:    subq $24, %rsp
1128; X64-NEXT:    fldt (%rdi)
1129; X64-NEXT:    fstpt (%rsp)
1130; X64-NEXT:    callq roundevenl
1131; X64-NEXT:    addq $24, %rsp
1132; X64-NEXT:    retq
1133  %1 = load x86_fp80, x86_fp80 *%a0
1134  %2 = call x86_fp80 @llvm.roundeven.f80(x86_fp80 %1)
1135  ret x86_fp80 %2
1136}
1137
1138declare x86_fp80 @llvm.roundeven.f80(x86_fp80 %p)
1139