]> granicus.if.org Git - llvm/commit
[SCEV] Teach computeSCEVAtScope benefit from one-input Phi. PR39673
authorPhilip Reames <listmail@philipreames.com>
Wed, 12 Jun 2019 17:21:47 +0000 (17:21 +0000)
committerPhilip Reames <listmail@philipreames.com>
Wed, 12 Jun 2019 17:21:47 +0000 (17:21 +0000)
commit4298a2dd20947b4102f678dc7c34b75ab221877d
tree0767acff1ece4cddefcd6384cb6a650603b8a3cc
parent9b95d3f22f252f18d3faf0118db032f986a2f40e
[SCEV] Teach computeSCEVAtScope benefit from one-input Phi. PR39673

SCEV does not propagate arguments through one-input Phis so as to make it easy for the SCEV expander (and related code) to preserve LCSSA.  It's not entirely clear this restriction is neccessary, but for the moment it exists.   For this reason, we don't analyze single-entry phi inputs.  However it is possible that when an this input leaves the loop through LCSSA Phi, it is a provable constant.  Missing that results in an order of optimization issue in loop exit value rewriting where we miss some oppurtunities based on order in which we visit sibling loops.

This patch teaches computeSCEVAtScope about this case. We can generalize it later, but so far we can only replace LCSSA Phis with their constant loop-exiting values.  We should probably also add similiar logic directly in the SCEV construction path itself.

Patch by: mkazantsev (with revised commit message by me)
Differential Revision: https://reviews.llvm.org/D58113

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@363180 91177308-0d34-0410-b5e6-96231b3b80d8
lib/Analysis/ScalarEvolution.cpp
test/Transforms/IndVarSimplify/pr39673.ll