[llvm] [InstSimplify] Consider vscale_range for get active lane mask (PR #160073)
Matthew Devereau via llvm-commits
llvm-commits at lists.llvm.org
Tue Sep 23 08:18:05 PDT 2025
================
@@ -6474,10 +6474,27 @@ Value *llvm::simplifyBinaryIntrinsic(Intrinsic::ID IID, Type *ReturnType,
const CallBase *Call) {
unsigned BitWidth = ReturnType->getScalarSizeInBits();
switch (IID) {
- case Intrinsic::get_active_lane_mask:
+ case Intrinsic::get_active_lane_mask: {
if (match(Op1, m_Zero()))
return ConstantInt::getFalse(ReturnType);
+
+ const Function *F = Call->getFunction();
+ auto ScalableTy = dyn_cast<ScalableVectorType>(ReturnType);
+ if (ScalableTy && F->hasFnAttribute(Attribute::VScaleRange)) {
+ Attribute Attr = F->getFnAttribute(Attribute::VScaleRange);
+ std::optional<unsigned> VScaleMax = Attr.getVScaleRangeMax();
+ if (!VScaleMax)
+ break;
+ unsigned MaxPossibleMaskElements =
+ ScalableTy->getMinNumElements() * (*VScaleMax);
----------------
MDevereau wrote:
Makes sense, thanks for explaining. If you cast the first operand, both operands get extended before the binop:
https://godbolt.org/z/z3eqnzTT6
https://github.com/llvm/llvm-project/pull/160073
More information about the llvm-commits
mailing list