Index: llvm/lib/Target/RISCV/RISCVISelLowering.cpp =================================================================== --- llvm/lib/Target/RISCV/RISCVISelLowering.cpp +++ llvm/lib/Target/RISCV/RISCVISelLowering.cpp @@ -1071,9 +1071,12 @@ SDValue RHS = N->getOperand(1); APInt LHSMask = APInt::getLowBitsSet(LHS.getValueSizeInBits(), 32); APInt RHSMask = APInt::getLowBitsSet(RHS.getValueSizeInBits(), 5); - if ((SimplifyDemandedBits(N->getOperand(0), LHSMask, DCI)) || - (SimplifyDemandedBits(N->getOperand(1), RHSMask, DCI))) - return SDValue(); + if (SimplifyDemandedBits(N->getOperand(0), LHSMask, DCI) || + SimplifyDemandedBits(N->getOperand(1), RHSMask, DCI)) { + if (N->getOpcode() != ISD::DELETED_NODE) + DCI.AddToWorklist(N); + return SDValue(N, 0); + } break; } case RISCVISD::FMV_X_ANYEXTW_RV64: { Index: llvm/test/CodeGen/RISCV/rv64i-demanded-bits.ll =================================================================== --- llvm/test/CodeGen/RISCV/rv64i-demanded-bits.ll +++ llvm/test/CodeGen/RISCV/rv64i-demanded-bits.ll @@ -14,8 +14,6 @@ ; CHECK-NEXT: mul a0, a0, a0 ; CHECK-NEXT: add a0, a0, a2 ; CHECK-NEXT: addi a0, a0, 1 -; CHECK-NEXT: slli a1, a1, 32 -; CHECK-NEXT: srli a1, a1, 32 ; CHECK-NEXT: sllw a0, a0, a1 ; CHECK-NEXT: ret %b = mul i32 %x, %x