[llvm] [RISCV] Lower masked_{u, s}{div, rem} and update TTI (PR #192543)

Luke Lau via llvm-commits llvm-commits at lists.llvm.org
Fri Apr 17 02:21:57 PDT 2026


================
@@ -8796,6 +8810,18 @@ SDValue RISCVTargetLowering::LowerOperation(SDValue Op,
     return DAG.getNode(RISCVISD::PSSLAI, DL, VT, Op.getOperand(0),
                        DAG.getTargetConstant(ShAmt, DL, Subtarget.getXLenVT()));
   }
+  case ISD::MASKED_UDIV:
+  case ISD::MASKED_SDIV:
+  case ISD::MASKED_UREM:
+  case ISD::MASKED_SREM: {
+    SDLoc DL(Op);
+    MVT VT = Op.getSimpleValueType();
----------------
lukel97 wrote:

Unfortunately not if we want to preserve the mask operand, since lowerToScalableOp just uses the default all ones mask.

But I guess in theory it should also be safe if we just drop the mask entirely, that's also an option. I'm kind of hoping that uarchs will use the mask to avoid dispatching uops on disabled lanes though, but I have no data on this

https://github.com/llvm/llvm-project/pull/192543


More information about the llvm-commits mailing list