[llvm] [TTI] Provide conservative costs for @llvm.speculative.load. (PR #180036)

Florian Hahn via llvm-commits llvm-commits at lists.llvm.org
Wed Sep 23 02:11:23 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);
----------------
fhahn wrote:

Fair enough, I added `isLegalSpeculativeLoad` and updated `speculative_load` cost to directly delegate to `getMemoryOpCost`. Is that what you had in mind?

I don't think the way we handle this distinction currently is particularly nice (having an ever growing selection of specialized `isLegalXXX` functions, but I guess this is something to better address separately, if at all

https://github.com/llvm/llvm-project/pull/180036


More information about the llvm-commits mailing list