[llvm] [SCCP] Handle llvm.experimental.get.vector.length calls (PR #169527)

Luke Lau via llvm-commits llvm-commits at lists.llvm.org
Tue Nov 25 10:17:47 PST 2025


================
@@ -2098,6 +2098,32 @@ void SCCPInstVisitor::handleCallResult(CallBase &CB) {
       return (void)mergeInValue(ValueState[II], II,
                                 ValueLatticeElement::getRange(Result));
     }
+    if (II->getIntrinsicID() == Intrinsic::experimental_get_vector_length) {
+      unsigned BitWidth = CB.getType()->getScalarSizeInBits();
+      Value *CountArg = II->getArgOperand(0);
+      Value *VF = II->getArgOperand(1);
+      bool Scalable = cast<ConstantInt>(II->getArgOperand(2))->isOne();
+      ConstantRange Count = getValueState(CountArg)
+                                .asConstantRange(CountArg->getType(), false)
+                                .zextOrTrunc(BitWidth);
----------------
lukel97 wrote:

Thanks, changed it to use the larger of the two types in 67801c511c2286f2773b5eb5e0ed9e9971f888b3. I think that matches how SelectionDAGBuilder.cpp expands the intrinsic if the target doesn't natively support it.

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


More information about the llvm-commits mailing list