If you try to compute the difference between two SCEV values which don't have a dominance relationship (so there's no point in the source code where the difference could actually be computed), SCEV will crash. This patch teaches SCEVAA not to do that.
I'm not sure this is the right fix; it seems like I'm working around the underlying issue rather than actually solving it. Does it makes sense to call AliasAnalysis::alias() in the case where HasDominanceRelation returns false? Alias analysis is normally defined in terms of memory operations, so I'm not sure what alias() means in the case where you can't construct a memory operation which refers to both pointers.
FWIW: This rediscovers the same info again and again .
But i'm not sure it's that slow.
IE you could cache scev->largest domtree dfs number interval, and only have to do this computation once per scev.
In fact, it also speeds up the other computation if you want
IE if the dom tree dfs in/out numbers for scev A are {50, 75}, when you call GetBottom on scev B, the second you see an operand with a set of dfs numbers that is either not between those or not encompassing those, there is no dominance relationship between the scevs and you can stop.
(Of course, then you can't cache the dfs number pair for that scev, but ...)
It's fine if you want to leave all this as a comment, i don't know if it's slow enough to be worth doing atm.