[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 20:10:13 PDT 2017


mkazantsev added inline comments.


================
Comment at: lib/Analysis/ScalarEvolution.cpp:2681
   SmallVector<const SCEV *, 4> Ops;
+  SmallSet<const SCEV *, 4> Visited;
   Ops.push_back(StartExpr);
----------------
sanjoy wrote:
> 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?
Yes, it can be done. I'll update the patch.


https://reviews.llvm.org/D35931





More information about the llvm-commits mailing list