1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc -mtriple=x86_64-apple-darwin -fast-isel -code-model=small < %s | FileCheck %s
3 ; RUN: llc -mtriple=x86_64-apple-darwin -fast-isel -code-model=medium < %s | FileCheck %s
4 ; RUN: llc -mtriple=x86_64-apple-darwin -fast-isel -code-model=large < %s | FileCheck %s --check-prefix=LARGE
5 ; RUN: llc -mtriple=x86_64 -fast-isel -code-model=large -relocation-model=pic < %s | FileCheck %s --check-prefix=LARGE_PIC
6 ; RUN: llc -mtriple=x86_64-apple-darwin -fast-isel -code-model=small -mattr=avx < %s | FileCheck %s --check-prefix=AVX
7 ; RUN: llc -mtriple=x86_64-apple-darwin -fast-isel -code-model=large -mattr=avx < %s | FileCheck %s --check-prefix=LARGE_AVX
8 ; RUN: llc -mtriple=x86_64-apple-darwin -fast-isel -code-model=small -mattr=avx512f < %s | FileCheck %s --check-prefix=AVX
9 ; RUN: llc -mtriple=x86_64-apple-darwin -fast-isel -code-model=large -mattr=avx512f < %s | FileCheck %s --check-prefix=LARGE_AVX
11 ; This large code mode shouldn't mean anything on x86 but it used to
12 ; generate 64-bit only instructions and asserted in the encoder.
13 ; -show-mc-encoding here to assert if this breaks again.
14 ; RUN: llc -mtriple=i686-apple-darwin -fast-isel -code-model=large -mattr=sse2 -show-mc-encoding < %s | FileCheck %s --check-prefix=X86-LARGE
16 ; Make sure fast isel uses rip-relative addressing for the small code model.
17 define float @constpool_float(float %x) {
18 ; CHECK-LABEL: constpool_float:
20 ; CHECK-NEXT: movss {{.*#+}} xmm1 = [1.65E+2,0.0E+0,0.0E+0,0.0E+0]
21 ; CHECK-NEXT: addss %xmm1, %xmm0
24 ; LARGE-LABEL: constpool_float:
26 ; LARGE-NEXT: movabsq ${{\.?LCPI[0-9]+_[0-9]+}}, %rax
27 ; LARGE-NEXT: addss (%rax), %xmm0
30 ; LARGE_PIC-LABEL: constpool_float:
32 ; LARGE_PIC-NEXT: .L0$pb:
33 ; LARGE_PIC-NEXT: leaq .L0$pb(%rip), %rax
34 ; LARGE_PIC-NEXT: movabsq $_GLOBAL_OFFSET_TABLE_-.L0$pb, %rcx
35 ; LARGE_PIC-NEXT: addq %rax, %rcx
36 ; LARGE_PIC-NEXT: movabsq ${{\.?LCPI[0-9]+_[0-9]+}}@GOTOFF, %rax
37 ; LARGE_PIC-NEXT: addss (%rax,%rcx), %xmm0
38 ; LARGE_PIC-NEXT: retq
40 ; AVX-LABEL: constpool_float:
42 ; AVX-NEXT: vmovss {{.*#+}} xmm1 = [1.65E+2,0.0E+0,0.0E+0,0.0E+0]
43 ; AVX-NEXT: vaddss %xmm1, %xmm0, %xmm0
46 ; LARGE_AVX-LABEL: constpool_float:
47 ; LARGE_AVX: ## %bb.0:
48 ; LARGE_AVX-NEXT: movabsq ${{\.?LCPI[0-9]+_[0-9]+}}, %rax
49 ; LARGE_AVX-NEXT: vaddss (%rax), %xmm0, %xmm0
50 ; LARGE_AVX-NEXT: retq
52 ; X86-LARGE-LABEL: constpool_float:
53 ; X86-LARGE: ## %bb.0:
54 ; X86-LARGE-NEXT: pushl %eax ## encoding: [0x50]
55 ; X86-LARGE-NEXT: .cfi_def_cfa_offset 8
56 ; X86-LARGE-NEXT: movss {{.*#+}} xmm0 = mem[0],zero,zero,zero
57 ; X86-LARGE-NEXT: ## encoding: [0xf3,0x0f,0x10,0x44,0x24,0x08]
58 ; X86-LARGE-NEXT: addss {{\.?LCPI[0-9]+_[0-9]+}}, %xmm0 ## encoding: [0xf3,0x0f,0x58,0x05,A,A,A,A]
59 ; X86-LARGE-NEXT: ## fixup A - offset: 4, value: {{\.?LCPI[0-9]+_[0-9]+}}, kind: FK_Data_4
60 ; X86-LARGE-NEXT: movss %xmm0, (%esp) ## encoding: [0xf3,0x0f,0x11,0x04,0x24]
61 ; X86-LARGE-NEXT: flds (%esp) ## encoding: [0xd9,0x04,0x24]
62 ; X86-LARGE-NEXT: popl %eax ## encoding: [0x58]
63 ; X86-LARGE-NEXT: retl ## encoding: [0xc3]
65 %1 = fadd float %x, 16.50e+01
69 define double @constpool_double(double %x) nounwind {
70 ; CHECK-LABEL: constpool_double:
72 ; CHECK-NEXT: movsd {{.*#+}} xmm1 = [8.4999999999999998E-1,0.0E+0]
73 ; CHECK-NEXT: addsd %xmm1, %xmm0
76 ; LARGE-LABEL: constpool_double:
78 ; LARGE-NEXT: movabsq ${{\.?LCPI[0-9]+_[0-9]+}}, %rax
79 ; LARGE-NEXT: addsd (%rax), %xmm0
82 ; LARGE_PIC-LABEL: constpool_double:
84 ; LARGE_PIC-NEXT: .L1$pb:
85 ; LARGE_PIC-NEXT: leaq .L1$pb(%rip), %rax
86 ; LARGE_PIC-NEXT: movabsq $_GLOBAL_OFFSET_TABLE_-.L1$pb, %rcx
87 ; LARGE_PIC-NEXT: addq %rax, %rcx
88 ; LARGE_PIC-NEXT: movabsq ${{\.?LCPI[0-9]+_[0-9]+}}@GOTOFF, %rax
89 ; LARGE_PIC-NEXT: addsd (%rax,%rcx), %xmm0
90 ; LARGE_PIC-NEXT: retq
92 ; AVX-LABEL: constpool_double:
94 ; AVX-NEXT: vmovsd {{.*#+}} xmm1 = [8.4999999999999998E-1,0.0E+0]
95 ; AVX-NEXT: vaddsd %xmm1, %xmm0, %xmm0
98 ; LARGE_AVX-LABEL: constpool_double:
99 ; LARGE_AVX: ## %bb.0:
100 ; LARGE_AVX-NEXT: movabsq ${{\.?LCPI[0-9]+_[0-9]+}}, %rax
101 ; LARGE_AVX-NEXT: vaddsd (%rax), %xmm0, %xmm0
102 ; LARGE_AVX-NEXT: retq
104 ; X86-LARGE-LABEL: constpool_double:
105 ; X86-LARGE: ## %bb.0:
106 ; X86-LARGE-NEXT: subl $12, %esp ## encoding: [0x83,0xec,0x0c]
107 ; X86-LARGE-NEXT: movsd {{.*#+}} xmm0 = mem[0],zero
108 ; X86-LARGE-NEXT: ## encoding: [0xf2,0x0f,0x10,0x44,0x24,0x10]
109 ; X86-LARGE-NEXT: addsd {{\.?LCPI[0-9]+_[0-9]+}}, %xmm0 ## encoding: [0xf2,0x0f,0x58,0x05,A,A,A,A]
110 ; X86-LARGE-NEXT: ## fixup A - offset: 4, value: {{\.?LCPI[0-9]+_[0-9]+}}, kind: FK_Data_4
111 ; X86-LARGE-NEXT: movsd %xmm0, (%esp) ## encoding: [0xf2,0x0f,0x11,0x04,0x24]
112 ; X86-LARGE-NEXT: fldl (%esp) ## encoding: [0xdd,0x04,0x24]
113 ; X86-LARGE-NEXT: addl $12, %esp ## encoding: [0x83,0xc4,0x0c]
114 ; X86-LARGE-NEXT: retl ## encoding: [0xc3]
116 %1 = fadd double %x, 8.500000e-01
120 define void @constpool_float_no_fp_args(ptr %x) nounwind {
121 ; CHECK-LABEL: constpool_float_no_fp_args:
123 ; CHECK-NEXT: movss {{.*#+}} xmm0 = [1.65E+2,0.0E+0,0.0E+0,0.0E+0]
124 ; CHECK-NEXT: addss (%rdi), %xmm0
125 ; CHECK-NEXT: movss %xmm0, (%rdi)
128 ; LARGE-LABEL: constpool_float_no_fp_args:
130 ; LARGE-NEXT: movabsq ${{\.?LCPI[0-9]+_[0-9]+}}, %rax
131 ; LARGE-NEXT: movss {{.*#+}} xmm0 = mem[0],zero,zero,zero
132 ; LARGE-NEXT: addss (%rdi), %xmm0
133 ; LARGE-NEXT: movss %xmm0, (%rdi)
136 ; LARGE_PIC-LABEL: constpool_float_no_fp_args:
137 ; LARGE_PIC: # %bb.0:
138 ; LARGE_PIC-NEXT: .L2$pb:
139 ; LARGE_PIC-NEXT: leaq .L2$pb(%rip), %rax
140 ; LARGE_PIC-NEXT: movabsq $_GLOBAL_OFFSET_TABLE_-.L2$pb, %rcx
141 ; LARGE_PIC-NEXT: addq %rax, %rcx
142 ; LARGE_PIC-NEXT: movabsq ${{\.?LCPI[0-9]+_[0-9]+}}@GOTOFF, %rax
143 ; LARGE_PIC-NEXT: movss {{.*#+}} xmm0 = mem[0],zero,zero,zero
144 ; LARGE_PIC-NEXT: addss (%rdi), %xmm0
145 ; LARGE_PIC-NEXT: movss %xmm0, (%rdi)
146 ; LARGE_PIC-NEXT: retq
148 ; AVX-LABEL: constpool_float_no_fp_args:
150 ; AVX-NEXT: vmovss {{.*#+}} xmm0 = [1.65E+2,0.0E+0,0.0E+0,0.0E+0]
151 ; AVX-NEXT: vaddss (%rdi), %xmm0, %xmm0
152 ; AVX-NEXT: vmovss %xmm0, (%rdi)
155 ; LARGE_AVX-LABEL: constpool_float_no_fp_args:
156 ; LARGE_AVX: ## %bb.0:
157 ; LARGE_AVX-NEXT: movabsq ${{\.?LCPI[0-9]+_[0-9]+}}, %rax
158 ; LARGE_AVX-NEXT: vmovss {{.*#+}} xmm0 = mem[0],zero,zero,zero
159 ; LARGE_AVX-NEXT: vaddss (%rdi), %xmm0, %xmm0
160 ; LARGE_AVX-NEXT: vmovss %xmm0, (%rdi)
161 ; LARGE_AVX-NEXT: retq
163 ; X86-LARGE-LABEL: constpool_float_no_fp_args:
164 ; X86-LARGE: ## %bb.0:
165 ; X86-LARGE-NEXT: movl {{[0-9]+}}(%esp), %eax ## encoding: [0x8b,0x44,0x24,0x04]
166 ; X86-LARGE-NEXT: movss {{.*#+}} xmm0 = [1.65E+2,0.0E+0,0.0E+0,0.0E+0]
167 ; X86-LARGE-NEXT: ## encoding: [0xf3,0x0f,0x10,0x05,A,A,A,A]
168 ; X86-LARGE-NEXT: ## fixup A - offset: 4, value: {{\.?LCPI[0-9]+_[0-9]+}}, kind: FK_Data_4
169 ; X86-LARGE-NEXT: addss (%eax), %xmm0 ## encoding: [0xf3,0x0f,0x58,0x00]
170 ; X86-LARGE-NEXT: movss %xmm0, (%eax) ## encoding: [0xf3,0x0f,0x11,0x00]
171 ; X86-LARGE-NEXT: retl ## encoding: [0xc3]
172 %a = load float, ptr %x
173 %b = fadd float %a, 16.50e+01
174 store float %b, ptr %x
178 define void @constpool_double_no_fp_args(ptr %x) nounwind {
179 ; CHECK-LABEL: constpool_double_no_fp_args:
181 ; CHECK-NEXT: movsd {{.*#+}} xmm0 = [8.4999999999999998E-1,0.0E+0]
182 ; CHECK-NEXT: addsd (%rdi), %xmm0
183 ; CHECK-NEXT: movsd %xmm0, (%rdi)
186 ; LARGE-LABEL: constpool_double_no_fp_args:
188 ; LARGE-NEXT: movabsq ${{\.?LCPI[0-9]+_[0-9]+}}, %rax
189 ; LARGE-NEXT: movsd {{.*#+}} xmm0 = mem[0],zero
190 ; LARGE-NEXT: addsd (%rdi), %xmm0
191 ; LARGE-NEXT: movsd %xmm0, (%rdi)
194 ; LARGE_PIC-LABEL: constpool_double_no_fp_args:
195 ; LARGE_PIC: # %bb.0:
196 ; LARGE_PIC-NEXT: .L3$pb:
197 ; LARGE_PIC-NEXT: leaq .L3$pb(%rip), %rax
198 ; LARGE_PIC-NEXT: movabsq $_GLOBAL_OFFSET_TABLE_-.L3$pb, %rcx
199 ; LARGE_PIC-NEXT: addq %rax, %rcx
200 ; LARGE_PIC-NEXT: movabsq ${{\.?LCPI[0-9]+_[0-9]+}}@GOTOFF, %rax
201 ; LARGE_PIC-NEXT: movsd {{.*#+}} xmm0 = mem[0],zero
202 ; LARGE_PIC-NEXT: addsd (%rdi), %xmm0
203 ; LARGE_PIC-NEXT: movsd %xmm0, (%rdi)
204 ; LARGE_PIC-NEXT: retq
206 ; AVX-LABEL: constpool_double_no_fp_args:
208 ; AVX-NEXT: vmovsd {{.*#+}} xmm0 = [8.4999999999999998E-1,0.0E+0]
209 ; AVX-NEXT: vaddsd (%rdi), %xmm0, %xmm0
210 ; AVX-NEXT: vmovsd %xmm0, (%rdi)
213 ; LARGE_AVX-LABEL: constpool_double_no_fp_args:
214 ; LARGE_AVX: ## %bb.0:
215 ; LARGE_AVX-NEXT: movabsq ${{\.?LCPI[0-9]+_[0-9]+}}, %rax
216 ; LARGE_AVX-NEXT: vmovsd {{.*#+}} xmm0 = mem[0],zero
217 ; LARGE_AVX-NEXT: vaddsd (%rdi), %xmm0, %xmm0
218 ; LARGE_AVX-NEXT: vmovsd %xmm0, (%rdi)
219 ; LARGE_AVX-NEXT: retq
221 ; X86-LARGE-LABEL: constpool_double_no_fp_args:
222 ; X86-LARGE: ## %bb.0:
223 ; X86-LARGE-NEXT: movl {{[0-9]+}}(%esp), %eax ## encoding: [0x8b,0x44,0x24,0x04]
224 ; X86-LARGE-NEXT: movsd {{.*#+}} xmm0 = [8.4999999999999998E-1,0.0E+0]
225 ; X86-LARGE-NEXT: ## encoding: [0xf2,0x0f,0x10,0x05,A,A,A,A]
226 ; X86-LARGE-NEXT: ## fixup A - offset: 4, value: {{\.?LCPI[0-9]+_[0-9]+}}, kind: FK_Data_4
227 ; X86-LARGE-NEXT: addsd (%eax), %xmm0 ## encoding: [0xf2,0x0f,0x58,0x00]
228 ; X86-LARGE-NEXT: movsd %xmm0, (%eax) ## encoding: [0xf2,0x0f,0x11,0x00]
229 ; X86-LARGE-NEXT: retl ## encoding: [0xc3]
230 %a = load double, ptr %x
231 %b = fadd double %a, 8.500000e-01
232 store double %b, ptr %x