[LSR] Hoist IVInc to loop header if its all uses are in the loop header
authorchenglin.bi <chenglin.bi@linaro.org>
Tue, 10 Jan 2023 10:33:33 +0000 (18:33 +0800)
committerchenglin.bi <chenglin.bi@linaro.org>
Tue, 10 Jan 2023 10:34:00 +0000 (18:34 +0800)
commitb1b4758e7f4b2ffe1faa28b00eb037832e5d26a7
tree4d7c6673d4576e5c40545b28768390a265ef6bed
parent96b52c1eec7b7952059a4cc4acd2f5e62e1ba1ca
[LSR] Hoist IVInc to loop header if its all uses are in the loop header

When the latch block is different from header block, IVInc will be expanded in the latch loop. We can't generate the post index load/store this case.
But if the IVInc only used in the loop, actually we still can use the post index load/store because when exit loop we don't care the last IVInc value.
So, trying to hoist IVInc to help backend to generate more post index load/store.

Fix #53625

Reviewed By: eopXD

Differential Revision: https://reviews.llvm.org/D138636
llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
llvm/test/Transforms/LoopStrengthReduce/AArch64/pr53625.ll