This enhancement will enable loop vectorizations that are currently blocked due to noop inttoptr/ptrtoint operations.
The change itself is straightforward, but it exposes a few bugs in existing code. For instance, const_expr created by the expander can grow exponentially so some size limit needs to be applied. The expander also invalidates some of the SCEVs for some of the values (when noop cast is inserted) which can leads to inconsistent SCEVs with other cached values when recomputed (e.g, when scalar loop's header phi's init value is replaced by loop vectorizer). This patch also fixes those problems.
I'm not sure that this is correct: How do we know that AAPtr is a pointer value? The idea here is that there's some expression that looks like ptrtoint(ptr) + e1 + e2 + ..., and we want to separate it into (ptr, e1 + e2 + ...). If we update SCEV to look through ptrtoint, we can't do this in the same way. I imagine we need to write a visitor to pull out the underlying pointer, or we need to not use SCEV for this task.