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)
commitb6ef9a14de7fcf9cf11e996e09241e24596a6edf
tree42bb5ab6559463fa59f16abd9b2024667fb36e14
parent984bc5298b5f1aa2fca3dd8b3d39b36cb44147d3
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.

llvm-svn: 232134
llvm/lib/Analysis/ScalarEvolution.cpp
llvm/test/Analysis/ScalarEvolution/trip-count.ll