[llvm] LAA: scale strides using type-size (NFC) (PR #124529)

David Sherwood via llvm-commits llvm-commits at lists.llvm.org
Fri Jan 31 02:34:25 PST 2025


================
@@ -1990,25 +1986,32 @@ MemoryDepChecker::getDependenceDistanceStrideAndSize(
     return MemoryDepChecker::Dependence::Unknown;
   }
 
-  uint64_t TypeByteSize = DL.getTypeAllocSize(ATy);
-  bool HasSameSize =
-      DL.getTypeStoreSizeInBits(ATy) == DL.getTypeStoreSizeInBits(BTy);
-  if (!HasSameSize)
-    TypeByteSize = 0;
+  TypeSize AStoreSz = DL.getTypeStoreSize(ATy),
+           BStoreSz = DL.getTypeStoreSize(BTy);
+
+  // Fail early if either store size is scalable.
+  if (AStoreSz.isScalable() || BStoreSz.isScalable())
+    return MemoryDepChecker::Dependence::Unknown;
+
+  // If store sizes are not the same, set TypeByteSize to zero, so we can check
+  // it in the caller.
+  uint64_t ASz = alignTo(AStoreSz, DL.getABITypeAlign(ATy)),
----------------
david-arm wrote:

Hmm, this does look the same as what `getTypeAllocSize` does, but I feel a bit nervous in case the definition of `getTypeAllocSize` changes at some point in the future. Is it worth adding an assert here that `ASz == DL.getTypeAllocSize(ATy)`?

Alternatively, even though it's less efficient you could just recalculate again with:

```
uint64_t ASz = DL.getTypeAllocSize(ATy),
...
```

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


More information about the llvm-commits mailing list