[llvm] [LICM][MustExec] Make must-exec logic for IV condition commutative (PR #93150)

Nikita Popov via llvm-commits llvm-commits at lists.llvm.org
Sat May 25 23:31:27 PDT 2024


nikic wrote:

> > I don't think we would be able to directly report umax(N, N+1) as the exit count
> 
> We can use umax(N, N+1) as the count as long as the AddRec is nowrap, I think? And if the AddRec isn't nowrap, we can add that as a predicate. That's basically the same reasoning we're using to return zext(N)+1 anyway.

I don't think this is the case. Consider two exits, first `<= -1` and `< -1`. With this approach, both exits would report an exit count of `-1`, as such indvars would conclude that the second exit must be dead. However, in reality the first exit is the one that is dead. Now, I think that *in practice* this wouldn't happen because we can only reach this conclusion for non-symbolic exit counts, while `<= -1` apparently goes through a different code path and produces CouldNotCompute. But I think this illustrates that this is not generally correct...

https://github.com/llvm/llvm-project/pull/93150


More information about the llvm-commits mailing list