When forming an addrec out of a phi don't just look at the last computation and steal...
authorNick Lewycky <nicholas@mxc.ca>
Fri, 13 Mar 2015 01:37:52 +0000 (01:37 +0000)
committerNick Lewycky <nicholas@mxc.ca>
Fri, 13 Mar 2015 01:37:52 +0000 (01:37 +0000)
commit011cb4d5bdc3a56e9d8e7a19c1a576a3eaabe5ad
treed9a5b23a7f0e90ab8e71c98e04478e9c9c9b84df
parentc666f5df88bdf0826c2f974da9cc368b0f84ce9e
When forming an addrec out of a phi don't just look at the last computation and steal its flags for our own, there may be other computations in the middle. Check whether the LHS of the computation is the phi itself and then we know it's safe to steal the flags. Fixes PR22795.

There's a missed optimization opportunity where we could look at the full chain of computation and take the intersection of the flags instead of only looking one instruction deep.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@232134 91177308-0d34-0410-b5e6-96231b3b80d8
lib/Analysis/ScalarEvolution.cpp
test/Analysis/ScalarEvolution/trip-count.ll