[IndVars] Simplify instructions after replacing header phi with preheader value
authorNikita Popov <npopov@redhat.com>
Thu, 7 Jul 2022 15:04:37 +0000 (17:04 +0200)
committerNikita Popov <npopov@redhat.com>
Wed, 13 Jul 2022 08:27:04 +0000 (10:27 +0200)
commitaf49bed93376da6950af116371ecdaab0bf4bb7b
treeffc8bf15f73a9f715dd6ed1b6be0e697d3d79f36
parentee4d09b8bb735470cc7bbacfdfcd218220b1978a
[IndVars] Simplify instructions after replacing header phi with preheader value

After replacing a loop phi with the preheader value, it's usually
possible to simplify some of the using instructions, so do that as
part of replaceLoopPHINodesWithPreheaderValues().

Doing this as part of IndVars is valuable, because it may make GEPs
in the loop have constant offsets and allow the following SROA run
to succeed (as demonstrated in the PhaseOrdering test).

Differential Revision: https://reviews.llvm.org/D129293
13 files changed:
llvm/lib/Transforms/Scalar/IndVarSimplify.cpp
llvm/test/Transforms/IndVarSimplify/X86/pr35406.ll
llvm/test/Transforms/IndVarSimplify/eliminate-backedge.ll
llvm/test/Transforms/IndVarSimplify/eliminate-exit-no-dl.ll
llvm/test/Transforms/IndVarSimplify/floating-point-iv.ll
llvm/test/Transforms/IndVarSimplify/lcssa-preservation.ll
llvm/test/Transforms/IndVarSimplify/no-iv-rewrite.ll
llvm/test/Transforms/IndVarSimplify/pr22222.ll
llvm/test/Transforms/IndVarSimplify/pr40454.ll
llvm/test/Transforms/IndVarSimplify/scev-expander-preserve-lcssa.ll
llvm/test/Transforms/IndVarSimplify/sentinel.ll
llvm/test/Transforms/LoopDeletion/pr53969.ll
llvm/test/Transforms/PhaseOrdering/single-iteration-loop-sroa.ll