aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib
diff options
context:
space:
mode:
authorAntonio Frighetto <me@antoniofrighetto.com>2024-12-04 10:15:11 +0100
committerAntonio Frighetto <me@antoniofrighetto.com>2024-12-04 10:20:14 +0100
commitf68b0e36997322eeda8fd199ea80deb1b49c5410 (patch)
tree80723b066b6069fc337b90e5c062df85e8b35c93 /llvm/lib
parent73731d6873b6fb0757c3065aaf2452eaccd0eebc (diff)
downloadllvm-f68b0e36997322eeda8fd199ea80deb1b49c5410.zip
llvm-f68b0e36997322eeda8fd199ea80deb1b49c5410.tar.gz
llvm-f68b0e36997322eeda8fd199ea80deb1b49c5410.tar.bz2
[AggressiveInstCombine] Use APInt and avoid truncation when folding loads
A miscompilation issue has been addressed with improved handling. Fixes: https://github.com/llvm/llvm-project/issues/118467.
Diffstat (limited to 'llvm/lib')
-rw-r--r--llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp3
1 files changed, 1 insertions, 2 deletions
diff --git a/llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp b/llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp
index b5b5617..45ee2d4 100644
--- a/llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp
+++ b/llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombine.cpp
@@ -803,8 +803,7 @@ static bool foldConsecutiveLoads(Instruction &I, const DataLayout &DL,
APInt Offset1(DL.getIndexTypeSizeInBits(Load1Ptr->getType()), 0);
Load1Ptr = Load1Ptr->stripAndAccumulateConstantOffsets(
DL, Offset1, /* AllowNonInbounds */ true);
- Load1Ptr = Builder.CreatePtrAdd(Load1Ptr,
- Builder.getInt32(Offset1.getZExtValue()));
+ Load1Ptr = Builder.CreatePtrAdd(Load1Ptr, Builder.getInt(Offset1));
}
// Generate wider load.
NewLoad = Builder.CreateAlignedLoad(WiderType, Load1Ptr, LI1->getAlign(),