1; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py 2; RUN: llc < %s -mtriple=i686-unknown -mattr=+sse2 | FileCheck %s --check-prefix=X86 3; RUN: llc < %s -mtriple=x86_64-unknown -mattr=+sse2 | FileCheck %s --check-prefix=X64 4; RUN: llc < %s -mtriple=i686-windows -mattr=+sse2 | FileCheck %s --check-prefix=X86-WIN 5; RUN: llc < %s -mtriple=x86_64-windows -mattr=+sse2 | FileCheck %s --check-prefix=X64-WIN 6 7; Verify that we are using the efficient uitofp --> sitofp lowering illustrated 8; by the compiler_rt implementation of __floatundisf. 9; <rdar://problem/8493982> 10 11define float @test(i64 %a) nounwind { 12; X86-LABEL: test: 13; X86: # %bb.0: # %entry 14; X86-NEXT: pushl %ebp 15; X86-NEXT: movl %esp, %ebp 16; X86-NEXT: andl $-8, %esp 17; X86-NEXT: subl $16, %esp 18; X86-NEXT: movl 12(%ebp), %eax 19; X86-NEXT: movsd {{.*#+}} xmm0 = mem[0],zero 20; X86-NEXT: movlps %xmm0, {{[0-9]+}}(%esp) 21; X86-NEXT: shrl $31, %eax 22; X86-NEXT: fildll {{[0-9]+}}(%esp) 23; X86-NEXT: fadds {{\.?LCPI[0-9]+_[0-9]+}}(,%eax,4) 24; X86-NEXT: fstps {{[0-9]+}}(%esp) 25; X86-NEXT: movss {{.*#+}} xmm0 = mem[0],zero,zero,zero 26; X86-NEXT: movss %xmm0, (%esp) 27; X86-NEXT: flds (%esp) 28; X86-NEXT: movl %ebp, %esp 29; X86-NEXT: popl %ebp 30; X86-NEXT: retl 31; 32; X64-LABEL: test: 33; X64: # %bb.0: # %entry 34; X64-NEXT: testq %rdi, %rdi 35; X64-NEXT: js .LBB0_1 36; X64-NEXT: # %bb.2: # %entry 37; X64-NEXT: cvtsi2ss %rdi, %xmm0 38; X64-NEXT: retq 39; X64-NEXT: .LBB0_1: 40; X64-NEXT: movq %rdi, %rax 41; X64-NEXT: shrq %rax 42; X64-NEXT: andl $1, %edi 43; X64-NEXT: orq %rax, %rdi 44; X64-NEXT: cvtsi2ss %rdi, %xmm0 45; X64-NEXT: addss %xmm0, %xmm0 46; X64-NEXT: retq 47; 48; X86-WIN-LABEL: test: 49; X86-WIN: # %bb.0: # %entry 50; X86-WIN-NEXT: pushl %ebp 51; X86-WIN-NEXT: movl %esp, %ebp 52; X86-WIN-NEXT: andl $-8, %esp 53; X86-WIN-NEXT: subl $24, %esp 54; X86-WIN-NEXT: movl 12(%ebp), %eax 55; X86-WIN-NEXT: movsd {{.*#+}} xmm0 = mem[0],zero 56; X86-WIN-NEXT: movlps %xmm0, {{[0-9]+}}(%esp) 57; X86-WIN-NEXT: shrl $31, %eax 58; X86-WIN-NEXT: fildll {{[0-9]+}}(%esp) 59; X86-WIN-NEXT: fnstcw {{[0-9]+}}(%esp) 60; X86-WIN-NEXT: movzwl {{[0-9]+}}(%esp), %ecx 61; X86-WIN-NEXT: orl $768, %ecx # imm = 0x300 62; X86-WIN-NEXT: movw %cx, {{[0-9]+}}(%esp) 63; X86-WIN-NEXT: fldcw {{[0-9]+}}(%esp) 64; X86-WIN-NEXT: fadds __real@5f80000000000000(,%eax,4) 65; X86-WIN-NEXT: fldcw {{[0-9]+}}(%esp) 66; X86-WIN-NEXT: fstps {{[0-9]+}}(%esp) 67; X86-WIN-NEXT: movss {{.*#+}} xmm0 = mem[0],zero,zero,zero 68; X86-WIN-NEXT: movss %xmm0, {{[0-9]+}}(%esp) 69; X86-WIN-NEXT: flds {{[0-9]+}}(%esp) 70; X86-WIN-NEXT: movl %ebp, %esp 71; X86-WIN-NEXT: popl %ebp 72; X86-WIN-NEXT: retl 73; 74; X64-WIN-LABEL: test: 75; X64-WIN: # %bb.0: # %entry 76; X64-WIN-NEXT: testq %rcx, %rcx 77; X64-WIN-NEXT: js .LBB0_1 78; X64-WIN-NEXT: # %bb.2: # %entry 79; X64-WIN-NEXT: cvtsi2ss %rcx, %xmm0 80; X64-WIN-NEXT: retq 81; X64-WIN-NEXT: .LBB0_1: 82; X64-WIN-NEXT: movq %rcx, %rax 83; X64-WIN-NEXT: shrq %rax 84; X64-WIN-NEXT: andl $1, %ecx 85; X64-WIN-NEXT: orq %rax, %rcx 86; X64-WIN-NEXT: cvtsi2ss %rcx, %xmm0 87; X64-WIN-NEXT: addss %xmm0, %xmm0 88; X64-WIN-NEXT: retq 89entry: 90 %b = uitofp i64 %a to float 91 ret float %b 92} 93