Skip to content

Commit fee9067

Browse files
committed
[X86] Move all the FP_TO_XINT/XINT_TO_FP setOperationActions into the same !useSoftFloat block. Qualify all of the Promote actions for these with !useSoftFloat too. NFCI
The Promote action doesn't apply until LegalizeDAG. By the time we get there, we would have already softened all the FP operations if useSoftFloat was true. So there wouldn't be any operation left to Promote.
1 parent 3d30c14 commit fee9067

File tree

1 file changed

+28
-41
lines changed

1 file changed

+28
-41
lines changed

llvm/lib/Target/X86/X86ISelLowering.cpp

Lines changed: 28 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -223,56 +223,43 @@ X86TargetLowering::X86TargetLowering(const X86TargetMachine &TM,
223223
setOperationAction(ShiftOp , MVT::i64 , Custom);
224224
}
225225

226-
// Promote all UINT_TO_FP to larger SINT_TO_FP's, as X86 doesn't have this
227-
// operation.
228-
setOperationAction(ISD::UINT_TO_FP , MVT::i8 , Promote);
229-
setOperationAction(ISD::UINT_TO_FP , MVT::i16 , Promote);
230-
231226
if (!Subtarget.useSoftFloat()) {
232-
// We have an algorithm for SSE2->double, and we turn this into a
233-
// 64-bit FILD followed by conditional FADD for other targets.
234-
setOperationAction(ISD::UINT_TO_FP , MVT::i64 , Custom);
227+
// Promote all UINT_TO_FP to larger SINT_TO_FP's, as X86 doesn't have this
228+
// operation.
229+
setOperationAction(ISD::UINT_TO_FP, MVT::i8, Promote);
230+
setOperationAction(ISD::UINT_TO_FP, MVT::i16, Promote);
235231
// We have an algorithm for SSE2, and we turn this into a 64-bit
236232
// FILD or VCVTUSI2SS/SD for other targets.
237-
setOperationAction(ISD::UINT_TO_FP , MVT::i32 , Custom);
238-
}
239-
240-
// Promote i8 SINT_TO_FP to larger SINT_TO_FP's, as X86 doesn't have
241-
// this operation.
242-
setOperationAction(ISD::SINT_TO_FP , MVT::i8 , Promote);
233+
setOperationAction(ISD::UINT_TO_FP, MVT::i32, Custom);
234+
// We have an algorithm for SSE2->double, and we turn this into a
235+
// 64-bit FILD followed by conditional FADD for other targets.
236+
setOperationAction(ISD::UINT_TO_FP, MVT::i64, Custom);
243237

244-
if (!Subtarget.useSoftFloat()) {
238+
// Promote i8 SINT_TO_FP to larger SINT_TO_FP's, as X86 doesn't have
239+
// this operation.
240+
setOperationAction(ISD::SINT_TO_FP, MVT::i8, Promote);
245241
// SSE has no i16 to fp conversion, only i32.
246-
if (X86ScalarSSEf32) {
247-
setOperationAction(ISD::SINT_TO_FP , MVT::i16 , Promote);
248-
// f32 and f64 cases are Legal, f80 case is not
249-
setOperationAction(ISD::SINT_TO_FP , MVT::i32 , Custom);
250-
} else {
251-
setOperationAction(ISD::SINT_TO_FP , MVT::i16 , Custom);
252-
setOperationAction(ISD::SINT_TO_FP , MVT::i32 , Custom);
253-
}
254-
}
255-
256-
// Promote i8 FP_TO_SINT to larger FP_TO_SINTS's, as X86 doesn't have
257-
// this operation.
258-
setOperationAction(ISD::FP_TO_SINT , MVT::i8 , Promote);
259-
260-
if (!Subtarget.useSoftFloat()) {
242+
setOperationAction(ISD::SINT_TO_FP, MVT::i16, X86ScalarSSEf32 ? Promote
243+
: Custom);
244+
// f32 and f64 cases are Legal with SSE1/SSE2, f80 case is not
245+
setOperationAction(ISD::SINT_TO_FP, MVT::i32, Custom);
261246
// In 32-bit mode these are custom lowered. In 64-bit mode F32 and F64
262247
// are Legal, f80 is custom lowered.
263-
setOperationAction(ISD::FP_TO_SINT , MVT::i64 , Custom);
264-
setOperationAction(ISD::SINT_TO_FP , MVT::i64 , Custom);
248+
setOperationAction(ISD::SINT_TO_FP, MVT::i64, Custom);
265249

266-
setOperationAction(ISD::FP_TO_SINT , MVT::i16 , Custom);
267-
setOperationAction(ISD::FP_TO_SINT , MVT::i32 , Custom);
268-
}
269-
270-
// Handle FP_TO_UINT by promoting the destination to a larger signed
271-
// conversion.
272-
setOperationAction(ISD::FP_TO_UINT , MVT::i8 , Promote);
273-
setOperationAction(ISD::FP_TO_UINT , MVT::i16 , Promote);
250+
// Promote i8 FP_TO_SINT to larger FP_TO_SINTS's, as X86 doesn't have
251+
// this operation.
252+
setOperationAction(ISD::FP_TO_SINT, MVT::i8, Promote);
253+
setOperationAction(ISD::FP_TO_SINT, MVT::i16, Custom);
254+
setOperationAction(ISD::FP_TO_SINT, MVT::i32, Custom);
255+
// In 32-bit mode these are custom lowered. In 64-bit mode F32 and F64
256+
// are Legal, f80 is custom lowered.
257+
setOperationAction(ISD::FP_TO_SINT, MVT::i64, Custom);
274258

275-
if (!Subtarget.useSoftFloat()) {
259+
// Handle FP_TO_UINT by promoting the destination to a larger signed
260+
// conversion.
261+
setOperationAction(ISD::FP_TO_UINT, MVT::i8, Promote);
262+
setOperationAction(ISD::FP_TO_UINT, MVT::i16, Promote);
276263
setOperationAction(ISD::FP_TO_UINT, MVT::i32, Custom);
277264
setOperationAction(ISD::FP_TO_UINT, MVT::i64, Custom);
278265
}

0 commit comments

Comments
 (0)