[SCEV] Avoid redundant computations when doing AddRec merge

When we calculate a product of 2 AddRecs, we end up making quite massive
computations to deduce the operands of resulting AddRec. This process can
be optimized by computing all args of intermediate sum and then calling
`getAddExpr` once rather than calling `getAddExpr` with intermediate
result every time a new argument is computed.

Differential Revision: https://reviews.llvm.org/D53189
Reviewed By: rtereshin


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@345813 91177308-0d34-0410-b5e6-96231b3b80d8
2 files changed