[PATCH] D34025: [SCEV] Teach SCEVExpander to expand BinPow

Max Kazantsev via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sun Jun 18 22:29:34 PDT 2017


mkazantsev added inline comments.


================
Comment at: lib/Analysis/ScalarEvolutionExpander.cpp:767
+    while (E != OpsAndLoops.end() && *I == *E && Exponent != MaxExponent) {
+      ++Exponent; ++E;
+    }
----------------
mkazantsev wrote:
> sanjoy wrote:
> > Avoid braces here.
> > 
> > You could also write this loop using `find_if`.
> > 
> > Finally I'd perhaps suggest using a `uint64_t` for `Exponent` so that an overflow is practically impossible.
> I cannot get rid of braces because of two operands inside. Will split them into two lines.
> 
> Isn't it true that the operands here are sorted? If yes, we just need a consecutive sequence of similar operands, find_if here would be an overcomplication.
> 
> Agreed with uint64_t.
Added a test that checks that the BinPow is expanded even if the calculation of SCEV included different operands.



https://reviews.llvm.org/D34025





More information about the llvm-commits mailing list