Skip to content

Commit 8d0d3fc

Browse files
committed
Fix negative offsets calculation
1 parent 5d15526 commit 8d0d3fc

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

llvm/lib/Transforms/Scalar/InferAlignment.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ bool inferAlignment(Function &F, AssumptionCache &AC, DominatorTree &DT) {
7474
// Derive the base pointer alignment from the load/store alignment
7575
// and the offset from the base pointer.
7676
Align BasePointerAlign =
77-
commonAlignment(LoadStoreAlign, OffsetFromBase.getLimitedValue());
77+
commonAlignment(LoadStoreAlign, OffsetFromBase.abs().getLimitedValue());
7878

7979
auto [It, Inserted] =
8080
BestBasePointerAligns.try_emplace(PtrOp, BasePointerAlign);
@@ -85,7 +85,7 @@ bool inferAlignment(Function &F, AssumptionCache &AC, DominatorTree &DT) {
8585
// improved base pointer alignment for future iterations.
8686
if (It->second > BasePointerAlign) {
8787
Align BetterLoadStoreAlign =
88-
commonAlignment(It->second, OffsetFromBase.getLimitedValue());
88+
commonAlignment(It->second, OffsetFromBase.abs().getLimitedValue());
8989
return BetterLoadStoreAlign;
9090
}
9191
It->second = BasePointerAlign;

0 commit comments

Comments
 (0)