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

Max Kazantsev via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Jul 27 22:25:12 PDT 2017


mkazantsev added inline comments.


================
Comment at: lib/Analysis/ScalarEvolution.cpp:2685
+      if (isa<SCEVConstant>(S)) {
+        FoundConstant = true;
+        return false;
----------------
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);


https://reviews.llvm.org/D35931





More information about the llvm-commits mailing list