[llvm] [RISCV] Track the value range of vsetvlimax (PR #218313)

Luke Lau via llvm-commits llvm-commits at lists.llvm.org
Sun Aug 23 22:34:07 PDT 2026


================
@@ -2871,6 +2903,12 @@ bool llvm::isKnownToBeAPowerOfTwo(const Value *V, bool OrZero,
         if (II->getArgOperand(0) == II->getArgOperand(1))
           return isKnownToBeAPowerOfTwo(II->getArgOperand(0), OrZero, Q, Depth);
         break;
+      case Intrinsic::riscv_vsetvlimax:
+        // VLEN and LMUL are powers of two, and SEW is a power of two.
+        if (ConstantRange Range = getRISCVVSetVLMaxRange(*II);
+            !Range.isFullSet())
+          return OrZero || !Range.contains(APInt(Range.getBitWidth(), 0));
+        return false;
----------------
lukel97 wrote:

Can we just `return true` given that VLMAX is always a power of two? 

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


More information about the llvm-commits mailing list