[llvm] [RISCV] Merge ADDI and SIGN_EXTEND_INREG to ADDIW during selectSETCC. (PR #162614)
Craig Topper via llvm-commits
llvm-commits at lists.llvm.org
Thu Oct 9 07:10:57 PDT 2025
================
@@ -3353,14 +3353,19 @@ bool RISCVDAGToDAGISel::selectSETCC(SDValue N, ISD::CondCode ExpectedCCVal,
0);
return true;
}
- // If the RHS is [-2047,2048], we can use addi with -RHS to produce 0 if the
- // LHS is equal to the RHS and non-zero otherwise.
+ // If the RHS is [-2047,2048], we can use addi/addiw with -RHS to produce 0
+ // if the LHS is equal to the RHS and non-zero otherwise.
if (isInt<12>(CVal) || CVal == 2048) {
- Val = SDValue(
- CurDAG->getMachineNode(
- RISCV::ADDI, DL, N->getValueType(0), LHS,
- CurDAG->getSignedTargetConstant(-CVal, DL, N->getValueType(0))),
- 0);
+ unsigned Opc = RISCV::ADDI;
+ if (LHS.getOpcode() == ISD::SIGN_EXTEND_INREG) {
----------------
topperc wrote:
Do we need to check the VT in operand 1 of the SIGN_EXTEND_INREG?
https://github.com/llvm/llvm-project/pull/162614
More information about the llvm-commits
mailing list