[PATCH] D24651: [SCEV] Try harder to find UB for NSW/NUW instr

Christof Douma via llvm-commits llvm-commits at lists.llvm.org
Mon Sep 19 02:25:41 PDT 2016


christof added a comment.

In https://reviews.llvm.org/D24651#545945, @sanjoy wrote:

> Apologies in advance for this off-the-cuff comment with only having skimmed through your patch, let me know if you've already addressed this:  infinite loops are not UB in general, they're UB only if the loop has no side effects (i.e. no volatile or atomic operations and no IO).


I've used the existing code in SCEV that searches for UB in loops. However, that code does assume infinite loops without side effects to be UB. I guess that this comes from the C++ and C standards.


================
Comment at: lib/Analysis/ScalarEvolution.cpp:4938
@@ -4898,3 +4937,3 @@
 
-  // For an add recurrence specifically, we assume that infinite loops without
-  // side effects are undefined behavior, and then reason as follows:
+bool ScalarEvolution::isAlwaysLatchControlDependentOnPoison(const Instruction *I, const Loop *L) {
+  // We assume that infinite loops without side effects are undefined behavior,
----------------
This (existing, but renamed) function does assume that infinite loops without side effect  are also UB. See the long comment on its reasoning.


Repository:
  rL LLVM

https://reviews.llvm.org/D24651





More information about the llvm-commits mailing list