[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 07:05:00 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:
It might be worth adding a comment here that for scalable vector types there needs to be a runtime check to ensure the type is <= 16 bytes.
https://github.com/llvm/llvm-project/pull/180036
More information about the llvm-commits
mailing list