Skip to content

Commit

Permalink
[RISCV] Merge ReplaceNodeResults code for SHFL and GREV/GORC. NFC
Browse files Browse the repository at this point in the history
  • Loading branch information
topperc committed Mar 14, 2022
1 parent ec06edc commit eeb3bfd
Showing 1 changed file with 2 additions and 16 deletions.
18 changes: 2 additions & 16 deletions llvm/lib/Target/RISCV/RISCVISelLowering.cpp
Expand Up @@ -6816,7 +6816,8 @@ void RISCVTargetLowering::ReplaceNodeResults(SDNode *N,
break;
}
case RISCVISD::GREV:
case RISCVISD::GORC: {
case RISCVISD::GORC:
case RISCVISD::SHFL: {
MVT VT = N->getSimpleValueType(0);
MVT XLenVT = Subtarget.getXLenVT();
assert((VT == MVT::i16 || (VT == MVT::i32 && Subtarget.is64Bit())) &&
Expand All @@ -6835,21 +6836,6 @@ void RISCVTargetLowering::ReplaceNodeResults(SDNode *N,
Results.push_back(DAG.getNode(ISD::TRUNCATE, DL, VT, NewRes));
break;
}
case RISCVISD::SHFL: {
// There is no SHFLIW instruction, but we can just promote the operation.
assert(N->getValueType(0) == MVT::i32 && Subtarget.is64Bit() &&
"Unexpected custom legalisation");
assert(isa<ConstantSDNode>(N->getOperand(1)) && "Expected constant");
SDValue NewOp0 =
DAG.getNode(ISD::ANY_EXTEND, DL, MVT::i64, N->getOperand(0));
SDValue NewOp1 =
DAG.getNode(ISD::ZERO_EXTEND, DL, MVT::i64, N->getOperand(1));
SDValue NewRes = DAG.getNode(RISCVISD::SHFL, DL, MVT::i64, NewOp0, NewOp1);
// ReplaceNodeResults requires we maintain the same type for the return
// value.
Results.push_back(DAG.getNode(ISD::TRUNCATE, DL, MVT::i32, NewRes));
break;
}
case ISD::BSWAP:
case ISD::BITREVERSE: {
MVT VT = N->getSimpleValueType(0);
Expand Down

0 comments on commit eeb3bfd

Please sign in to comment.