[all-commits] [llvm/llvm-project] 7954c5: [IR] Fix GEP offset computations for vector GEPs (...
Jannik Silvanus via All-commits
all-commits at lists.llvm.org
Thu Jan 4 01:08:35 PST 2024
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: 7954c57124b495fbdc73674d71f2e366e4afe522
https://github.com/llvm/llvm-project/commit/7954c57124b495fbdc73674d71f2e366e4afe522
Author: Jannik Silvanus <37809848+jasilvanus at users.noreply.github.com>
Date: 2024-01-04 (Thu, 04 Jan 2024)
Changed paths:
M clang/lib/CodeGen/CGExprScalar.cpp
M llvm/include/llvm/Analysis/TargetTransformInfoImpl.h
M llvm/include/llvm/IR/GetElementPtrTypeIterator.h
M llvm/lib/Analysis/BasicAliasAnalysis.cpp
M llvm/lib/Analysis/InlineCost.cpp
M llvm/lib/Analysis/Local.cpp
M llvm/lib/Analysis/LoopAccessAnalysis.cpp
M llvm/lib/Analysis/ValueTracking.cpp
M llvm/lib/CodeGen/CodeGenPrepare.cpp
M llvm/lib/CodeGen/GlobalISel/IRTranslator.cpp
M llvm/lib/CodeGen/SelectionDAG/FastISel.cpp
M llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
M llvm/lib/ExecutionEngine/Interpreter/Execution.cpp
M llvm/lib/IR/DataLayout.cpp
M llvm/lib/IR/Operator.cpp
M llvm/lib/IR/Value.cpp
M llvm/lib/Target/AArch64/AArch64FastISel.cpp
M llvm/lib/Target/ARM/ARMFastISel.cpp
M llvm/lib/Target/Mips/MipsFastISel.cpp
M llvm/lib/Target/PowerPC/PPCFastISel.cpp
M llvm/lib/Target/RISCV/RISCVGatherScatterLowering.cpp
M llvm/lib/Target/WebAssembly/WebAssemblyFastISel.cpp
M llvm/lib/Target/X86/X86FastISel.cpp
M llvm/lib/Transforms/Scalar/SROA.cpp
M llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp
M llvm/lib/Transforms/Scalar/StraightLineStrengthReduce.cpp
M llvm/lib/Transforms/Vectorize/LoadStoreVectorizer.cpp
M llvm/test/Transforms/InstCombine/getelementptr.ll
Log Message:
-----------
[IR] Fix GEP offset computations for vector GEPs (#75448)
Vectors are always bit-packed and don't respect the elements' alignment
requirements. This is different from arrays. This means offsets of
vector GEPs need to be computed differently than offsets of array GEPs.
This PR fixes many places that rely on an incorrect pattern
that always relies on `DL.getTypeAllocSize(GTI.getIndexedType())`.
We replace these by usages of `GTI.getSequentialElementStride(DL)`,
which is a new helper function added in this PR.
This changes behavior for GEPs into vectors with element types for which
the (bit) size and alloc size is different. This includes two cases:
* Types with a bit size that is not a multiple of a byte, e.g. i1.
GEPs into such vectors are questionable to begin with, as some elements
are not even addressable.
* Overaligned types, e.g. i16 with 32-bit alignment.
Existing tests are unaffected, but a miscompilation of a new test is fixed.
---------
Co-authored-by: Nikita Popov <github at npopov.com>
More information about the All-commits
mailing list