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=large < %s | FileCheck %s --check-prefix=LARGE 4; RUN: llc -mtriple=x86_64 -fast-isel -code-model=large -relocation-model=pic < %s | FileCheck %s --check-prefix=LARGE_PIC 5; RUN: llc -mtriple=x86_64-apple-darwin -fast-isel -code-model=small -mattr=avx < %s | FileCheck %s --check-prefix=AVX 6; RUN: llc -mtriple=x86_64-apple-darwin -fast-isel -code-model=large -mattr=avx < %s | FileCheck %s --check-prefix=LARGE_AVX 7; RUN: llc -mtriple=x86_64-apple-darwin -fast-isel -code-model=small -mattr=avx512f < %s | FileCheck %s --check-prefix=AVX 8; RUN: llc -mtriple=x86_64-apple-darwin -fast-isel -code-model=large -mattr=avx512f < %s | FileCheck %s --check-prefix=LARGE_AVX 9 10; This large code mode shouldn't mean anything on x86 but it used to 11; generate 64-bit only instructions and asserted in the encoder. 12; -show-mc-encoding here to assert if this breaks again. 13; RUN: llc -mtriple=i686-apple-darwin -fast-isel -code-model=large -mattr=sse2 -show-mc-encoding < %s | FileCheck %s --check-prefix=X86-LARGE 14 15; Make sure fast isel uses rip-relative addressing for the small code model. 16define float @constpool_float(float %x) { 17; CHECK-LABEL: constpool_float: 18; CHECK: ## %bb.0: 19; CHECK-NEXT: movss {{.*#+}} xmm1 = mem[0],zero,zero,zero 20; CHECK-NEXT: addss %xmm1, %xmm0 21; CHECK-NEXT: retq 22; 23; LARGE-LABEL: constpool_float: 24; LARGE: ## %bb.0: 25; LARGE-NEXT: movabsq $LCPI0_0, %rax 26; LARGE-NEXT: addss (%rax), %xmm0 27; LARGE-NEXT: retq 28; 29; LARGE_PIC-LABEL: constpool_float: 30; LARGE_PIC: # %bb.0: 31; LARGE_PIC-NEXT: .L0$pb: 32; LARGE_PIC-NEXT: leaq .L0$pb(%rip), %rax 33; LARGE_PIC-NEXT: movabsq $_GLOBAL_OFFSET_TABLE_-.L0$pb, %rcx 34; LARGE_PIC-NEXT: addq %rax, %rcx 35; LARGE_PIC-NEXT: movabsq $.LCPI0_0@GOTOFF, %rax 36; LARGE_PIC-NEXT: addss (%rax,%rcx), %xmm0 37; LARGE_PIC-NEXT: retq 38; 39; AVX-LABEL: constpool_float: 40; AVX: ## %bb.0: 41; AVX-NEXT: vmovss {{.*#+}} xmm1 = mem[0],zero,zero,zero 42; AVX-NEXT: vaddss %xmm1, %xmm0, %xmm0 43; AVX-NEXT: retq 44; 45; LARGE_AVX-LABEL: constpool_float: 46; LARGE_AVX: ## %bb.0: 47; LARGE_AVX-NEXT: movabsq $LCPI0_0, %rax 48; LARGE_AVX-NEXT: vaddss (%rax), %xmm0, %xmm0 49; LARGE_AVX-NEXT: retq 50; 51; X86-LARGE-LABEL: constpool_float: 52; X86-LARGE: ## %bb.0: 53; X86-LARGE-NEXT: pushl %eax ## encoding: [0x50] 54; X86-LARGE-NEXT: .cfi_def_cfa_offset 8 55; X86-LARGE-NEXT: movss {{[0-9]+}}(%esp), %xmm0 ## encoding: [0xf3,0x0f,0x10,0x44,0x24,0x08] 56; X86-LARGE-NEXT: ## xmm0 = mem[0],zero,zero,zero 57; X86-LARGE-NEXT: addss LCPI0_0, %xmm0 ## encoding: [0xf3,0x0f,0x58,0x05,A,A,A,A] 58; X86-LARGE-NEXT: ## fixup A - offset: 4, value: LCPI0_0, kind: FK_Data_4 59; X86-LARGE-NEXT: movss %xmm0, (%esp) ## encoding: [0xf3,0x0f,0x11,0x04,0x24] 60; X86-LARGE-NEXT: flds (%esp) ## encoding: [0xd9,0x04,0x24] 61; X86-LARGE-NEXT: popl %eax ## encoding: [0x58] 62; X86-LARGE-NEXT: retl ## encoding: [0xc3] 63 64 %1 = fadd float %x, 16.50e+01 65 ret float %1 66} 67 68define double @constpool_double(double %x) nounwind { 69; CHECK-LABEL: constpool_double: 70; CHECK: ## %bb.0: 71; CHECK-NEXT: movsd {{.*#+}} xmm1 = mem[0],zero 72; CHECK-NEXT: addsd %xmm1, %xmm0 73; CHECK-NEXT: retq 74; 75; LARGE-LABEL: constpool_double: 76; LARGE: ## %bb.0: 77; LARGE-NEXT: movabsq $LCPI1_0, %rax 78; LARGE-NEXT: addsd (%rax), %xmm0 79; LARGE-NEXT: retq 80; 81; AVX-LABEL: constpool_double: 82; AVX: ## %bb.0: 83; AVX-NEXT: vmovsd {{.*#+}} xmm1 = mem[0],zero 84; AVX-NEXT: vaddsd %xmm1, %xmm0, %xmm0 85; AVX-NEXT: retq 86; 87; LARGE_AVX-LABEL: constpool_double: 88; LARGE_AVX: ## %bb.0: 89; LARGE_AVX-NEXT: movabsq $LCPI1_0, %rax 90; LARGE_AVX-NEXT: vaddsd (%rax), %xmm0, %xmm0 91; LARGE_AVX-NEXT: retq 92; 93; X86-LARGE-LABEL: constpool_double: 94; X86-LARGE: ## %bb.0: 95; X86-LARGE-NEXT: subl $12, %esp ## encoding: [0x83,0xec,0x0c] 96; X86-LARGE-NEXT: movsd {{[0-9]+}}(%esp), %xmm0 ## encoding: [0xf2,0x0f,0x10,0x44,0x24,0x10] 97; X86-LARGE-NEXT: ## xmm0 = mem[0],zero 98; X86-LARGE-NEXT: addsd LCPI1_0, %xmm0 ## encoding: [0xf2,0x0f,0x58,0x05,A,A,A,A] 99; X86-LARGE-NEXT: ## fixup A - offset: 4, value: LCPI1_0, kind: FK_Data_4 100; X86-LARGE-NEXT: movsd %xmm0, (%esp) ## encoding: [0xf2,0x0f,0x11,0x04,0x24] 101; X86-LARGE-NEXT: fldl (%esp) ## encoding: [0xdd,0x04,0x24] 102; X86-LARGE-NEXT: addl $12, %esp ## encoding: [0x83,0xc4,0x0c] 103; X86-LARGE-NEXT: retl ## encoding: [0xc3] 104 105 %1 = fadd double %x, 8.500000e-01 106 ret double %1 107} 108 109define void @constpool_float_no_fp_args(float* %x) nounwind { 110; CHECK-LABEL: constpool_float_no_fp_args: 111; CHECK: ## %bb.0: 112; CHECK-NEXT: movss {{.*#+}} xmm0 = mem[0],zero,zero,zero 113; CHECK-NEXT: addss (%rdi), %xmm0 114; CHECK-NEXT: movss %xmm0, (%rdi) 115; CHECK-NEXT: retq 116; 117; LARGE-LABEL: constpool_float_no_fp_args: 118; LARGE: ## %bb.0: 119; LARGE-NEXT: movabsq $LCPI2_0, %rax 120; LARGE-NEXT: movss {{.*#+}} xmm0 = mem[0],zero,zero,zero 121; LARGE-NEXT: addss (%rdi), %xmm0 122; LARGE-NEXT: movss %xmm0, (%rdi) 123; LARGE-NEXT: retq 124; 125; AVX-LABEL: constpool_float_no_fp_args: 126; AVX: ## %bb.0: 127; AVX-NEXT: vmovss {{.*#+}} xmm0 = mem[0],zero,zero,zero 128; AVX-NEXT: vaddss (%rdi), %xmm0, %xmm0 129; AVX-NEXT: vmovss %xmm0, (%rdi) 130; AVX-NEXT: retq 131; 132; LARGE_AVX-LABEL: constpool_float_no_fp_args: 133; LARGE_AVX: ## %bb.0: 134; LARGE_AVX-NEXT: movabsq $LCPI2_0, %rax 135; LARGE_AVX-NEXT: vmovss {{.*#+}} xmm0 = mem[0],zero,zero,zero 136; LARGE_AVX-NEXT: vaddss (%rdi), %xmm0, %xmm0 137; LARGE_AVX-NEXT: vmovss %xmm0, (%rdi) 138; LARGE_AVX-NEXT: retq 139; 140; X86-LARGE-LABEL: constpool_float_no_fp_args: 141; X86-LARGE: ## %bb.0: 142; X86-LARGE-NEXT: movl {{[0-9]+}}(%esp), %eax ## encoding: [0x8b,0x44,0x24,0x04] 143; X86-LARGE-NEXT: movss LCPI2_0, %xmm0 ## encoding: [0xf3,0x0f,0x10,0x05,A,A,A,A] 144; X86-LARGE-NEXT: ## fixup A - offset: 4, value: LCPI2_0, kind: FK_Data_4 145; X86-LARGE-NEXT: ## xmm0 = mem[0],zero,zero,zero 146; X86-LARGE-NEXT: addss (%eax), %xmm0 ## encoding: [0xf3,0x0f,0x58,0x00] 147; X86-LARGE-NEXT: movss %xmm0, (%eax) ## encoding: [0xf3,0x0f,0x11,0x00] 148; X86-LARGE-NEXT: retl ## encoding: [0xc3] 149 %a = load float, float* %x 150 %b = fadd float %a, 16.50e+01 151 store float %b, float* %x 152 ret void 153} 154 155define void @constpool_double_no_fp_args(double* %x) nounwind { 156; CHECK-LABEL: constpool_double_no_fp_args: 157; CHECK: ## %bb.0: 158; CHECK-NEXT: movsd {{.*#+}} xmm0 = mem[0],zero 159; CHECK-NEXT: addsd (%rdi), %xmm0 160; CHECK-NEXT: movsd %xmm0, (%rdi) 161; CHECK-NEXT: retq 162; 163; LARGE-LABEL: constpool_double_no_fp_args: 164; LARGE: ## %bb.0: 165; LARGE-NEXT: movabsq $LCPI3_0, %rax 166; LARGE-NEXT: movsd {{.*#+}} xmm0 = mem[0],zero 167; LARGE-NEXT: addsd (%rdi), %xmm0 168; LARGE-NEXT: movsd %xmm0, (%rdi) 169; LARGE-NEXT: retq 170; 171; AVX-LABEL: constpool_double_no_fp_args: 172; AVX: ## %bb.0: 173; AVX-NEXT: vmovsd {{.*#+}} xmm0 = mem[0],zero 174; AVX-NEXT: vaddsd (%rdi), %xmm0, %xmm0 175; AVX-NEXT: vmovsd %xmm0, (%rdi) 176; AVX-NEXT: retq 177; 178; LARGE_AVX-LABEL: constpool_double_no_fp_args: 179; LARGE_AVX: ## %bb.0: 180; LARGE_AVX-NEXT: movabsq $LCPI3_0, %rax 181; LARGE_AVX-NEXT: vmovsd {{.*#+}} xmm0 = mem[0],zero 182; LARGE_AVX-NEXT: vaddsd (%rdi), %xmm0, %xmm0 183; LARGE_AVX-NEXT: vmovsd %xmm0, (%rdi) 184; LARGE_AVX-NEXT: retq 185; 186; X86-LARGE-LABEL: constpool_double_no_fp_args: 187; X86-LARGE: ## %bb.0: 188; X86-LARGE-NEXT: movl {{[0-9]+}}(%esp), %eax ## encoding: [0x8b,0x44,0x24,0x04] 189; X86-LARGE-NEXT: movsd LCPI3_0, %xmm0 ## encoding: [0xf2,0x0f,0x10,0x05,A,A,A,A] 190; X86-LARGE-NEXT: ## fixup A - offset: 4, value: LCPI3_0, kind: FK_Data_4 191; X86-LARGE-NEXT: ## xmm0 = mem[0],zero 192; X86-LARGE-NEXT: addsd (%eax), %xmm0 ## encoding: [0xf2,0x0f,0x58,0x00] 193; X86-LARGE-NEXT: movsd %xmm0, (%eax) ## encoding: [0xf2,0x0f,0x11,0x00] 194; X86-LARGE-NEXT: retl ## encoding: [0xc3] 195 %a = load double, double* %x 196 %b = fadd double %a, 8.500000e-01 197 store double %b, double* %x 198 ret void 199} 200