[MustExecute] Add simplest possible test for LoopSafetyOnfo
authorPhilip Reames <listmail@philipreames.com>
Tue, 20 Mar 2018 22:55:20 +0000 (22:55 +0000)
committerPhilip Reames <listmail@philipreames.com>
Tue, 20 Mar 2018 22:55:20 +0000 (22:55 +0000)
(Currently showing without, will enable and check in diff to show impact)

llvm-svn: 328056

llvm/test/Analysis/MustExecute/loop-header.ll

index b74c3e2a31734eb45ecd1463db5876609ce2121b..4d4c1ff90fc698217bd6b0675efa4dfb926b457b 100644 (file)
@@ -83,5 +83,31 @@ exit:
   ret i1 false
 }
 
+; Since all the instructions in the loop dominate the only exit
+; and there's no implicit control flow in the loop, all must execute
+; FIXME: handled by loop safety info, test it
+define i1 @nothrow_loop(i32* noalias %p, i32 %high) {
+; CHECK-LABEL: @nothrow_loop(
+; CHECK-LABEL:       loop:
+; CHECK:         %iv = phi i32 [ 0, %entry ], [ %iv.next, %next ] ; (mustexec in: loop)
+; CHECK:          br label %next ; (mustexec in: loop)
+; CHECK-NOT: mustexec
+
+entry:
+  br label %loop
+
+loop:
+  %iv = phi i32 [0, %entry], [%iv.next, %next]
+  br label %next
+next:
+  %v = load i32, i32* %p
+  %iv.next = add nsw nuw i32 %iv, 1
+  %exit.test = icmp slt i32 %iv, %high
+  br i1 %exit.test, label %exit, label %loop
+
+exit:
+  ret i1 false
+}
+
 
 declare void @maythrow_and_use(i32)