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