Index: llvm/lib/Target/RISCV/RISCVInstrInfoM.td =================================================================== --- llvm/lib/Target/RISCV/RISCVInstrInfoM.td +++ llvm/lib/Target/RISCV/RISCVInstrInfoM.td @@ -78,14 +78,6 @@ def : PatGprGpr; def : PatGprGpr; -// Handle the specific cases where using DIVU/REMU would be correct and result -// in fewer instructions than emitting DIVUW/REMUW then zero-extending the -// result. -def : Pat<(zexti32 (riscv_divuw (zexti32 GPR:$rs1), (zexti32 GPR:$rs2))), - (DIVU GPR:$rs1, GPR:$rs2)>; -def : Pat<(zexti32 (riscv_remuw (zexti32 GPR:$rs1), (zexti32 GPR:$rs2))), - (REMU GPR:$rs1, GPR:$rs2)>; - // Although the sexti32 operands may not have originated from an i32 srem, // this pattern is safe as it is impossible for two sign extended inputs to // produce a result where res[63:32]=0 and res[31]=1. Index: llvm/test/CodeGen/RISCV/rv64m-exhaustive-w-insts.ll =================================================================== --- llvm/test/CodeGen/RISCV/rv64m-exhaustive-w-insts.ll +++ llvm/test/CodeGen/RISCV/rv64m-exhaustive-w-insts.ll @@ -520,7 +520,9 @@ define zeroext i32 @zext_divuw_zext_zext(i32 zeroext %a, i32 zeroext %b) nounwind { ; RV64IM-LABEL: zext_divuw_zext_zext: ; RV64IM: # %bb.0: -; RV64IM-NEXT: divu a0, a0, a1 +; RV64IM-NEXT: divuw a0, a0, a1 +; RV64IM-NEXT: slli a0, a0, 32 +; RV64IM-NEXT: srli a0, a0, 32 ; RV64IM-NEXT: ret %1 = udiv i32 %a, %b ret i32 %1 @@ -1301,7 +1303,9 @@ define zeroext i32 @zext_remuw_zext_zext(i32 zeroext %a, i32 zeroext %b) nounwind { ; RV64IM-LABEL: zext_remuw_zext_zext: ; RV64IM: # %bb.0: -; RV64IM-NEXT: remu a0, a0, a1 +; RV64IM-NEXT: remuw a0, a0, a1 +; RV64IM-NEXT: slli a0, a0, 32 +; RV64IM-NEXT: srli a0, a0, 32 ; RV64IM-NEXT: ret %1 = urem i32 %a, %b ret i32 %1