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

Paul Walker via llvm-commits llvm-commits at lists.llvm.org
Wed Sep 23 03:01:04 PDT 2026


================
@@ -5920,6 +5920,26 @@ bool AArch64TTIImpl::isLegalMaskedExpandLoad(Type *DataTy,
          (ST->isSVEorStreamingSVEAvailable() && ST->hasSME2p2());
 }
 
+bool AArch64TTIImpl::isLegalSpeculativeLoad(Type *DataType,
+                                            unsigned AddressSpace) const {
+  // Matches AArch64TargetLowering::emitCanLoadSpeculatively: only address
+  // space 0 and sizes up to the 16-byte MTE tag granule are supported.
+  if (AddressSpace != 0)
+    return false;
+  TypeSize Size = DL.getTypeStoreSize(DataType);
+  uint64_t MinSize = Size.getKnownMinValue();
+  // Scalable types are at least the minimum vscale times their known minimum
+  // size.
+  if (Size.isScalable()) {
+    if (!ST->isSVEorStreamingSVEAvailable())
+      return false;
+    MinSize *=
+        std::max(ST->getMinSVEVectorSizeInBits(), AArch64::SVEBitsPerBlock) /
+        AArch64::SVEBitsPerBlock;
+  }
----------------
paulwalker-arm wrote:

```suggestion
  if (Size.isScalable())
    return ST->isSVEorStreamingSVEAvailable();
```
When SVE is available we can emit a sequence of first/non-faulting loads?

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


More information about the llvm-commits mailing list