Skip to content

Commit a7ff607

Browse files
committed
[DataLayout] Explicitly call getFixedValue() (NFC)
Instead of relying on the implicit cast. The scalable case has been explicitly checked beforehand.
1 parent d6edc1a commit a7ff607

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

llvm/lib/IR/DataLayout.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -926,12 +926,13 @@ static APInt getElementIndex(TypeSize ElemSize, APInt &Offset) {
926926
return APInt::getZero(BitWidth);
927927
}
928928

929-
APInt Index = Offset.sdiv(ElemSize);
930-
Offset -= Index * ElemSize;
929+
uint64_t FixedElemSize = ElemSize.getFixedValue();
930+
APInt Index = Offset.sdiv(FixedElemSize);
931+
Offset -= Index * FixedElemSize;
931932
if (Offset.isNegative()) {
932933
// Prefer a positive remaining offset to allow struct indexing.
933934
--Index;
934-
Offset += ElemSize;
935+
Offset += FixedElemSize;
935936
assert(Offset.isNonNegative() && "Remaining offset shouldn't be negative");
936937
}
937938
return Index;

0 commit comments

Comments
 (0)