[llvm] [InstCombine] Fold @llvm.experimental.get.vector.length when cnt <= max_lanes (PR #169293)
Ryan Buchner via llvm-commits
llvm-commits at lists.llvm.org
Mon Nov 24 09:26:29 PST 2025
================
@@ -4005,6 +4005,22 @@ Instruction *InstCombinerImpl::visitCallInst(CallInst &CI) {
}
break;
}
+ case Intrinsic::experimental_get_vector_length: {
+ // get.vector.length(Cnt, MaxLanes) --> Cnt when Cnt <= MaxLanes
+ ConstantRange Cnt = computeConstantRangeIncludingKnownBits(
+ II->getArgOperand(0), false, SQ.getWithInstruction(II));
+ ConstantRange MaxLanes = cast<ConstantInt>(II->getArgOperand(1))
+ ->getValue()
+ .zext(Cnt.getBitWidth());
+ if (cast<ConstantInt>(II->getArgOperand(2))->getZExtValue())
----------------
bababuck wrote:
When checking to see if a boolean `ConstantInt` is `true`, is there a preference for using `getZExtValue()` versus `isOne()`?
https://github.com/llvm/llvm-project/pull/169293
More information about the llvm-commits
mailing list