[SCEV] Memoize visitMulExpr results in SCEVRewriteVisitor. Fix PR18606
When SCEVRewriteVisitor traverses the SCEV DAG, it may visit the same SCEV multiple times if this SCEV is referenced by multiple other SCEVs. This has exponential time complexity in the worst case. Memoizing the results will avoid re-visiting the same SCEV.
It's legal to memoize the rewrite results because SCEVRewriteVisitor is state-less, i.e., it should return the same rewrite result each time for the same input SCEV. Currently only memoize results of visitMulExpr because other functions are much cheaper in the worst case.
This patch depends on D25794, and they together fix PR18606.