[all-commits] [llvm/llvm-project] 0a41e7: [LICM] Do not reassociate constant offset GEP (#15...
Nikita Popov via All-commits
all-commits at lists.llvm.org
Fri Aug 1 00:43:37 PDT 2025
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: 0a41e7c87ef910d0124c50354422f3b5290518e9
https://github.com/llvm/llvm-project/commit/0a41e7c87ef910d0124c50354422f3b5290518e9
Author: Nikita Popov <npopov at redhat.com>
Date: 2025-08-01 (Fri, 01 Aug 2025)
Changed paths:
M llvm/lib/Transforms/Scalar/LICM.cpp
M llvm/test/CodeGen/AMDGPU/loop-prefetch-data.ll
M llvm/test/CodeGen/AMDGPU/memintrinsic-unroll.ll
M llvm/test/CodeGen/AMDGPU/memmove-var-size.ll
M llvm/test/CodeGen/PowerPC/more-dq-form-prepare.ll
M llvm/test/CodeGen/PowerPC/no-ctr-loop-if-exit-in-nested-loop.ll
M llvm/test/Transforms/LICM/gep-reassociate.ll
M llvm/test/Transforms/LoopVectorize/X86/float-induction-x86.ll
M llvm/test/Transforms/PhaseOrdering/X86/pr88239.ll
Log Message:
-----------
[LICM] Do not reassociate constant offset GEP (#151492)
LICM tries to reassociate GEPs in order to hoist an invariant GEP.
Currently, it also does this in the case where the GEP has a constant
offset.
This is usually undesirable. From a back-end perspective, constant GEPs
are usually free because they can be folded into addressing modes, so
this just increases register pressume. From a middle-end perspective,
keeping constant offsets last in the chain makes it easier to analyze
the relationship between multiple GEPs on the same base, especially
after CSE.
The worst that can happen here is if we start with something like
```
loop {
p + 4*x
p + 4*x + 1
p + 4*x + 2
p + 4*x + 3
}
```
And LICM converts it into:
```
p.1 = p + 1
p.2 = p + 2
p.3 = p + 3
loop {
p + 4*x
p.1 + 4*x
p.2 + 4*x
p.3 + 4*x
}
```
Which is much worse than leaving it for CSE to convert to:
```
loop {
p2 = p + 4*x
p2 + 1
p2 + 2
p2 + 3
}
```
To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications
More information about the All-commits
mailing list