Commit 0b7b21dc authored by Craig Topper's avatar Craig Topper
Browse files

[X86] Add test cases for regcall function that takes a long double as a...

[X86] Add test cases for regcall function that takes a long double as a parameter, but does not return a long double.

I believe we are incorrectly doing some FP stack manipulations
after the call.
parent dac98a22
Loading
Loading
Loading
Loading
+80 −0
Original line number Diff line number Diff line
@@ -524,6 +524,42 @@ define x86_regcallcc x86_fp80 @test_argRetf80(x86_fp80 %a0) nounwind {
  ret x86_fp80 %r0
}

; Test regcall when receiving/returning long double
define double @test_argParamf80(x86_fp80 %a0) nounwind {
; X32-LABEL: test_argParamf80:
; X32:       # %bb.0:
; X32-NEXT:    pushl %ebp
; X32-NEXT:    movl %esp, %ebp
; X32-NEXT:    andl $-8, %esp
; X32-NEXT:    subl $16, %esp
; X32-NEXT:    fldt 8(%ebp)
; X32-NEXT:    fstpl {{[0-9]+}}(%esp)
; X32-NEXT:    vmovsd {{.*#+}} xmm0 = mem[0],zero
; X32-NEXT:    vmovsd %xmm0, (%esp)
; X32-NEXT:    fldl (%esp)
; X32-NEXT:    movl %ebp, %esp
; X32-NEXT:    popl %ebp
; X32-NEXT:    retl
;
; WIN64-LABEL: test_argParamf80:
; WIN64:       # %bb.0:
; WIN64-NEXT:    pushq %rax
; WIN64-NEXT:    fldt (%rcx)
; WIN64-NEXT:    fstpl (%rsp)
; WIN64-NEXT:    vmovsd {{.*#+}} xmm0 = mem[0],zero
; WIN64-NEXT:    popq %rax
; WIN64-NEXT:    retq
;
; LINUXOSX64-LABEL: test_argParamf80:
; LINUXOSX64:       # %bb.0:
; LINUXOSX64-NEXT:    fldt {{[0-9]+}}(%rsp)
; LINUXOSX64-NEXT:    fstpl -{{[0-9]+}}(%rsp)
; LINUXOSX64-NEXT:    vmovsd {{.*#+}} xmm0 = mem[0],zero
; LINUXOSX64-NEXT:    retq
  %r0 = fptrunc x86_fp80 %a0 to double
  ret double %r0
}

; Test regcall when passing/retrieving long double
define x86_regcallcc x86_fp80 @test_CallargRetf80(x86_fp80 %a)  {
; X32-LABEL: test_CallargRetf80:
@@ -566,6 +602,50 @@ define x86_regcallcc x86_fp80 @test_CallargRetf80(x86_fp80 %a) {
  ret x86_fp80 %d
}

define x86_regcallcc double @test_CallargParamf80(x86_fp80 %a)  {
; X32-LABEL: test_CallargParamf80:
; X32:       # %bb.0:
; X32-NEXT:    pushl %esp
; X32-NEXT:    fadd %st, %st(0)
; X32-NEXT:    calll _test_argParamf80
; X32-NEXT:    vaddsd %xmm0, %xmm0, %xmm0
; X32-NEXT:    fstp %st(0)
; X32-NEXT:    popl %esp
; X32-NEXT:    retl
;
; WIN64-LABEL: test_CallargParamf80:
; WIN64:       # %bb.0:
; WIN64-NEXT:    pushq %rsp
; WIN64-NEXT:    .seh_pushreg %rsp
; WIN64-NEXT:    .seh_endprologue
; WIN64-NEXT:    fadd %st, %st(0)
; WIN64-NEXT:    callq test_argParamf80
; WIN64-NEXT:    vaddsd %xmm0, %xmm0, %xmm0
; WIN64-NEXT:    fstp %st(0)
; WIN64-NEXT:    popq %rsp
; WIN64-NEXT:    retq
; WIN64-NEXT:    .seh_handlerdata
; WIN64-NEXT:    .text
; WIN64-NEXT:    .seh_endproc
;
; LINUXOSX64-LABEL: test_CallargParamf80:
; LINUXOSX64:       # %bb.0:
; LINUXOSX64-NEXT:    pushq %rsp
; LINUXOSX64-NEXT:    .cfi_def_cfa_offset 16
; LINUXOSX64-NEXT:    .cfi_offset %rsp, -16
; LINUXOSX64-NEXT:    fadd %st, %st(0)
; LINUXOSX64-NEXT:    callq test_argParamf80
; LINUXOSX64-NEXT:    vaddsd %xmm0, %xmm0, %xmm0
; LINUXOSX64-NEXT:    fstp %st(0)
; LINUXOSX64-NEXT:    popq %rsp
; LINUXOSX64-NEXT:    .cfi_def_cfa_offset 8
; LINUXOSX64-NEXT:    retq
  %b = fadd x86_fp80 %a, %a
  %c = call x86_regcallcc double @test_argParamf80(x86_fp80 %b)
  %d = fadd double %c, %c
  ret double %d
}

; Test regcall when receiving/returning pointer
define x86_regcallcc [4 x i32]* @test_argRetPointer([4 x i32]* %a)  {
; X32-LABEL: test_argRetPointer: