• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1; RUN: opt < %s -loop-deletion -S | FileCheck %s
2
3; ScalarEvolution can prove the loop iteration is finite, even though
4; it can't represent the exact trip count as an expression. That's
5; good enough to let the loop be deleted.
6
7; CHECK:      entry:
8; CHECK-NEXT:   br label %return
9
10; CHECK:      return:
11; CHECK-NEXT:   ret void
12
13define void @foo(i64 %n, i64 %m) nounwind {
14entry:
15  br label %bb
16
17bb:
18  %x.0 = phi i64 [ 0, %entry ], [ %t0, %bb ]
19  %t0 = add i64 %x.0, 1
20  %t1 = icmp slt i64 %x.0, %n
21  %t3 = icmp sgt i64 %x.0, %m
22  %t4 = and i1 %t1, %t3
23  br i1 %t4, label %bb, label %return
24
25return:
26  ret void
27}
28