[llvm] [TTI] Provide conservative costs for @llvm.speculative.load. (PR #180036)
David Sherwood via llvm-commits
llvm-commits at lists.llvm.org
Mon Sep 21 06:12:57 PDT 2026
================
@@ -619,6 +619,25 @@ AArch64TTIImpl::getIntrinsicInstrCost(const IntrinsicCostAttributes &ICA,
return InstructionCost::getInvalid();
switch (ICA.getID()) {
+ case Intrinsic::speculative_load: {
+ // Speculative loads are only valid for types <= 16 bytes due to MTE
+ // (Memory Tagging Extension) using 16-byte tag granules. Loads larger
+ // than 16 bytes could cross a tag granule boundary.
+ auto LT = getTypeLegalizationCost(RetTy);
+ if (!LT.first.isValid())
+ return InstructionCost::getInvalid();
+ // For scalable vectors, check that we use a single register (which means
+ // <= 16 bytes at minimum vscale). For fixed types, compute the actual size.
+ if (isa<ScalableVectorType>(RetTy)) {
+ if (LT.first.getValue() != 1)
----------------
david-arm wrote:
Oh I see, I think I understand now. You're saying that with scalable vectors we *may* be able to enter the vector loop, but provided a separate runtime check says the vector length <= 16 bytes. In that case I think the code is fine as it is. Thanks for explaining!
https://github.com/llvm/llvm-project/pull/180036
More information about the llvm-commits
mailing list