[clang] [llvm] [AVR] Fix Avr indvar detection and strength reduction (missed optimization) (PR #152028)

Tom Vijlbrief via llvm-commits llvm-commits at lists.llvm.org
Mon Aug 4 14:20:50 PDT 2025


tomtor wrote:

loop-reduce does not preserve predecrement operations in loops which it cannot optimize.
This is a non AVR specific bug/issue, but on architectures with rich addressing modes it is hidden (a scaled index is used on Intel/ARM) and RISCV has no post/pre addressing.

In functions which have an `incdec` ptr I disable the loop-reduce. That is a bit of overkill, this could/should be done on an individual loop instead of the whole function, but in practice the difference will be small, because `incdec` ptrs are rare in generated AVR code.

I see no easy way to do this on individual loops. @Patryk27 suggestions?

https://github.com/llvm/llvm-project/pull/152028


More information about the llvm-commits mailing list