[IndVars] Replace PHIs if loop exits on 1st iteration
authorMax Kazantsev <mkazantsev@azul.com>
Mon, 13 Sep 2021 03:48:42 +0000 (10:48 +0700)
committerMax Kazantsev <mkazantsev@azul.com>
Mon, 13 Sep 2021 03:50:33 +0000 (10:50 +0700)
commit5a6dfb27ca7424f15a20f9bb7ec90d858865faa3
tree1832868ee0e063e072aef791f8b5e31f811b9ee9
parentd48a3f9f757c2c4b6adc7b8f7ca94641d9cf3a46
[IndVars] Replace PHIs if loop exits on 1st iteration

This is a part of D108910.
We replace all loop PHIs with values coming from the loop preheader if
we proved that backedge is never taken.

Patch by Dmitry Makogon!

Differential Revision: https://reviews.llvm.org/D109596
Reviewed By: lebedev.ri
llvm/lib/Transforms/Scalar/IndVarSimplify.cpp
llvm/test/Transforms/IndVarSimplify/eliminate-backedge.ll
llvm/test/Transforms/IndVarSimplify/eliminate-exit-no-dl.ll
llvm/test/Transforms/IndVarSimplify/floating-point-iv.ll