[IndVars] Fix PR26974: make sure replaceCongruentIVs doesn't break LCSSA
authorSilviu Baranga <silviu.baranga@arm.com>
Mon, 21 Mar 2016 12:44:29 +0000 (12:44 +0000)
committerSilviu Baranga <silviu.baranga@arm.com>
Mon, 21 Mar 2016 12:44:29 +0000 (12:44 +0000)
commitf875e4fd924b5ce61fd3bed76c569b5ec2c2f048
tree30a50403e9c2cac25b1e020962a747998bbb70b4
parent6c250b714cf6ccee666ec30ecfb5cd2130d7de8f
[IndVars] Fix PR26974: make sure replaceCongruentIVs doesn't break LCSSA

Summary:
replaceCongruentIVs can break LCSSA when trying to replace IV increments
since it tries to replace all uses of a phi node with another phi node
while both of the phi nodes are not necessarily in the processed loop.
This will cause an assert in IndVars.

To fix this, we add a check to make sure that the replacement maintains
LCSSA.

Reviewers: sanjoy

Subscribers: mzolotukhin, llvm-commits

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

llvm-svn: 263941
llvm/lib/Analysis/ScalarEvolutionExpander.cpp
llvm/test/Transforms/IndVarSimplify/pr26974.ll [new file with mode: 0644]