[llvm] Support STRICT_UINT_TO_FP and STRICT_SINT_TO_FP (PR #102503)
Mikhail R. Gadelha via llvm-commits
llvm-commits at lists.llvm.org
Fri Sep 6 11:30:57 PDT 2024
================
@@ -3537,17 +3531,26 @@ SDValue DAGTypeLegalizer::SoftPromoteHalfOp_FP_EXTEND(SDNode *N) {
SDValue DAGTypeLegalizer::SoftPromoteHalfOp_FP_TO_XINT(SDNode *N) {
EVT RVT = N->getValueType(0);
- SDValue Op = N->getOperand(0);
+ bool IsStrict = N->isStrictFPOpcode();
+ SDValue Op = N->getOperand(IsStrict ? 1 : 0);
EVT SVT = Op.getValueType();
SDLoc dl(N);
- EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(), Op.getValueType());
-
+ EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(), SVT);
Op = GetSoftPromotedHalf(Op);
- SDValue Res = DAG.getNode(GetPromotionOpcode(SVT, RVT), dl, NVT, Op);
+ if (IsStrict) {
+ Op = DAG.getNode(GetPromotionOpcodeStrict(SVT, RVT), dl, {NVT, MVT::Other},
+ {N->getOperand(0), Op});
+ Op = DAG.getNode(N->getOpcode(), dl, {RVT, MVT::Other},
+ {Op.getValue(1), Op});
+ ReplaceValueWith(SDValue(N, 1), Op.getValue(1));
+ DAG.ReplaceAllUsesOfValueWith(SDValue(N, 1), Op.getValue(1));
----------------
mikhailramalho wrote:
yeah... I can try to move the code used by both methods to a separate function and just ignore the return in `SoftPromoteHalfOp_FP_TO_XINT` but I think current approach is cleaner
https://github.com/llvm/llvm-project/pull/102503
More information about the llvm-commits
mailing list