[llvm] [SCCP] Handle llvm.experimental.get.vector.length calls (PR #169527)
Yingwei Zheng via llvm-commits
llvm-commits at lists.llvm.org
Tue Nov 25 09:44:13 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);
----------------
dtcxzyw wrote:
`i32 @llvm.experimental.get.vector.length.i64(i64 2**33, i32 4, i1 false)` will be folded to zero.
https://github.com/llvm/llvm-project/pull/169527
More information about the llvm-commits
mailing list