1 ; RUN: opt -disable-output "-passes=print<scalar-evolution>" < %s 2>&1 | FileCheck %s
3 define void @single_loop(ptr %buf, i32 %start) {
4 ; CHECK-LABEL: Classifying expressions for: @single_loop
6 %val = add i32 %start, 400
10 %counter = phi i32 [ 0, %entry ], [ %counter.inc, %loop ]
11 %idx = phi i32 [ %start, %entry ], [ %idx.inc, %loop ]
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, ptr %buf
22 ; CHECK-NEXT: --> {{.*}} LoopDispositions: { %loop: Variant }
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, ptr %buf
30 br i1 %condition, label %exit, label %loop
37 define void @nested_loop(ptr %p, i64 %m) {
38 ; CHECK-LABEL: Classifying expressions for: @nested_loop
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 }
52 %k = icmp sgt i64 %m, 0
53 br i1 %k, label %outer.loop, label %return
56 %j = phi i64 [ 0, %entry ], [ %j.next, %outer.latch ]
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
67 %j.next = add i64 %j, 91
68 %h = icmp eq i64 %j.next, %m
69 br i1 %h, label %return, label %outer.loop