[llvm] 8265679 - [RISCV][NFC] Refactor the type promotion of fsl/fsr/becompress/bdecompress/bfp
Ben Shi via llvm-commits
llvm-commits at lists.llvm.org
Wed Apr 13 01:52:14 PDT 2022
Author: Liqin Weng
Date: 2022-04-13T08:52:04Z
New Revision: 8265679018c8807a80586db0ea8d22fd7b82aacd
URL: https://github.com/llvm/llvm-project/commit/8265679018c8807a80586db0ea8d22fd7b82aacd
DIFF: https://github.com/llvm/llvm-project/commit/8265679018c8807a80586db0ea8d22fd7b82aacd.diff
LOG: [RISCV][NFC] Refactor the type promotion of fsl/fsr/becompress/bdecompress/bfp
Reviewed By: asb, jrtc27, craig.topper, frasercrmck
Differential Revision: https://reviews.llvm.org/D123181
Added:
Modified:
llvm/lib/Target/RISCV/RISCVISelLowering.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Target/RISCV/RISCVISelLowering.cpp b/llvm/lib/Target/RISCV/RISCVISelLowering.cpp
index e4e2263e09ec0..c10401e878840 100644
--- a/llvm/lib/Target/RISCV/RISCVISelLowering.cpp
+++ b/llvm/lib/Target/RISCV/RISCVISelLowering.cpp
@@ -6635,9 +6635,12 @@ static SDValue customLegalizeToWOpByIntr(SDNode *N, SelectionDAG &DAG,
unsigned IntNo) {
SDLoc DL(N);
RISCVISD::NodeType WOpcode = getRISCVWOpcodeByIntr(IntNo);
- SDValue NewOp1 = DAG.getNode(ISD::ANY_EXTEND, DL, MVT::i64, N->getOperand(1));
- SDValue NewOp2 = DAG.getNode(ISD::ANY_EXTEND, DL, MVT::i64, N->getOperand(2));
- SDValue NewRes = DAG.getNode(WOpcode, DL, MVT::i64, NewOp1, NewOp2);
+ // Deal with the Instruction Operands
+ SmallVector<SDValue, 3> NewOps;
+ for (SDValue Op : drop_begin(N->ops()))
+ // Promote the operand to i64 type
+ NewOps.push_back(DAG.getNode(ISD::ANY_EXTEND, DL, MVT::i64, Op));
+ SDValue NewRes = DAG.getNode(WOpcode, DL, MVT::i64, NewOps);
// ReplaceNodeResults requires we maintain the same type for the return value.
return DAG.getNode(ISD::TRUNCATE, DL, N->getValueType(0), NewRes);
}
@@ -7153,25 +7156,12 @@ void RISCVTargetLowering::ReplaceNodeResults(SDNode *N,
}
case Intrinsic::riscv_bcompress:
case Intrinsic::riscv_bdecompress:
- case Intrinsic::riscv_bfp: {
- assert(N->getValueType(0) == MVT::i32 && Subtarget.is64Bit() &&
- "Unexpected custom legalisation");
- Results.push_back(customLegalizeToWOpByIntr(N, DAG, IntNo));
- break;
- }
+ case Intrinsic::riscv_bfp:
case Intrinsic::riscv_fsl:
case Intrinsic::riscv_fsr: {
assert(N->getValueType(0) == MVT::i32 && Subtarget.is64Bit() &&
"Unexpected custom legalisation");
- SDValue NewOp1 =
- DAG.getNode(ISD::ANY_EXTEND, DL, MVT::i64, N->getOperand(1));
- SDValue NewOp2 =
- DAG.getNode(ISD::ANY_EXTEND, DL, MVT::i64, N->getOperand(2));
- SDValue NewOp3 =
- DAG.getNode(ISD::ANY_EXTEND, DL, MVT::i64, N->getOperand(3));
- unsigned Opc = getRISCVWOpcodeByIntr(IntNo);
- SDValue Res = DAG.getNode(Opc, DL, MVT::i64, NewOp1, NewOp2, NewOp3);
- Results.push_back(DAG.getNode(ISD::TRUNCATE, DL, MVT::i32, Res));
+ Results.push_back(customLegalizeToWOpByIntr(N, DAG, IntNo));
break;
}
case Intrinsic::riscv_orc_b: {
More information about the llvm-commits
mailing list