[llvm] a7ff607 - [DataLayout] Explicitly call getFixedValue() (NFC)

Nikita Popov via llvm-commits llvm-commits at lists.llvm.org
Tue Sep 2 00:52:25 PDT 2025


Author: Nikita Popov
Date: 2025-09-02T09:52:16+02:00
New Revision: a7ff60788df8d86f930c4588c9f2c4130da55630

URL: https://github.com/llvm/llvm-project/commit/a7ff60788df8d86f930c4588c9f2c4130da55630
DIFF: https://github.com/llvm/llvm-project/commit/a7ff60788df8d86f930c4588c9f2c4130da55630.diff

LOG: [DataLayout] Explicitly call getFixedValue() (NFC)

Instead of relying on the implicit cast. The scalable case has
been explicitly checked beforehand.

Added: 
    

Modified: 
    llvm/lib/IR/DataLayout.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/IR/DataLayout.cpp b/llvm/lib/IR/DataLayout.cpp
index dbd6d81ad2e24..50c45f5f5feb0 100644
--- a/llvm/lib/IR/DataLayout.cpp
+++ b/llvm/lib/IR/DataLayout.cpp
@@ -926,12 +926,13 @@ static APInt getElementIndex(TypeSize ElemSize, APInt &Offset) {
     return APInt::getZero(BitWidth);
   }
 
-  APInt Index = Offset.sdiv(ElemSize);
-  Offset -= Index * ElemSize;
+  uint64_t FixedElemSize = ElemSize.getFixedValue();
+  APInt Index = Offset.sdiv(FixedElemSize);
+  Offset -= Index * FixedElemSize;
   if (Offset.isNegative()) {
     // Prefer a positive remaining offset to allow struct indexing.
     --Index;
-    Offset += ElemSize;
+    Offset += FixedElemSize;
     assert(Offset.isNonNegative() && "Remaining offset shouldn't be negative");
   }
   return Index;


        


More information about the llvm-commits mailing list