aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp
diff options
context:
space:
mode:
authorQuentin Dian <dianqk@dianqk.net>2024-03-06 06:16:28 +0800
committerGitHub <noreply@github.com>2024-03-06 06:16:28 +0800
commite96c0c1d5e0a9916098b1a31acb006ea6c1108fb (patch)
tree719c5383969df468d5a423559597d64b987420fc /llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp
parentf51ade25b9205efee09a4915031848cebe772805 (diff)
downloadllvm-e96c0c1d5e0a9916098b1a31acb006ea6c1108fb.zip
llvm-e96c0c1d5e0a9916098b1a31acb006ea6c1108fb.tar.gz
llvm-e96c0c1d5e0a9916098b1a31acb006ea6c1108fb.tar.bz2
[InstCombine] Fix shift calculation in InstCombineCasts (#84027)
Fixes #84025.
Diffstat (limited to 'llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp')
-rw-r--r--llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp4
1 files changed, 2 insertions, 2 deletions
diff --git a/llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp b/llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp
index 33ed1d5..45afa63 100644
--- a/llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp
+++ b/llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp
@@ -2167,14 +2167,14 @@ static bool collectInsertionElements(Value *V, unsigned Shift,
Type *ElementIntTy = IntegerType::get(C->getContext(), ElementSize);
for (unsigned i = 0; i != NumElts; ++i) {
- unsigned ShiftI = Shift + i * ElementSize;
+ unsigned ShiftI = i * ElementSize;
Constant *Piece = ConstantFoldBinaryInstruction(
Instruction::LShr, C, ConstantInt::get(C->getType(), ShiftI));
if (!Piece)
return false;
Piece = ConstantExpr::getTrunc(Piece, ElementIntTy);
- if (!collectInsertionElements(Piece, ShiftI, Elements, VecEltTy,
+ if (!collectInsertionElements(Piece, ShiftI + Shift, Elements, VecEltTy,
isBigEndian))
return false;
}