314 lines · plain
1; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py2; RUN: llc < %s -mtriple=i686-unknown | FileCheck %s --check-prefixes=X86,X86-NOSSE3; RUN: llc < %s -mtriple=i686-unknown -mattr=sse2 | FileCheck %s --check-prefixes=X86,X86-SSE24; RUN: llc < %s -mtriple=x86_64-unknown | FileCheck %s --check-prefixes=CHECK,SSE5; RUN: llc < %s -mtriple=x86_64-unknown -mattr=avx | FileCheck %s --check-prefixes=CHECK,AVX6; RUN: llc < %s -mtriple=x86_64-unknown -mattr=avx512f | FileCheck %s --check-prefixes=CHECK,AVX7 8; FIXME: crash9; define i64 @test_lrint_i64_f16(half %x) nounwind {10; %conv = tail call i64 @llvm.lrint.i64.f16(half %x)11; ret i64 %conv12; }13 14define i64 @test_lrint_i64_f32(float %x) nounwind {15; X86-NOSSE-LABEL: test_lrint_i64_f32:16; X86-NOSSE: # %bb.0:17; X86-NOSSE-NEXT: pushl %ebp18; X86-NOSSE-NEXT: movl %esp, %ebp19; X86-NOSSE-NEXT: andl $-8, %esp20; X86-NOSSE-NEXT: subl $8, %esp21; X86-NOSSE-NEXT: flds 8(%ebp)22; X86-NOSSE-NEXT: fistpll (%esp)23; X86-NOSSE-NEXT: movl (%esp), %eax24; X86-NOSSE-NEXT: movl {{[0-9]+}}(%esp), %edx25; X86-NOSSE-NEXT: movl %ebp, %esp26; X86-NOSSE-NEXT: popl %ebp27; X86-NOSSE-NEXT: retl28;29; X86-SSE2-LABEL: test_lrint_i64_f32:30; X86-SSE2: # %bb.0:31; X86-SSE2-NEXT: pushl %ebp32; X86-SSE2-NEXT: movl %esp, %ebp33; X86-SSE2-NEXT: andl $-8, %esp34; X86-SSE2-NEXT: subl $8, %esp35; X86-SSE2-NEXT: movss {{.*#+}} xmm0 = mem[0],zero,zero,zero36; X86-SSE2-NEXT: movss %xmm0, (%esp)37; X86-SSE2-NEXT: flds (%esp)38; X86-SSE2-NEXT: fistpll (%esp)39; X86-SSE2-NEXT: movl (%esp), %eax40; X86-SSE2-NEXT: movl {{[0-9]+}}(%esp), %edx41; X86-SSE2-NEXT: movl %ebp, %esp42; X86-SSE2-NEXT: popl %ebp43; X86-SSE2-NEXT: retl44;45; SSE-LABEL: test_lrint_i64_f32:46; SSE: # %bb.0:47; SSE-NEXT: cvtss2si %xmm0, %rax48; SSE-NEXT: retq49;50; AVX-LABEL: test_lrint_i64_f32:51; AVX: # %bb.0:52; AVX-NEXT: vcvtss2si %xmm0, %rax53; AVX-NEXT: retq54 %conv = tail call i64 @llvm.lrint.i64.f32(float %x)55 ret i64 %conv56}57 58define i64 @test_lrint_i64_f64(double %x) nounwind {59; X86-NOSSE-LABEL: test_lrint_i64_f64:60; X86-NOSSE: # %bb.0:61; X86-NOSSE-NEXT: pushl %ebp62; X86-NOSSE-NEXT: movl %esp, %ebp63; X86-NOSSE-NEXT: andl $-8, %esp64; X86-NOSSE-NEXT: subl $8, %esp65; X86-NOSSE-NEXT: fldl 8(%ebp)66; X86-NOSSE-NEXT: fistpll (%esp)67; X86-NOSSE-NEXT: movl (%esp), %eax68; X86-NOSSE-NEXT: movl {{[0-9]+}}(%esp), %edx69; X86-NOSSE-NEXT: movl %ebp, %esp70; X86-NOSSE-NEXT: popl %ebp71; X86-NOSSE-NEXT: retl72;73; X86-SSE2-LABEL: test_lrint_i64_f64:74; X86-SSE2: # %bb.0:75; X86-SSE2-NEXT: pushl %ebp76; X86-SSE2-NEXT: movl %esp, %ebp77; X86-SSE2-NEXT: andl $-8, %esp78; X86-SSE2-NEXT: subl $8, %esp79; X86-SSE2-NEXT: movsd {{.*#+}} xmm0 = mem[0],zero80; X86-SSE2-NEXT: movsd %xmm0, (%esp)81; X86-SSE2-NEXT: fldl (%esp)82; X86-SSE2-NEXT: fistpll (%esp)83; X86-SSE2-NEXT: movl (%esp), %eax84; X86-SSE2-NEXT: movl {{[0-9]+}}(%esp), %edx85; X86-SSE2-NEXT: movl %ebp, %esp86; X86-SSE2-NEXT: popl %ebp87; X86-SSE2-NEXT: retl88;89; SSE-LABEL: test_lrint_i64_f64:90; SSE: # %bb.0:91; SSE-NEXT: cvtsd2si %xmm0, %rax92; SSE-NEXT: retq93;94; AVX-LABEL: test_lrint_i64_f64:95; AVX: # %bb.0:96; AVX-NEXT: vcvtsd2si %xmm0, %rax97; AVX-NEXT: retq98 %conv = tail call i64 @llvm.lrint.i64.f64(double %x)99 ret i64 %conv100}101 102define i64 @test_lrint_i64_f80(x86_fp80 %x) nounwind {103; X86-LABEL: test_lrint_i64_f80:104; X86: # %bb.0:105; X86-NEXT: pushl %ebp106; X86-NEXT: movl %esp, %ebp107; X86-NEXT: andl $-8, %esp108; X86-NEXT: subl $8, %esp109; X86-NEXT: fldt 8(%ebp)110; X86-NEXT: fistpll (%esp)111; X86-NEXT: movl (%esp), %eax112; X86-NEXT: movl {{[0-9]+}}(%esp), %edx113; X86-NEXT: movl %ebp, %esp114; X86-NEXT: popl %ebp115; X86-NEXT: retl116;117; CHECK-LABEL: test_lrint_i64_f80:118; CHECK: # %bb.0:119; CHECK-NEXT: fldt {{[0-9]+}}(%rsp)120; CHECK-NEXT: fistpll -{{[0-9]+}}(%rsp)121; CHECK-NEXT: movq -{{[0-9]+}}(%rsp), %rax122; CHECK-NEXT: retq123 %conv = tail call i64 @llvm.lrint.i64.f80(x86_fp80 %x)124 ret i64 %conv125}126 127; FIXME(#44744): incorrect libcall128define i64 @test_lrint_i64_f128(fp128 %x) nounwind {129; X86-LABEL: test_lrint_i64_f128:130; X86: # %bb.0:131; X86-NEXT: pushl %ebp132; X86-NEXT: movl %esp, %ebp133; X86-NEXT: andl $-16, %esp134; X86-NEXT: subl $16, %esp135; X86-NEXT: pushl 20(%ebp)136; X86-NEXT: pushl 16(%ebp)137; X86-NEXT: pushl 12(%ebp)138; X86-NEXT: pushl 8(%ebp)139; X86-NEXT: calll lrintl140; X86-NEXT: addl $16, %esp141; X86-NEXT: movl %ebp, %esp142; X86-NEXT: popl %ebp143; X86-NEXT: retl144;145; CHECK-LABEL: test_lrint_i64_f128:146; CHECK: # %bb.0:147; CHECK-NEXT: jmp lrintl@PLT # TAILCALL148 %conv = tail call i64 @llvm.lrint.i64.f128(fp128 %x)149 ret i64 %conv150}151 152; FIXME: crash153; define i64 @test_lrint_i64_f16_strict(half %x) nounwind {154; %conv = tail call i64 @llvm.experimental.constrained.lrint.i64.f16(half %x, metadata!"round.dynamic", metadata!"fpexcept.strict")155; ret i64 %conv156; }157 158define i64 @test_lrint_i64_f32_strict(float %x) nounwind {159; X86-NOSSE-LABEL: test_lrint_i64_f32_strict:160; X86-NOSSE: # %bb.0:161; X86-NOSSE-NEXT: pushl %eax162; X86-NOSSE-NEXT: flds {{[0-9]+}}(%esp)163; X86-NOSSE-NEXT: fstps (%esp)164; X86-NOSSE-NEXT: calll lrintf165; X86-NOSSE-NEXT: popl %ecx166; X86-NOSSE-NEXT: retl167;168; X86-SSE2-LABEL: test_lrint_i64_f32_strict:169; X86-SSE2: # %bb.0:170; X86-SSE2-NEXT: pushl %eax171; X86-SSE2-NEXT: movss {{.*#+}} xmm0 = mem[0],zero,zero,zero172; X86-SSE2-NEXT: movss %xmm0, (%esp)173; X86-SSE2-NEXT: calll lrintf174; X86-SSE2-NEXT: popl %ecx175; X86-SSE2-NEXT: retl176;177; CHECK-LABEL: test_lrint_i64_f32_strict:178; CHECK: # %bb.0:179; CHECK-NEXT: pushq %rax180; CHECK-NEXT: callq lrintf@PLT181; CHECK-NEXT: popq %rcx182; CHECK-NEXT: retq183 %conv = tail call i64 @llvm.experimental.constrained.lrint.i64.f32(float %x, metadata!"round.dynamic", metadata!"fpexcept.strict")184 ret i64 %conv185}186 187define i64 @test_lrint_i64_f64_strict(double %x) nounwind {188; X86-NOSSE-LABEL: test_lrint_i64_f64_strict:189; X86-NOSSE: # %bb.0:190; X86-NOSSE-NEXT: subl $8, %esp191; X86-NOSSE-NEXT: fldl {{[0-9]+}}(%esp)192; X86-NOSSE-NEXT: fstpl (%esp)193; X86-NOSSE-NEXT: calll lrint194; X86-NOSSE-NEXT: addl $8, %esp195; X86-NOSSE-NEXT: retl196;197; X86-SSE2-LABEL: test_lrint_i64_f64_strict:198; X86-SSE2: # %bb.0:199; X86-SSE2-NEXT: subl $8, %esp200; X86-SSE2-NEXT: movsd {{.*#+}} xmm0 = mem[0],zero201; X86-SSE2-NEXT: movsd %xmm0, (%esp)202; X86-SSE2-NEXT: calll lrint203; X86-SSE2-NEXT: addl $8, %esp204; X86-SSE2-NEXT: retl205;206; CHECK-LABEL: test_lrint_i64_f64_strict:207; CHECK: # %bb.0:208; CHECK-NEXT: pushq %rax209; CHECK-NEXT: callq lrint@PLT210; CHECK-NEXT: popq %rcx211; CHECK-NEXT: retq212 %conv = tail call i64 @llvm.experimental.constrained.lrint.i64.f64(double %x, metadata!"round.dynamic", metadata!"fpexcept.strict")213 ret i64 %conv214}215 216define i64 @test_lrint_i64_f80_strict(x86_fp80 %x) nounwind {217; X86-LABEL: test_lrint_i64_f80_strict:218; X86: # %bb.0:219; X86-NEXT: subl $12, %esp220; X86-NEXT: fldt {{[0-9]+}}(%esp)221; X86-NEXT: fstpt (%esp)222; X86-NEXT: calll lrintl223; X86-NEXT: addl $12, %esp224; X86-NEXT: retl225;226; CHECK-LABEL: test_lrint_i64_f80_strict:227; CHECK: # %bb.0:228; CHECK-NEXT: subq $24, %rsp229; CHECK-NEXT: fldt {{[0-9]+}}(%rsp)230; CHECK-NEXT: fstpt (%rsp)231; CHECK-NEXT: callq lrintl@PLT232; CHECK-NEXT: addq $24, %rsp233; CHECK-NEXT: retq234 %conv = tail call i64 @llvm.experimental.constrained.lrint.i64.f80(x86_fp80 %x, metadata!"round.dynamic", metadata!"fpexcept.strict")235 ret i64 %conv236}237 238; FIXME(#44744): incorrect libcall239define i64 @test_lrint_i64_f128_strict(fp128 %x) nounwind {240; X86-LABEL: test_lrint_i64_f128_strict:241; X86: # %bb.0:242; X86-NEXT: pushl %ebp243; X86-NEXT: movl %esp, %ebp244; X86-NEXT: andl $-16, %esp245; X86-NEXT: subl $16, %esp246; X86-NEXT: pushl 20(%ebp)247; X86-NEXT: pushl 16(%ebp)248; X86-NEXT: pushl 12(%ebp)249; X86-NEXT: pushl 8(%ebp)250; X86-NEXT: calll lrintl251; X86-NEXT: addl $16, %esp252; X86-NEXT: movl %ebp, %esp253; X86-NEXT: popl %ebp254; X86-NEXT: retl255;256; CHECK-LABEL: test_lrint_i64_f128_strict:257; CHECK: # %bb.0:258; CHECK-NEXT: pushq %rax259; CHECK-NEXT: callq lrintl@PLT260; CHECK-NEXT: popq %rcx261; CHECK-NEXT: retq262 %conv = tail call i64 @llvm.experimental.constrained.lrint.i64.f128(fp128 %x, metadata!"round.dynamic", metadata!"fpexcept.strict")263 ret i64 %conv264}265 266define i32 @PR125324(float %x) nounwind {267; X86-NOSSE-LABEL: PR125324:268; X86-NOSSE: # %bb.0:269; X86-NOSSE-NEXT: pushl %ebp270; X86-NOSSE-NEXT: movl %esp, %ebp271; X86-NOSSE-NEXT: andl $-8, %esp272; X86-NOSSE-NEXT: subl $8, %esp273; X86-NOSSE-NEXT: flds 8(%ebp)274; X86-NOSSE-NEXT: fistpll (%esp)275; X86-NOSSE-NEXT: movl (%esp), %eax276; X86-NOSSE-NEXT: movl %ebp, %esp277; X86-NOSSE-NEXT: popl %ebp278; X86-NOSSE-NEXT: retl279;280; X86-SSE2-LABEL: PR125324:281; X86-SSE2: # %bb.0:282; X86-SSE2-NEXT: pushl %ebp283; X86-SSE2-NEXT: movl %esp, %ebp284; X86-SSE2-NEXT: andl $-8, %esp285; X86-SSE2-NEXT: subl $8, %esp286; X86-SSE2-NEXT: movss {{.*#+}} xmm0 = mem[0],zero,zero,zero287; X86-SSE2-NEXT: movss %xmm0, (%esp)288; X86-SSE2-NEXT: flds (%esp)289; X86-SSE2-NEXT: fistpll (%esp)290; X86-SSE2-NEXT: movl (%esp), %eax291; X86-SSE2-NEXT: movl %ebp, %esp292; X86-SSE2-NEXT: popl %ebp293; X86-SSE2-NEXT: retl294;295; SSE-LABEL: PR125324:296; SSE: # %bb.0:297; SSE-NEXT: cvtss2si %xmm0, %rax298; SSE-NEXT: # kill: def $eax killed $eax killed $rax299; SSE-NEXT: retq300;301; AVX-LABEL: PR125324:302; AVX: # %bb.0:303; AVX-NEXT: vcvtss2si %xmm0, %rax304; AVX-NEXT: # kill: def $eax killed $eax killed $rax305; AVX-NEXT: retq306 %conv = tail call i64 @llvm.lrint.i64.f32(float %x)307 %trunc = trunc i64 %conv to i32308 ret i32 %trunc309}310 311declare i64 @llvm.lrint.i64.f32(float) nounwind readnone312declare i64 @llvm.lrint.i64.f64(double) nounwind readnone313declare i64 @llvm.lrint.i64.f80(x86_fp80) nounwind readnone314