[llvm] [TTI] Provide conservative costs for @llvm.speculative.load. (PR #180036)
Florian Hahn via llvm-commits
llvm-commits at lists.llvm.org
Mon Sep 21 06:06: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)
----------------
fhahn wrote:
This is only about profitability here. We cannot guarantee that it is safe here statically for SVE, but the size will need to be checked at runtime via `emitCanLoadSpeculatively`.
I'm happy to drop the SVE parts, if preferred.
https://github.com/llvm/llvm-project/pull/180036
More information about the llvm-commits
mailing list