• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1; RUN: opt -analyze -scalar-evolution < %s | FileCheck %s
2
3define void @single_loop(i32* %buf, i32 %start) {
4; CHECK-LABEL: Classifying expressions for: @single_loop
5 entry:
6  %val = add i32 %start, 400
7  br label %loop
8
9 loop:
10  %counter = phi i32 [ 0, %entry ], [ %counter.inc, %loop ]
11  %idx = phi i32 [ %start, %entry ], [ %idx.inc, %loop ]
12
13; CHECK:  %counter = phi i32 [ 0, %entry ], [ %counter.inc, %loop ]
14; CHECK-NEXT:  -->  {{.*}} LoopDispositions: { %loop: Computable }
15; CHECK:  %idx = phi i32 [ %start, %entry ], [ %idx.inc, %loop ]
16; CHECK-NEXT:  -->  {{.*}} LoopDispositions: { %loop: Computable }
17; CHECK:  %val2 = add i32 %start, 400
18; CHECK-NEXT:  -->  {{.*}} LoopDispositions: { %loop: Invariant }
19; CHECK:  %idx.inc = add nsw i32 %idx, 1
20; CHECK-NEXT:  -->  {{.*}} LoopDispositions: { %loop: Computable }
21; CHECK:  %val3 = load volatile i32, i32* %buf
22; CHECK-NEXT:  -->  {{.*}} LoopDispositions: { %loop: Variant }
23
24  %val2 = add i32 %start, 400
25  %idx.inc = add nsw i32 %idx, 1
26  %idx.inc.sext = sext i32 %idx.inc to i64
27  %condition = icmp eq i32 %counter, 1
28  %counter.inc = add i32 %counter, 1
29  %val3 = load volatile i32, i32* %buf
30  br i1 %condition, label %exit, label %loop
31
32 exit:
33  ret void
34}
35
36
37define void @nested_loop(double* %p, i64 %m) {
38; CHECK-LABEL: Classifying expressions for: @nested_loop
39
40; CHECK:  %j = phi i64 [ 0, %entry ], [ %j.next, %outer.latch ]
41; CHECK-NEXT:  -->  {{.*}} LoopDispositions: { %outer.loop: Computable, %bb: Invariant }
42; CHECK:  %i = phi i64 [ 0, %outer.loop ], [ %i.next, %bb ]
43; CHECK-NEXT:  -->  {{.*}} LoopDispositions: { %bb: Computable, %outer.loop: Variant }
44; CHECK:  %j.add = add i64 %j, 100
45; CHECK-NEXT:  -->  {{.*}} LoopDispositions: { %bb: Invariant, %outer.loop: Computable }
46; CHECK:  %i.next = add i64 %i, 1
47; CHECK-NEXT:  -->  {{.*}} LoopDispositions: { %bb: Computable, %outer.loop: Variant }
48; CHECK:  %j.next = add i64 %j, 91
49; CHECK-NEXT:  -->  {{.*}} LoopDispositions: { %outer.loop: Computable, %bb: Invariant }
50
51entry:
52  %k = icmp sgt i64 %m, 0
53  br i1 %k, label %outer.loop, label %return
54
55outer.loop:
56  %j = phi i64 [ 0, %entry ], [ %j.next, %outer.latch ]
57  br label %bb
58
59bb:
60  %i = phi i64 [ 0, %outer.loop ], [ %i.next, %bb ]
61  %j.add = add i64 %j, 100
62  %i.next = add i64 %i, 1
63  %exitcond = icmp eq i64 %i.next, 91
64  br i1 %exitcond, label %outer.latch, label %bb
65
66outer.latch:
67  %j.next = add i64 %j, 91
68  %h = icmp eq i64 %j.next, %m
69  br i1 %h, label %return, label %outer.loop
70
71return:
72  ret void
73}
74