[llvm] [LSR] Add unequal cost eval for dropping solutions (PR #178039)
John Brawn via llvm-commits
llvm-commits at lists.llvm.org
Thu Feb 12 09:21:05 PST 2026
john-brawn-arm wrote:
Looking at the tests added in lsr-baseline-solution.ll it looks like this change sometimes makes things worse. e.g. in _Z6add1_iPim we currently generate
```
_Z6add1_iPim: # @_Z6add1_iPim
.cfi_startproc
# %bb.0: # %entry
beqz a1, .LBB0_3
# %bb.1: # %for.body.preheader
slli a1, a1, 2
add a1, a0, a1
.LBB0_2: # %for.body
# =>This Inner Loop Header: Depth=1
lw a2, 0(a0)
addi a2, a2, 1
sw a2, 0(a0)
addi a0, a0, 4
bne a0, a1, .LBB0_2
.LBB0_3: # %for.cond.cleanup
ret
```
but with this change we generate
```
_Z6add1_iPim: # @_Z6add1_iPim
.cfi_startproc
# %bb.0: # %entry
beqz a1, .LBB0_3
# %bb.1: # %for.body.preheader
li a2, 0
.LBB0_2: # %for.body
# =>This Inner Loop Header: Depth=1
slli a3, a2, 2
add a3, a0, a3
lw a4, 0(a3)
addi a4, a4, 1
addi a2, a2, 1
sw a4, 0(a3)
bne a2, a1, .LBB0_2
.LBB0_3: # %for.cond.cleanup
ret
```
https://github.com/llvm/llvm-project/pull/178039
More information about the llvm-commits
mailing list