Be wary of abnormal exits from loop when exploiting UB

We can safely rely on a NoWrap add recurrence causing UB down the road
only if we know the loop does not have a exit expressed in a way that is
opaque to ScalarEvolution (e.g. by a function call that conditionally
calls exit(0)).

I believe with this change PR28012 is fixed.

Note: I had to change some llvm-lit tests in LoopReroll, since it looks
like they were depending on this incorrect behavior.

llvm-svn: 272237
diff --git a/llvm/test/Transforms/LoopReroll/basic.ll b/llvm/test/Transforms/LoopReroll/basic.ll
index 16a6dc8..ce2ab2f 100644
--- a/llvm/test/Transforms/LoopReroll/basic.ll
+++ b/llvm/test/Transforms/LoopReroll/basic.ll
@@ -24,7 +24,7 @@
   %add2 = add nsw i32 %i.08, 2
   %call3 = tail call i32 @foo(i32 %add2) #1
   %add3 = add nsw i32 %i.08, 3
-  %exitcond = icmp eq i32 %add3, 500
+  %exitcond = icmp sge i32 %add3, 500
   br i1 %exitcond, label %for.end, label %for.body
 
 ; CHECK-LABEL: @bar
@@ -33,7 +33,7 @@
 ; CHECK: %indvar = phi i32 [ %indvar.next, %for.body ], [ 0, %entry ]
 ; CHECK: %call = tail call i32 @foo(i32 %indvar) #1
 ; CHECK: %indvar.next = add i32 %indvar, 1
-; CHECK: %exitcond1 = icmp eq i32 %indvar, 497
+; CHECK: %exitcond1 = icmp eq i32 %indvar, 500
 ; CHECK: br i1 %exitcond1, label %for.end, label %for.body
 
 ; CHECK: ret
@@ -524,7 +524,7 @@
 
   %add3 = add nsw i32 %i.08, 3
 
-  %exitcond = icmp eq i32 %add3, 500
+  %exitcond = icmp sge i32 %add3, 500
   br i1 %exitcond, label %for.end, label %for.body
 
 ; CHECK-LABEL: @bar2
@@ -536,7 +536,7 @@
 ; CHECK: %tmp3 = add i32 %tmp2, %tmp1
 ; CHECK: %call = tail call i32 @foo(i32 %tmp3) #1
 ; CHECK: %indvar.next = add i32 %indvar, 1
-; CHECK: %exitcond1 = icmp eq i32 %indvar, 497
+; CHECK: %exitcond1 = icmp eq i32 %indvar, 500
 ; CHECK: br i1 %exitcond1, label %for.end, label %for.body
 
 ; CHECK: ret