[PATCH] D45572: [X86] Replace action Promote with Custom for operation ISD::SINT_TO_FP
Vyacheslav via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Apr 12 08:26:35 PDT 2018
vrybalov created this revision.
Herald added a subscriber: llvm-commits.
If attribute "use-soft-float"="true" is set then X86ISelLowering.cpp sets 'Promote' action for ISD::SINT_TO_FP operation on type i32.
But 'Promote' action is not proper in this case since lib function __floatsidf is available for casting from signed int to float type. Thus Custom action is more suitable here.
If function attribute "use-soft-float"="true" is set then infinite looping can happen in DAG combining, function visitSINT_TO_FP() replaces SINT_TO_FP node with UINT_TO_FP node and function combineUIntToFP() replace vice versa in cycle. The fix prevents it.
Repository:
rL LLVM
https://reviews.llvm.org/D45572
Files:
lib/Target/X86/X86ISelLowering.cpp
test/CodeGen/X86/sitofp.ll
Index: test/CodeGen/X86/sitofp.ll
===================================================================
--- /dev/null
+++ test/CodeGen/X86/sitofp.ll
@@ -0,0 +1,17 @@
+; RUN: llc < %s
+
+target triple = "i386-unknown-linux-gnu"
+
+define void @foo() #0 {
+entry:
+ %a = alloca i16, align 2
+ %b = alloca double, align 4
+ %0 = load i16, i16* %a, align 2
+ %conv = zext i16 %0 to i32
+ %conv1 = sitofp i32 %conv to double
+ %add = fadd double %conv1, 0.000000e+00
+ store double %add, double* %b, align 4
+ ret void
+}
+
+attributes #0 = { "use-soft-float"="true" }
Index: lib/Target/X86/X86ISelLowering.cpp
===================================================================
--- lib/Target/X86/X86ISelLowering.cpp
+++ lib/Target/X86/X86ISelLowering.cpp
@@ -235,7 +235,7 @@
}
} else {
setOperationAction(ISD::SINT_TO_FP , MVT::i16 , Promote);
- setOperationAction(ISD::SINT_TO_FP , MVT::i32 , Promote);
+ setOperationAction(ISD::SINT_TO_FP , MVT::i32 , Custom);
}
// Promote i1/i8 FP_TO_SINT to larger FP_TO_SINTS's, as X86 doesn't have
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D45572.142191.patch
Type: text/x-patch
Size: 1083 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180412/195aaa68/attachment.bin>
More information about the llvm-commits
mailing list