[llvm] [DL] Invert `getTypeStoreSize` bytes-bits relationship to avoid `divideCeil` (PR #106757)

Nikita Popov via llvm-commits llvm-commits at lists.llvm.org
Fri Aug 30 11:47:01 PDT 2024


================
@@ -433,7 +434,10 @@ class DataLayout {
   ///
   /// For example, returns 40 for i36 and 80 for x86_fp80.
   TypeSize getTypeStoreSizeInBits(Type *Ty) const {
-    return 8 * getTypeStoreSize(Ty);
+    TypeSize BaseSize = getTypeSizeInBits(Ty);
+    uint64_t AlignedSizeInBits =
+        alignToPowerOf2(BaseSize.getKnownMinValue(), sizeof(uint64_t));
----------------
nikic wrote:

```suggestion
        alignToPowerOf2(BaseSize.getKnownMinValue(), 8);
```
`sizeof(uint64_t)` doesn't have any relation to this. The 8 here is the number of bits in a byte.

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


More information about the llvm-commits mailing list