[SCEV] Fix PR22856.
authorSanjoy Das <sanjoy@playingwithpointers.com>
Fri, 13 Mar 2015 18:31:19 +0000 (18:31 +0000)
committerSanjoy Das <sanjoy@playingwithpointers.com>
Fri, 13 Mar 2015 18:31:19 +0000 (18:31 +0000)
commitf1e9e1df2574836ae9ae28af4f3c1d54bd0e7b3a
tree3a68a3a3186b841518d8ee03c0ecfc93ca3ba887
parentba3e5ecf075c1d186906c06fe4f85a560c244699
[SCEV] Fix PR22856.

Summary:
ScalarEvolutionExpander assumes that the header block of a loop is a
legal place to have a use for a phi node.  This is true only for phis
that are either in the header or dominate the header block, but it is
not true for phi nodes that are strictly internal to the loop body.

This change teaches ScalarEvolutionExpander to place uses of PHI nodes
in the basic block the PHI nodes belong to.  This is always legal, and
`hoistIVInc` ensures that the said position dominates `IsomorphicInc`.

Reviewers: atrick

Subscribers: llvm-commits

Differential Revision: http://reviews.llvm.org/D8311

llvm-svn: 232189
llvm/lib/Analysis/ScalarEvolutionExpander.cpp
llvm/test/Analysis/ScalarEvolution/pr22856.ll [new file with mode: 0644]