[llvm] [ARM] Add strict uint to FP conversion handling during operation legalization (PR #208554)
David Green via llvm-commits
llvm-commits at lists.llvm.org
Tue Jul 14 06:33:34 PDT 2026
================
@@ -5838,19 +5844,37 @@ static SDValue LowerVectorINT_TO_FP(SDValue Op, SelectionDAG &DAG) {
SDValue ARMTargetLowering::LowerINT_TO_FP(SDValue Op, SelectionDAG &DAG) const {
EVT VT = Op.getValueType();
- if (VT.isVector())
+ if (VT.isVector()) {
return LowerVectorINT_TO_FP(Op, DAG);
+ }
+
+ bool IsStrict = Op->isStrictFPOpcode();
+ SDValue SrcVal = Op.getOperand(IsStrict ? 1 : 0);
+
if (isUnsupportedFloatingType(VT)) {
RTLIB::Libcall LC;
- if (Op.getOpcode() == ISD::SINT_TO_FP)
- LC = RTLIB::getSINTTOFP(Op.getOperand(0).getValueType(),
- Op.getValueType());
+ if (Op.getOpcode() == ISD::SINT_TO_FP ||
+ Op.getOpcode() == ISD::STRICT_SINT_TO_FP)
+ LC = RTLIB::getSINTTOFP(SrcVal.getValueType(), Op.getValueType());
else
- LC = RTLIB::getUINTTOFP(Op.getOperand(0).getValueType(),
- Op.getValueType());
+ LC = RTLIB::getUINTTOFP(SrcVal.getValueType(), Op.getValueType());
+ SDLoc Loc(Op);
MakeLibCallOptions CallOptions;
- return makeLibCall(DAG, LC, Op.getValueType(), Op.getOperand(0),
- CallOptions, SDLoc(Op)).first;
+ SDValue Chain = IsStrict ? Op.getOperand(0) : SDValue();
+ SDValue Result;
+ std::tie(Result, Chain) = makeLibCall(DAG, LC, Op.getValueType(), SrcVal,
+ CallOptions, Loc, Chain);
+ return IsStrict ? DAG.getMergeValues({Result, Chain}, Loc) : Result;
+ }
+
+ // FIXME: Remove this when we have strict fp instruction selection patterns
----------------
davemgreen wrote:
> IsStrict is handled separately in order to preserve chain - would the any_sint_to_fp pattern preserve chain as well?
I believe so. I'm not sure if this version properly preserves the chain and I would expect the strict nodes to be used until selection, so that the chain can be kept in place.
https://github.com/llvm/llvm-project/pull/208554
More information about the llvm-commits
mailing list