[PATCH] D27216: [SCEVExpand] do not hoist divisions by zero (PR30935)

Sanjoy Das via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Nov 29 10:10:41 PST 2016


sanjoy requested changes to this revision.
sanjoy added a comment.
This revision now requires changes to proceed.

I tried to address this some time back in https://reviews.llvm.org/rL286437, but that had to be reverted due to PR30976.  Can you please take a look and make sure that this patch does not have the same problem?

Also, does the C++ unit test case from https://reviews.llvm.org/rL286437 also pass with this patch?  If so, that would be nice to include too.



================
Comment at: llvm/lib/Analysis/ScalarEvolutionExpander.cpp:1670
+  if (!SCEVExprContains(S, [](const SCEV *S) {
+        if (const SCEVUDivExpr *D = dyn_cast<SCEVUDivExpr>(S))
+          // Divisions by anything other than constants should not be moved
----------------
Use `const auto *`


================
Comment at: llvm/lib/Analysis/ScalarEvolutionExpander.cpp:1673
+          // (PR30935.)
+          return !isa<SCEVConstant>(D->getRHS());
+        return false;
----------------
What about divisions by constant zero?  If they can't happen, then add an assert here.


https://reviews.llvm.org/D27216





More information about the llvm-commits mailing list