This change teaches SCEV to simplify add expressions that contain
multiplications to a sum of products representation, and use the
resulting simplified expression if that simplifies to a constant.
This was motivated by PR25170, but I think simplifying to a canonical
form is a good idea in general for consistency. However, I'm not a 100%
sure that this is a good idea with respect to compile time -- the core
recursive simplification logic has exponential complexity in the number
of SCEVMulExpr's it creates. Perhaps we should cap the depth (or some
other metric) to avoid the truly bad cases here?
In the future this can probably be extended to contruction of
multiplication expressions as well.
Did you consider SmallPtrSet?