1 ; RUN: llc < %s -mtriple=i686-pc-win32 | FileCheck %s -check-prefix=FTOL
2 ; RUN: llc < %s -mtriple=i686-pc-mingw32 | FileCheck %s -check-prefix=COMPILERRT
3 ; RUN: llc < %s -mtriple=i686-pc-linux | FileCheck %s -check-prefix=COMPILERRT
4 ; RUN: llc < %s -mtriple=x86_64-pc-win32 | FileCheck %s -check-prefix=COMPILERRT
5 ; RUN: llc < %s -mtriple=x86_64-pc-mingw32 | FileCheck %s -check-prefix=COMPILERRT
6 ; RUN: llc < %s -mtriple=x86_64-pc-linux | FileCheck %s -check-prefix=COMPILERRT
7 ; RUN: llc < %s -mattr=-sse -O0 -mtriple=i686-pc-win32 | FileCheck %s -check-prefix=FTOL_2
9 ; Win32 targets use the MSVCRT _ftol2 runtime function for fptoui to i64. This
10 ; function has a nonstandard calling convention: the input value is expected on
11 ; the x87 stack instead of the callstack. The input value is popped by the
12 ; callee. Mingw32 uses normal cdecl compiler-rt functions.
14 define i64 @double_ui64(double %x) nounwind {
16 ; COMPILERRT: @double_ui64
17 ; COMPILERRT-NOT: calll __ftol2
22 %0 = fptoui double %x to i64
26 define i64 @float_ui64(float %x) nounwind {
28 ; COMPILERRT: @float_ui64
29 ; COMPILERRT-NOT: calll __ftol2
34 %0 = fptoui float %x to i64
38 define i64 @double_ui64_2(double %x, double %y, double %z) nounwind {
39 ; COMPILERRT: @double_ui64_2
40 ; FTOL: @double_ui64_2
41 ; FTOL_2: @double_ui64_2
49 ; FTOL_2: fdiv %st(0), %st(1)
51 ; FTOL_2: fsubp %st(2)
57 ; FTOL_2: calll __ftol2
61 ; FTOL_2: calll __ftol2
64 %1 = fdiv double %x, %y
65 %2 = fsub double %x, %z
66 %3 = fptoui double %1 to i64
67 %4 = fptoui double %2 to i64
72 define i64 @double_ui64_3(double %x, double %y, double %z) nounwind {
73 ; COMPILERRT: @double_ui64_3
74 ; FTOL: @double_ui64_3
75 ; FTOL_2: @double_ui64_3
83 ; FTOL_2: fdiv %st(0), %st(1)
85 ; FTOL_2: fsubp %st(2)
90 ;; stack is %1 %2 (still)
91 ; FTOL_2: calll __ftol2
95 ; FTOL_2: calll __ftol2
98 %1 = fdiv double %x, %y
99 %2 = fsub double %x, %z
100 %3 = fptoui double %1 to i64
101 %4 = fptoui double %2 to i64
106 define {double, i64} @double_ui64_4(double %x, double %y) nounwind {
107 ; COMPILERRT: @double_ui64_4
108 ; FTOL: @double_ui64_4
109 ; FTOL_2: @double_ui64_4
117 ; FTOL_2: calll __ftol2
121 ; FTOL_2: calll __ftol2
124 %1 = fptoui double %x to i64
125 %2 = fptoui double %y to i64
127 %4 = insertvalue {double, i64} undef, double %x, 0
128 %5 = insertvalue {double, i64} %4, i64 %3, 1
132 define i32 @double_ui32_5(double %X) {
133 ; FTOL: @double_ui32_5
134 ; FTOL: calll __ftol2
135 %tmp.1 = fptoui double %X to i32
139 define i64 @double_ui64_5(double %X) {
140 ; FTOL: @double_ui64_5
141 ; FTOL: calll __ftol2
142 %tmp.1 = fptoui double %X to i64