Rules:
- SCEVUnknown is a pointer if and only if the LLVM IR value is a pointer.
- SCEVPtrToInt is never a pointer.
- If any other SCEV expression has no pointer operands, the result is an integer.
- If a SCEVAddExpr has exactly one pointer operand, the result is a pointer.
- If a SCEVAddRecExpr's first operand is a pointer, and it has no other pointer operands, the result is a pointer.
- If a SCEVMinMaxExpr has all pointer operands, the result is a pointer.
- Otherwise, the SCEV expression is invalid.
I'm not sure how useful rule 6 is in practice. If we exclude it, we can guarantee that ScalarEvolution::getPointerBase always returns a SCEVUnknown, which might be a helpful property. Anyway, I'll leave that for a followup.
This is basically mop-up at this point; all the changes with significant functional effects have landed. Some of the remaining changes could be split off, but I don't see much point.
It looks like it filters out such simple case as (LHS == RHS ) => (RHS== LHS) (if LHS = FoundRHS and RHS = FoundLHS). Could you please add a unit test to ensure it's not broken with this patch?