[PATCH] D35931: [SCEV] Do not visit nodes twice in containsConstantSomewhere

Sanjoy Das via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Jul 27 22:32:36 PDT 2017


sanjoy added inline comments.


================
Comment at: lib/Analysis/ScalarEvolution.cpp:2685
+      if (isa<SCEVConstant>(S)) {
+        FoundConstant = true;
+        return false;
----------------
mkazantsev wrote:
> sanjoy wrote:
> > This is optional and stylistic, but you could have been briefer as:
> > 
> > ```
> > bool follow(const SCEV *S) {
> >   FoundConstant = isa<SCEVConstant>(S);
> >   return isa<SCEVAddExpr>(S) || isa<SCEVMulExpr>(S);
> > }
> > ```
> It doesn't work, the way to go is
>     FoundConstant |= isa<SCEVConstant>(S);
Interesting -- this indicates there is a small potential performance win -- we should should guard the push_back in SCEVTraversal::push also on isDone().


https://reviews.llvm.org/D35931





More information about the llvm-commits mailing list