1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc -mtriple=i686-unknown-linux-gnu -mattr=-sse -verify-machineinstrs < %s | FileCheck %s -check-prefix=X86-NOSSE
3 ; RUN: llc -mtriple=i686-unknown-linux-gnu -mattr=+sse -verify-machineinstrs < %s | FileCheck %s -check-prefix=X86-SSE
4 ; RUN: llc -mtriple=x86_64-unknown-linux-gnu -verify-machineinstrs < %s | FileCheck %s -check-prefix=X64
6 declare void @llvm.set.rounding(i32 %x)
8 define void @func_01() nounwind {
9 ; X86-NOSSE-LABEL: func_01:
11 ; X86-NOSSE-NEXT: pushl %eax
12 ; X86-NOSSE-NEXT: fnstcw (%esp)
13 ; X86-NOSSE-NEXT: orb $12, {{[0-9]+}}(%esp)
14 ; X86-NOSSE-NEXT: fldcw (%esp)
15 ; X86-NOSSE-NEXT: popl %eax
16 ; X86-NOSSE-NEXT: retl
18 ; X86-SSE-LABEL: func_01:
20 ; X86-SSE-NEXT: pushl %eax
21 ; X86-SSE-NEXT: fnstcw (%esp)
22 ; X86-SSE-NEXT: orb $12, {{[0-9]+}}(%esp)
23 ; X86-SSE-NEXT: fldcw (%esp)
24 ; X86-SSE-NEXT: stmxcsr (%esp)
25 ; X86-SSE-NEXT: orb $96, {{[0-9]+}}(%esp)
26 ; X86-SSE-NEXT: ldmxcsr (%esp)
27 ; X86-SSE-NEXT: popl %eax
32 ; X64-NEXT: fnstcw -{{[0-9]+}}(%rsp)
33 ; X64-NEXT: orb $12, -{{[0-9]+}}(%rsp)
34 ; X64-NEXT: fldcw -{{[0-9]+}}(%rsp)
35 ; X64-NEXT: stmxcsr -{{[0-9]+}}(%rsp)
36 ; X64-NEXT: orb $96, -{{[0-9]+}}(%rsp)
37 ; X64-NEXT: ldmxcsr -{{[0-9]+}}(%rsp)
39 call void @llvm.set.rounding(i32 0) ; TowardZero (CW[11-10] = 11)
43 define void @func_02() nounwind {
44 ; X86-NOSSE-LABEL: func_02:
46 ; X86-NOSSE-NEXT: pushl %eax
47 ; X86-NOSSE-NEXT: fnstcw (%esp)
48 ; X86-NOSSE-NEXT: andb $-13, {{[0-9]+}}(%esp)
49 ; X86-NOSSE-NEXT: fldcw (%esp)
50 ; X86-NOSSE-NEXT: popl %eax
51 ; X86-NOSSE-NEXT: retl
53 ; X86-SSE-LABEL: func_02:
55 ; X86-SSE-NEXT: pushl %eax
56 ; X86-SSE-NEXT: fnstcw (%esp)
57 ; X86-SSE-NEXT: andb $-13, {{[0-9]+}}(%esp)
58 ; X86-SSE-NEXT: fldcw (%esp)
59 ; X86-SSE-NEXT: stmxcsr (%esp)
60 ; X86-SSE-NEXT: andb $-97, {{[0-9]+}}(%esp)
61 ; X86-SSE-NEXT: ldmxcsr (%esp)
62 ; X86-SSE-NEXT: popl %eax
67 ; X64-NEXT: fnstcw -{{[0-9]+}}(%rsp)
68 ; X64-NEXT: andb $-13, -{{[0-9]+}}(%rsp)
69 ; X64-NEXT: fldcw -{{[0-9]+}}(%rsp)
70 ; X64-NEXT: stmxcsr -{{[0-9]+}}(%rsp)
71 ; X64-NEXT: andb $-97, -{{[0-9]+}}(%rsp)
72 ; X64-NEXT: ldmxcsr -{{[0-9]+}}(%rsp)
74 call void @llvm.set.rounding(i32 1) ; ToNearestTiesToEven (CW[11-10] = 00)
78 define void @func_03() nounwind {
79 ; X86-NOSSE-LABEL: func_03:
81 ; X86-NOSSE-NEXT: pushl %eax
82 ; X86-NOSSE-NEXT: fnstcw (%esp)
83 ; X86-NOSSE-NEXT: movl $-3073, %eax # imm = 0xF3FF
84 ; X86-NOSSE-NEXT: andl (%esp), %eax
85 ; X86-NOSSE-NEXT: orl $2048, %eax # imm = 0x800
86 ; X86-NOSSE-NEXT: movw %ax, (%esp)
87 ; X86-NOSSE-NEXT: fldcw (%esp)
88 ; X86-NOSSE-NEXT: popl %eax
89 ; X86-NOSSE-NEXT: retl
91 ; X86-SSE-LABEL: func_03:
93 ; X86-SSE-NEXT: pushl %eax
94 ; X86-SSE-NEXT: fnstcw (%esp)
95 ; X86-SSE-NEXT: movl $-3073, %eax # imm = 0xF3FF
96 ; X86-SSE-NEXT: andl (%esp), %eax
97 ; X86-SSE-NEXT: orl $2048, %eax # imm = 0x800
98 ; X86-SSE-NEXT: movw %ax, (%esp)
99 ; X86-SSE-NEXT: fldcw (%esp)
100 ; X86-SSE-NEXT: stmxcsr (%esp)
101 ; X86-SSE-NEXT: movl $-24577, %eax # imm = 0x9FFF
102 ; X86-SSE-NEXT: andl (%esp), %eax
103 ; X86-SSE-NEXT: orl $16384, %eax # imm = 0x4000
104 ; X86-SSE-NEXT: movl %eax, (%esp)
105 ; X86-SSE-NEXT: ldmxcsr (%esp)
106 ; X86-SSE-NEXT: popl %eax
109 ; X64-LABEL: func_03:
111 ; X64-NEXT: fnstcw -{{[0-9]+}}(%rsp)
112 ; X64-NEXT: movl $-3073, %eax # imm = 0xF3FF
113 ; X64-NEXT: andl -{{[0-9]+}}(%rsp), %eax
114 ; X64-NEXT: orl $2048, %eax # imm = 0x800
115 ; X64-NEXT: movw %ax, -{{[0-9]+}}(%rsp)
116 ; X64-NEXT: fldcw -{{[0-9]+}}(%rsp)
117 ; X64-NEXT: stmxcsr -{{[0-9]+}}(%rsp)
118 ; X64-NEXT: movl $-24577, %eax # imm = 0x9FFF
119 ; X64-NEXT: andl -{{[0-9]+}}(%rsp), %eax
120 ; X64-NEXT: orl $16384, %eax # imm = 0x4000
121 ; X64-NEXT: movl %eax, -{{[0-9]+}}(%rsp)
122 ; X64-NEXT: ldmxcsr -{{[0-9]+}}(%rsp)
124 call void @llvm.set.rounding(i32 2) ; Upward (CW[11-10] = 10)
128 define void @func_04() nounwind {
129 ; X86-NOSSE-LABEL: func_04:
130 ; X86-NOSSE: # %bb.0:
131 ; X86-NOSSE-NEXT: pushl %eax
132 ; X86-NOSSE-NEXT: fnstcw (%esp)
133 ; X86-NOSSE-NEXT: movl $-3073, %eax # imm = 0xF3FF
134 ; X86-NOSSE-NEXT: andl (%esp), %eax
135 ; X86-NOSSE-NEXT: orl $1024, %eax # imm = 0x400
136 ; X86-NOSSE-NEXT: movw %ax, (%esp)
137 ; X86-NOSSE-NEXT: fldcw (%esp)
138 ; X86-NOSSE-NEXT: popl %eax
139 ; X86-NOSSE-NEXT: retl
141 ; X86-SSE-LABEL: func_04:
143 ; X86-SSE-NEXT: pushl %eax
144 ; X86-SSE-NEXT: fnstcw (%esp)
145 ; X86-SSE-NEXT: movl $-3073, %eax # imm = 0xF3FF
146 ; X86-SSE-NEXT: andl (%esp), %eax
147 ; X86-SSE-NEXT: orl $1024, %eax # imm = 0x400
148 ; X86-SSE-NEXT: movw %ax, (%esp)
149 ; X86-SSE-NEXT: fldcw (%esp)
150 ; X86-SSE-NEXT: stmxcsr (%esp)
151 ; X86-SSE-NEXT: movl $-24577, %eax # imm = 0x9FFF
152 ; X86-SSE-NEXT: andl (%esp), %eax
153 ; X86-SSE-NEXT: orl $8192, %eax # imm = 0x2000
154 ; X86-SSE-NEXT: movl %eax, (%esp)
155 ; X86-SSE-NEXT: ldmxcsr (%esp)
156 ; X86-SSE-NEXT: popl %eax
159 ; X64-LABEL: func_04:
161 ; X64-NEXT: fnstcw -{{[0-9]+}}(%rsp)
162 ; X64-NEXT: movl $-3073, %eax # imm = 0xF3FF
163 ; X64-NEXT: andl -{{[0-9]+}}(%rsp), %eax
164 ; X64-NEXT: orl $1024, %eax # imm = 0x400
165 ; X64-NEXT: movw %ax, -{{[0-9]+}}(%rsp)
166 ; X64-NEXT: fldcw -{{[0-9]+}}(%rsp)
167 ; X64-NEXT: stmxcsr -{{[0-9]+}}(%rsp)
168 ; X64-NEXT: movl $-24577, %eax # imm = 0x9FFF
169 ; X64-NEXT: andl -{{[0-9]+}}(%rsp), %eax
170 ; X64-NEXT: orl $8192, %eax # imm = 0x2000
171 ; X64-NEXT: movl %eax, -{{[0-9]+}}(%rsp)
172 ; X64-NEXT: ldmxcsr -{{[0-9]+}}(%rsp)
174 call void @llvm.set.rounding(i32 3) ; Downward (CW[11-10] = 01)
178 define void @func_05(i32 %x) nounwind {
179 ; X86-NOSSE-LABEL: func_05:
180 ; X86-NOSSE: # %bb.0:
181 ; X86-NOSSE-NEXT: pushl %eax
182 ; X86-NOSSE-NEXT: movl {{[0-9]+}}(%esp), %eax
183 ; X86-NOSSE-NEXT: leal 4(%eax,%eax), %ecx
184 ; X86-NOSSE-NEXT: movl $201, %eax
185 ; X86-NOSSE-NEXT: # kill: def $cl killed $cl killed $ecx
186 ; X86-NOSSE-NEXT: shll %cl, %eax
187 ; X86-NOSSE-NEXT: andl $3072, %eax # imm = 0xC00
188 ; X86-NOSSE-NEXT: fnstcw (%esp)
189 ; X86-NOSSE-NEXT: movl $-3073, %ecx # imm = 0xF3FF
190 ; X86-NOSSE-NEXT: andl (%esp), %ecx
191 ; X86-NOSSE-NEXT: orl %eax, %ecx
192 ; X86-NOSSE-NEXT: movw %cx, (%esp)
193 ; X86-NOSSE-NEXT: fldcw (%esp)
194 ; X86-NOSSE-NEXT: popl %eax
195 ; X86-NOSSE-NEXT: retl
197 ; X86-SSE-LABEL: func_05:
199 ; X86-SSE-NEXT: pushl %eax
200 ; X86-SSE-NEXT: movl {{[0-9]+}}(%esp), %eax
201 ; X86-SSE-NEXT: leal 4(%eax,%eax), %ecx
202 ; X86-SSE-NEXT: movl $201, %eax
203 ; X86-SSE-NEXT: # kill: def $cl killed $cl killed $ecx
204 ; X86-SSE-NEXT: shll %cl, %eax
205 ; X86-SSE-NEXT: andl $3072, %eax # imm = 0xC00
206 ; X86-SSE-NEXT: fnstcw (%esp)
207 ; X86-SSE-NEXT: movl $-3073, %ecx # imm = 0xF3FF
208 ; X86-SSE-NEXT: andl (%esp), %ecx
209 ; X86-SSE-NEXT: orl %eax, %ecx
210 ; X86-SSE-NEXT: movw %cx, (%esp)
211 ; X86-SSE-NEXT: fldcw (%esp)
212 ; X86-SSE-NEXT: stmxcsr (%esp)
213 ; X86-SSE-NEXT: movl $-24577, %ecx # imm = 0x9FFF
214 ; X86-SSE-NEXT: andl (%esp), %ecx
215 ; X86-SSE-NEXT: leal (%ecx,%eax,8), %eax
216 ; X86-SSE-NEXT: movl %eax, (%esp)
217 ; X86-SSE-NEXT: ldmxcsr (%esp)
218 ; X86-SSE-NEXT: popl %eax
221 ; X64-LABEL: func_05:
223 ; X64-NEXT: # kill: def $edi killed $edi def $rdi
224 ; X64-NEXT: leal 4(%rdi,%rdi), %ecx
225 ; X64-NEXT: movl $201, %eax
226 ; X64-NEXT: # kill: def $cl killed $cl killed $ecx
227 ; X64-NEXT: shll %cl, %eax
228 ; X64-NEXT: andl $3072, %eax # imm = 0xC00
229 ; X64-NEXT: fnstcw -{{[0-9]+}}(%rsp)
230 ; X64-NEXT: movl $-3073, %ecx # imm = 0xF3FF
231 ; X64-NEXT: andl -{{[0-9]+}}(%rsp), %ecx
232 ; X64-NEXT: orl %eax, %ecx
233 ; X64-NEXT: movw %cx, -{{[0-9]+}}(%rsp)
234 ; X64-NEXT: fldcw -{{[0-9]+}}(%rsp)
235 ; X64-NEXT: stmxcsr -{{[0-9]+}}(%rsp)
236 ; X64-NEXT: movl $-24577, %ecx # imm = 0x9FFF
237 ; X64-NEXT: andl -{{[0-9]+}}(%rsp), %ecx
238 ; X64-NEXT: leal (%rcx,%rax,8), %eax
239 ; X64-NEXT: movl %eax, -{{[0-9]+}}(%rsp)
240 ; X64-NEXT: ldmxcsr -{{[0-9]+}}(%rsp)
242 call void @llvm.set.rounding(i32 %x) ; Downward