Skip to content

Commit 1692dff

Browse files
committedJan 20, 2023
Revert "[X86] Avoid converting u64 to f32 using x87 on Windows"
This reverts commit a6e3027. Chrome and Halide are both reporting issues with importing builtins. Maybe the better direction is to manually adjust FPCW for the inline sequence on Windows.
1 parent f37614b commit 1692dff

File tree

2 files changed

+2
-41
lines changed

2 files changed

+2
-41
lines changed
 

‎llvm/lib/Target/X86/X86ISelLowering.cpp

-7
Original file line numberDiff line numberDiff line change
@@ -21898,13 +21898,6 @@ SDValue X86TargetLowering::LowerUINT_TO_FP(SDValue Op,
2189821898
}
2189921899

2190021900
assert(SrcVT == MVT::i64 && "Unexpected type in UINT_TO_FP");
21901-
21902-
// On Windows, the default precision control on x87 is only 53-bit, and FADD
21903-
// triggers rounding with that precision, so the final result may be less
21904-
// accurate. 18014397972611071 is one such case.
21905-
if (Subtarget.isOSWindows())
21906-
return SDValue();
21907-
2190821901
SDValue ValueToStore = Src;
2190921902
if (isScalarFPTypeInSSEReg(Op.getValueType()) && !Subtarget.is64Bit()) {
2191021903
// Bitcasting to f64 here allows us to do a single 64-bit store from

‎llvm/test/CodeGen/X86/uint64-to-float.ll

+2-34
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
; 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
2+
; RUN: llc < %s -mtriple=i686-apple-unknown -mattr=+sse2 | FileCheck %s --check-prefix=X86
3+
; RUN: llc < %s -mtriple=x86_64-apple-unknown -mattr=+sse2 | FileCheck %s --check-prefix=X64
64

75
; Verify that we are using the efficient uitofp --> sitofp lowering illustrated
86
; by the compiler_rt implementation of __floatundisf.
@@ -44,36 +42,6 @@ define float @test(i64 %a) nounwind {
4442
; X64-NEXT: cvtsi2ss %rdi, %xmm0
4543
; X64-NEXT: addss %xmm0, %xmm0
4644
; 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 $8, %esp
54-
; X86-WIN-NEXT: pushl 12(%ebp)
55-
; X86-WIN-NEXT: pushl 8(%ebp)
56-
; X86-WIN-NEXT: calll ___floatundisf
57-
; X86-WIN-NEXT: addl $8, %esp
58-
; X86-WIN-NEXT: movl %ebp, %esp
59-
; X86-WIN-NEXT: popl %ebp
60-
; X86-WIN-NEXT: retl
61-
;
62-
; X64-WIN-LABEL: test:
63-
; X64-WIN: # %bb.0: # %entry
64-
; X64-WIN-NEXT: testq %rcx, %rcx
65-
; X64-WIN-NEXT: js .LBB0_1
66-
; X64-WIN-NEXT: # %bb.2: # %entry
67-
; X64-WIN-NEXT: cvtsi2ss %rcx, %xmm0
68-
; X64-WIN-NEXT: retq
69-
; X64-WIN-NEXT: .LBB0_1:
70-
; X64-WIN-NEXT: movq %rcx, %rax
71-
; X64-WIN-NEXT: shrq %rax
72-
; X64-WIN-NEXT: andl $1, %ecx
73-
; X64-WIN-NEXT: orq %rax, %rcx
74-
; X64-WIN-NEXT: cvtsi2ss %rcx, %xmm0
75-
; X64-WIN-NEXT: addss %xmm0, %xmm0
76-
; X64-WIN-NEXT: retq
7745
entry:
7846
%b = uitofp i64 %a to float
7947
ret float %b

0 commit comments

Comments
 (0)
Please sign in to comment.