[PATCH] D43759: [SCEV] Smarter logic in computeConstantDifference

Sanjoy Das via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Mar 2 09:55:08 PST 2018


sanjoy added inline comments.


================
Comment at: lib/Analysis/ScalarEvolution.cpp:9396
+  if (auto *Difference = dyn_cast<SCEVConstant>(
+          getMinusSCEV(More, Less, SCEV::FlagAnyWrap, MaxArithDepth - 1)))
+    return Difference->getAPInt();
----------------
mkazantsev wrote:
> sanjoy wrote:
> > I'd much rather not put all of this (albeit non-recursive) work here when it is possible to easily extend the existing code to handle your pattern.
> Do we really want to add every easy pattern we find here in future just because it is easy? It looks counter-general. And we don't know how many other relatively simple cases we do not handle.
> Do we really want to add every easy pattern we find here in future just because it is easy?

If this function starts growing too much with a lot of ad-hoc strategies, we need some other way to handle the kinds of cases you're trying to handle (perhaps by making code higher up the stack smarter).

But for now you should be able to easily handle `LHS = {X + C1,+,step}, RHS = {X + C2,+,step}`,


https://reviews.llvm.org/D43759





More information about the llvm-commits mailing list