1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: sed -e "s/SETROUND/ldmxcsr/g" %s | llc -mtriple=x86_64-pc-linux - | FileCheck %s --check-prefix=X64
3 ; RUN: sed -e "s/SETROUND/fldcw/g" %s | llc -mtriple=i686-pc-linux - | FileCheck %s --check-prefix=X86
5 define double @foo(double %0) #0 {
8 ; X64-NEXT: subq $24, %rsp
9 ; X64-NEXT: movsd %xmm0, (%rsp) # 8-byte Spill
10 ; X64-NEXT: movl $1024, %edi # imm = 0x400
11 ; X64-NEXT: callq fesetround@PLT
12 ; X64-NEXT: movsd {{.*#+}} xmm1 = [1.0E+0,0.0E+0]
13 ; X64-NEXT: divsd (%rsp), %xmm1 # 8-byte Folded Reload
14 ; X64-NEXT: movsd %xmm1, {{[-0-9]+}}(%r{{[sb]}}p) # 8-byte Spill
15 ; X64-NEXT: movl $1024, %edi # imm = 0x400
16 ; X64-NEXT: callq fesetround@PLT
17 ; X64-NEXT: movsd {{.*#+}} xmm0 = [1.0E+0,0.0E+0]
18 ; X64-NEXT: divsd (%rsp), %xmm0 # 8-byte Folded Reload
19 ; X64-NEXT: movsd %xmm0, {{[-0-9]+}}(%r{{[sb]}}p) # 8-byte Spill
20 ; X64-NEXT: movl $1024, %edi # imm = 0x400
21 ; X64-NEXT: callq fesetround@PLT
22 ; X64-NEXT: movsd {{.*#+}} xmm2 = [1.0E+0,0.0E+0]
23 ; X64-NEXT: divsd (%rsp), %xmm2 # 8-byte Folded Reload
24 ; X64-NEXT: movsd {{[-0-9]+}}(%r{{[sb]}}p), %xmm0 # 8-byte Reload
25 ; X64-NEXT: # xmm0 = mem[0],zero
26 ; X64-NEXT: movsd {{[-0-9]+}}(%r{{[sb]}}p), %xmm1 # 8-byte Reload
27 ; X64-NEXT: # xmm1 = mem[0],zero
28 ; X64-NEXT: callq fma@PLT
29 ; X64-NEXT: addq $24, %rsp
34 ; X86-NEXT: subl $60, %esp
35 ; X86-NEXT: fldl {{[0-9]+}}(%esp)
36 ; X86-NEXT: fstpl {{[-0-9]+}}(%e{{[sb]}}p) # 8-byte Folded Spill
38 ; X86-NEXT: movl $1024, (%esp) # imm = 0x400
39 ; X86-NEXT: calll fesetround@PLT
41 ; X86-NEXT: fstl {{[-0-9]+}}(%e{{[sb]}}p) # 8-byte Folded Spill
42 ; X86-NEXT: fldl {{[-0-9]+}}(%e{{[sb]}}p) # 8-byte Folded Reload
43 ; X86-NEXT: fdivrp %st, %st(1)
44 ; X86-NEXT: fstpl {{[-0-9]+}}(%e{{[sb]}}p) # 8-byte Folded Spill
46 ; X86-NEXT: movl $1024, (%esp) # imm = 0x400
47 ; X86-NEXT: calll fesetround@PLT
48 ; X86-NEXT: fldl {{[-0-9]+}}(%e{{[sb]}}p) # 8-byte Folded Reload
49 ; X86-NEXT: fldl {{[-0-9]+}}(%e{{[sb]}}p) # 8-byte Folded Reload
50 ; X86-NEXT: fdivp %st, %st(1)
51 ; X86-NEXT: fstpl {{[-0-9]+}}(%e{{[sb]}}p) # 8-byte Folded Spill
53 ; X86-NEXT: movl $1024, (%esp) # imm = 0x400
54 ; X86-NEXT: calll fesetround@PLT
55 ; X86-NEXT: fldl {{[-0-9]+}}(%e{{[sb]}}p) # 8-byte Folded Reload
56 ; X86-NEXT: fldl {{[-0-9]+}}(%e{{[sb]}}p) # 8-byte Folded Reload
57 ; X86-NEXT: fdivp %st, %st(1)
58 ; X86-NEXT: fstpl {{[0-9]+}}(%esp)
59 ; X86-NEXT: fldl {{[-0-9]+}}(%e{{[sb]}}p) # 8-byte Folded Reload
60 ; X86-NEXT: fstpl {{[0-9]+}}(%esp)
61 ; X86-NEXT: fldl {{[-0-9]+}}(%e{{[sb]}}p) # 8-byte Folded Reload
62 ; X86-NEXT: fstpl (%esp)
65 ; X86-NEXT: addl $60, %esp
67 %2 = call i32 @fesetround(i32 noundef 1024)
68 %3 = call double @llvm.experimental.constrained.fdiv.f64(double 1.000000e+00, double %0, metadata !"round.dynamic", metadata !"fpexcept.ignore") #0
69 %4 = call i32 @fesetround(i32 noundef 1024)
70 %5 = call double @llvm.experimental.constrained.fdiv.f64(double 1.000000e+00, double %0, metadata !"round.dynamic", metadata !"fpexcept.ignore") #0
71 %6 = call i32 @fesetround(i32 noundef 1024)
72 %7 = call double @llvm.experimental.constrained.fdiv.f64(double 1.000000e+00, double %0, metadata !"round.dynamic", metadata !"fpexcept.ignore") #0
73 %8 = call double @llvm.experimental.constrained.fma.f64(double %3, double %5, double %7, metadata !"round.dynamic", metadata !"fpexcept.ignore") #0
77 define double @bar(double %0) #0 {
80 ; X64-NEXT: pushq %rax
84 ; X64-NEXT: movsd {{.*#+}} xmm2 = [1.0E+0,0.0E+0]
85 ; X64-NEXT: movapd %xmm2, %xmm3
86 ; X64-NEXT: divsd %xmm0, %xmm3
90 ; X64-NEXT: movapd %xmm2, %xmm1
91 ; X64-NEXT: divsd %xmm0, %xmm1
95 ; X64-NEXT: divsd %xmm0, %xmm2
96 ; X64-NEXT: movapd %xmm3, %xmm0
97 ; X64-NEXT: callq fma@PLT
103 ; X86-NEXT: subl $28, %esp
104 ; X86-NEXT: fldl {{[0-9]+}}(%esp)
110 ; X86-NEXT: fld %st(0)
111 ; X86-NEXT: fdiv %st(2), %st
115 ; X86-NEXT: fld %st(1)
116 ; X86-NEXT: fdiv %st(3), %st
120 ; X86-NEXT: fxch %st(2)
121 ; X86-NEXT: fdivp %st, %st(3)
122 ; X86-NEXT: fxch %st(2)
123 ; X86-NEXT: fstpl {{[0-9]+}}(%esp)
124 ; X86-NEXT: fstpl {{[0-9]+}}(%esp)
125 ; X86-NEXT: fstpl (%esp)
127 ; X86-NEXT: calll fma
128 ; X86-NEXT: addl $28, %esp
130 call void asm sideeffect "SETROUND $0", "*m,~{dirflag},~{fpsr},~{flags}"(ptr elementtype(i32) null)
131 %2 = call double @llvm.experimental.constrained.fdiv.f64(double 1.000000e+00, double %0, metadata !"round.dynamic", metadata !"fpexcept.ignore") #0
132 call void asm sideeffect "SETROUND $0", "*m,~{dirflag},~{fpsr},~{flags}"(ptr elementtype(i32) null)
133 %3 = call double @llvm.experimental.constrained.fdiv.f64(double 1.000000e+00, double %0, metadata !"round.dynamic", metadata !"fpexcept.ignore") #0
134 call void asm sideeffect "SETROUND $0", "*m,~{dirflag},~{fpsr},~{flags}"(ptr elementtype(i32) null)
135 %4 = call double @llvm.experimental.constrained.fdiv.f64(double 1.000000e+00, double %0, metadata !"round.dynamic", metadata !"fpexcept.ignore") #0
136 %5 = call double @llvm.experimental.constrained.fma.f64(double %2, double %3, double %4, metadata !"round.dynamic", metadata !"fpexcept.ignore") #0
140 declare i32 @fesetround(i32) #0
141 declare double @llvm.experimental.constrained.fdiv.f64(double, double, metadata, metadata) #0
142 declare double @llvm.experimental.constrained.fma.f64(double, double, double, metadata, metadata) #0
144 attributes #0 = { nounwind strictfp }