[llvm] [MemoryLocation] Size Scalable Masked MemOps (PR #154785)
Nikita Popov via llvm-commits
llvm-commits at lists.llvm.org
Thu Aug 21 08:23:33 PDT 2025
================
@@ -150,6 +150,29 @@ MemoryLocation::getForDest(const CallBase *CB, const TargetLibraryInfo &TLI) {
return MemoryLocation::getBeforeOrAfter(UsedV, CB->getAAMetadata());
}
+static std::optional<FixedVectorType *>
+getFixedTypeFromScalableMemOp(Value *Mask, Type *Ty) {
+ auto ActiveLaneMask = dyn_cast<IntrinsicInst>(Mask);
+ if (!ActiveLaneMask ||
+ ActiveLaneMask->getIntrinsicID() != Intrinsic::get_active_lane_mask)
+ return std::nullopt;
+
+ auto ScalableTy = dyn_cast<ScalableVectorType>(Ty);
+ if (!ScalableTy)
+ return std::nullopt;
+
+ auto LaneMaskLo = dyn_cast<ConstantInt>(ActiveLaneMask->getOperand(0));
+ auto LaneMaskHi = dyn_cast<ConstantInt>(ActiveLaneMask->getOperand(1));
+ if (!LaneMaskLo || !LaneMaskHi)
+ return std::nullopt;
+
+ uint64_t NumElts = LaneMaskHi->getZExtValue() - LaneMaskLo->getZExtValue();
----------------
nikic wrote:
Shouldn't this just use LaneMaskHi, without subtracting LaneMaskLo?
NumElts is the number of active elements, but the memory location is relative to the original base pointer, so inactive elements at the start need to be counted as well.
It looks like you are missing tests for a non-zero base index.
https://github.com/llvm/llvm-project/pull/154785
More information about the llvm-commits
mailing list