[llvm] [RISCV] Add additional conditions for signed icmp cases when canonicalizing masks for VL-predicate (PR #218068)

Luke Lau via llvm-commits llvm-commits at lists.llvm.org
Sat Aug 22 00:13:26 PDT 2026


================
@@ -19216,6 +19216,22 @@ static SDValue canonicalizeMaskForVLPredicate(EVT MaskVT, SDValue LHS,
   APInt Offset =
       IsSigned ? Start.sextOrTrunc(LenWidth) : Start.zextOrTrunc(LenWidth);
 
+  if (IsSigned) {
+    // Two additional conditions:
+    // 1. Offset + BaseIndex never overflow
+    if (!Offset.isZero() && (DAG.ComputeNumSignBits(BaseIndex) <= 1 ||
----------------
lukel97 wrote:

I think LenVT is always XLenVT because getSplatValue passes true to LegalizeType, but do we need to check for overflow in `RHS.getScalarValueType()` instead? Since that's what the value is ultimately stored in

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


More information about the llvm-commits mailing list