[PATCH] D108933: [LegalizeTypes][X86] Improve ExpandIntRes_FP_TO_SINT/ExpandIntRes_FP_TO_UINT when input is SoftPromoteHalf.
Craig Topper via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Aug 30 13:13:14 PDT 2021
This revision was automatically updated to reflect the committed changes.
Closed by commit rG201f6446da56: [LegalizeTypes][X86] Improve ExpandIntRes_FP_TO_SINT/ExpandIntRes_FP_TO_UINT… (authored by craig.topper).
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D108933/new/
https://reviews.llvm.org/D108933
Files:
llvm/lib/CodeGen/SelectionDAG/LegalizeIntegerTypes.cpp
llvm/test/CodeGen/X86/half.ll
Index: llvm/test/CodeGen/X86/half.ll
===================================================================
--- llvm/test/CodeGen/X86/half.ll
+++ llvm/test/CodeGen/X86/half.ll
@@ -210,14 +210,23 @@
;
; CHECK-I686-LABEL: test_fptosi_i64:
; CHECK-I686: # %bb.0:
-; CHECK-I686-NEXT: subl $12, %esp
+; CHECK-I686-NEXT: subl $28, %esp
; CHECK-I686-NEXT: movl {{[0-9]+}}(%esp), %eax
; CHECK-I686-NEXT: movzwl (%eax), %eax
; CHECK-I686-NEXT: movl %eax, (%esp)
; CHECK-I686-NEXT: calll __gnu_h2f_ieee
-; CHECK-I686-NEXT: fstps (%esp)
-; CHECK-I686-NEXT: calll __fixsfdi
-; CHECK-I686-NEXT: addl $12, %esp
+; CHECK-I686-NEXT: fstps {{[0-9]+}}(%esp)
+; CHECK-I686-NEXT: flds {{[0-9]+}}(%esp)
+; CHECK-I686-NEXT: fnstcw {{[0-9]+}}(%esp)
+; CHECK-I686-NEXT: movzwl {{[0-9]+}}(%esp), %eax
+; CHECK-I686-NEXT: orl $3072, %eax # imm = 0xC00
+; CHECK-I686-NEXT: movw %ax, {{[0-9]+}}(%esp)
+; CHECK-I686-NEXT: fldcw {{[0-9]+}}(%esp)
+; CHECK-I686-NEXT: fistpll {{[0-9]+}}(%esp)
+; CHECK-I686-NEXT: fldcw {{[0-9]+}}(%esp)
+; CHECK-I686-NEXT: movl {{[0-9]+}}(%esp), %eax
+; CHECK-I686-NEXT: movl {{[0-9]+}}(%esp), %edx
+; CHECK-I686-NEXT: addl $28, %esp
; CHECK-I686-NEXT: retl
%a = load half, half* %p, align 2
%r = fptosi half %a to i64
@@ -295,14 +304,35 @@
;
; CHECK-I686-LABEL: test_fptoui_i64:
; CHECK-I686: # %bb.0:
-; CHECK-I686-NEXT: subl $12, %esp
+; CHECK-I686-NEXT: subl $28, %esp
; CHECK-I686-NEXT: movl {{[0-9]+}}(%esp), %eax
; CHECK-I686-NEXT: movzwl (%eax), %eax
; CHECK-I686-NEXT: movl %eax, (%esp)
; CHECK-I686-NEXT: calll __gnu_h2f_ieee
-; CHECK-I686-NEXT: fstps (%esp)
-; CHECK-I686-NEXT: calll __fixunssfdi
-; CHECK-I686-NEXT: addl $12, %esp
+; CHECK-I686-NEXT: fstps {{[0-9]+}}(%esp)
+; CHECK-I686-NEXT: movss {{.*#+}} xmm0 = mem[0],zero,zero,zero
+; CHECK-I686-NEXT: movss {{.*#+}} xmm1 = mem[0],zero,zero,zero
+; CHECK-I686-NEXT: ucomiss %xmm1, %xmm0
+; CHECK-I686-NEXT: jae .LBB9_2
+; CHECK-I686-NEXT: # %bb.1:
+; CHECK-I686-NEXT: xorps %xmm1, %xmm1
+; CHECK-I686-NEXT: .LBB9_2:
+; CHECK-I686-NEXT: subss %xmm1, %xmm0
+; CHECK-I686-NEXT: movss %xmm0, {{[0-9]+}}(%esp)
+; CHECK-I686-NEXT: setae %al
+; CHECK-I686-NEXT: flds {{[0-9]+}}(%esp)
+; CHECK-I686-NEXT: fnstcw {{[0-9]+}}(%esp)
+; CHECK-I686-NEXT: movzwl {{[0-9]+}}(%esp), %ecx
+; CHECK-I686-NEXT: orl $3072, %ecx # imm = 0xC00
+; CHECK-I686-NEXT: movw %cx, {{[0-9]+}}(%esp)
+; CHECK-I686-NEXT: fldcw {{[0-9]+}}(%esp)
+; CHECK-I686-NEXT: fistpll {{[0-9]+}}(%esp)
+; CHECK-I686-NEXT: fldcw {{[0-9]+}}(%esp)
+; CHECK-I686-NEXT: movzbl %al, %edx
+; CHECK-I686-NEXT: shll $31, %edx
+; CHECK-I686-NEXT: xorl {{[0-9]+}}(%esp), %edx
+; CHECK-I686-NEXT: movl {{[0-9]+}}(%esp), %eax
+; CHECK-I686-NEXT: addl $28, %esp
; CHECK-I686-NEXT: retl
%a = load half, half* %p, align 2
%r = fptoui half %a to i64
Index: llvm/lib/CodeGen/SelectionDAG/LegalizeIntegerTypes.cpp
===================================================================
--- llvm/lib/CodeGen/SelectionDAG/LegalizeIntegerTypes.cpp
+++ llvm/lib/CodeGen/SelectionDAG/LegalizeIntegerTypes.cpp
@@ -3093,6 +3093,9 @@
EVT NFPVT = TLI.getTypeToTransformTo(*DAG.getContext(), Op.getValueType());
Op = GetSoftPromotedHalf(Op);
Op = DAG.getNode(ISD::FP16_TO_FP, dl, NFPVT, Op);
+ Op = DAG.getNode(ISD::FP_TO_SINT, dl, VT, Op);
+ SplitInteger(Op, Lo, Hi);
+ return;
}
RTLIB::Libcall LC = RTLIB::getFPTOSINT(Op.getValueType(), VT);
@@ -3122,6 +3125,9 @@
EVT NFPVT = TLI.getTypeToTransformTo(*DAG.getContext(), Op.getValueType());
Op = GetSoftPromotedHalf(Op);
Op = DAG.getNode(ISD::FP16_TO_FP, dl, NFPVT, Op);
+ Op = DAG.getNode(ISD::FP_TO_UINT, dl, VT, Op);
+ SplitInteger(Op, Lo, Hi);
+ return;
}
RTLIB::Libcall LC = RTLIB::getFPTOUINT(Op.getValueType(), VT);
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D108933.369534.patch
Type: text/x-patch
Size: 3929 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210830/5454502e/attachment.bin>
More information about the llvm-commits
mailing list