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 10 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 15 16; Make sure fast isel uses rip-relative addressing for the small code model. 17define float @constpool_float(float %x) { 18; CHECK-LABEL: constpool_float: 19; CHECK: ## %bb.0: 20; CHECK-NEXT: movss {{.*#+}} xmm1 = [1.65E+2,0.0E+0,0.0E+0,0.0E+0] 21; CHECK-NEXT: addss %xmm1, %xmm0 22; CHECK-NEXT: retq 23; 24; LARGE-LABEL: constpool_float: 25; LARGE: ## %bb.0: 26; LARGE-NEXT: movabsq ${{\.?LCPI[0-9]+_[0-9]+}}, %rax 27; LARGE-NEXT: addss (%rax), %xmm0 28; LARGE-NEXT: retq 29; 30; LARGE_PIC-LABEL: constpool_float: 31; LARGE_PIC: # %bb.0: 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 39; 40; AVX-LABEL: constpool_float: 41; AVX: ## %bb.0: 42; AVX-NEXT: vmovss {{.*#+}} xmm1 = [1.65E+2,0.0E+0,0.0E+0,0.0E+0] 43; AVX-NEXT: vaddss %xmm1, %xmm0, %xmm0 44; AVX-NEXT: retq 45; 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 51; 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] 64 65 %1 = fadd float %x, 16.50e+01 66 ret float %1 67} 68 69define double @constpool_double(double %x) nounwind { 70; CHECK-LABEL: constpool_double: 71; CHECK: ## %bb.0: 72; CHECK-NEXT: movsd {{.*#+}} xmm1 = [8.4999999999999998E-1,0.0E+0] 73; CHECK-NEXT: addsd %xmm1, %xmm0 74; CHECK-NEXT: retq 75; 76; LARGE-LABEL: constpool_double: 77; LARGE: ## %bb.0: 78; LARGE-NEXT: movabsq ${{\.?LCPI[0-9]+_[0-9]+}}, %rax 79; LARGE-NEXT: addsd (%rax), %xmm0 80; LARGE-NEXT: retq 81; 82; LARGE_PIC-LABEL: constpool_double: 83; LARGE_PIC: # %bb.0: 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 91; 92; AVX-LABEL: constpool_double: 93; AVX: ## %bb.0: 94; AVX-NEXT: vmovsd {{.*#+}} xmm1 = [8.4999999999999998E-1,0.0E+0] 95; AVX-NEXT: vaddsd %xmm1, %xmm0, %xmm0 96; AVX-NEXT: retq 97; 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 103; 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] 115 116 %1 = fadd double %x, 8.500000e-01 117 ret double %1 118} 119 120define void @constpool_float_no_fp_args(ptr %x) nounwind { 121; CHECK-LABEL: constpool_float_no_fp_args: 122; CHECK: ## %bb.0: 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) 126; CHECK-NEXT: retq 127; 128; LARGE-LABEL: constpool_float_no_fp_args: 129; LARGE: ## %bb.0: 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) 134; LARGE-NEXT: retq 135; 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 147; 148; AVX-LABEL: constpool_float_no_fp_args: 149; AVX: ## %bb.0: 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) 153; AVX-NEXT: retq 154; 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 162; 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 175 ret void 176} 177 178define void @constpool_double_no_fp_args(ptr %x) nounwind { 179; CHECK-LABEL: constpool_double_no_fp_args: 180; CHECK: ## %bb.0: 181; CHECK-NEXT: movsd {{.*#+}} xmm0 = [8.4999999999999998E-1,0.0E+0] 182; CHECK-NEXT: addsd (%rdi), %xmm0 183; CHECK-NEXT: movsd %xmm0, (%rdi) 184; CHECK-NEXT: retq 185; 186; LARGE-LABEL: constpool_double_no_fp_args: 187; LARGE: ## %bb.0: 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) 192; LARGE-NEXT: retq 193; 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 205; 206; AVX-LABEL: constpool_double_no_fp_args: 207; AVX: ## %bb.0: 208; AVX-NEXT: vmovsd {{.*#+}} xmm0 = [8.4999999999999998E-1,0.0E+0] 209; AVX-NEXT: vaddsd (%rdi), %xmm0, %xmm0 210; AVX-NEXT: vmovsd %xmm0, (%rdi) 211; AVX-NEXT: retq 212; 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 220; 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 233 ret void 234} 235