[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 15:09:29 PDT 2017


sanjoy added inline comments.


================
Comment at: lib/Analysis/ScalarEvolution.cpp:2681
   SmallVector<const SCEV *, 4> Ops;
+  SmallSet<const SCEV *, 4> Visited;
   Ops.push_back(StartExpr);
----------------
mkazantsev wrote:
> sanjoy wrote:
> > Can you use `SCEVExprContains` here?
> As far as I understand, SCEVExprContains just traverses through all operands of all types, and this method states that it only needs to pass through Add and Mul exprs. This method is only used when we try to recognize a formula `C1*(C2+V) -> C1*C2 + C1*V`. So we don't need just any constant, traversing through SCEVs of other types might be an overhead (and potentially change the behavior of users of this function).
I see, how about using `SCEVTraversal` then?


https://reviews.llvm.org/D35931





More information about the llvm-commits mailing list