1 ; NOTE: Assertions have been autogenerated by utils/update_analyze_test_checks.py UTC_ARGS: --version 2
2 ; RUN: opt -disable-output "-passes=print<scalar-evolution>" < %s 2>&1 | FileCheck %s
4 define i32 @test_1_non_negative(i32 %n) {
5 ; CHECK-LABEL: 'test_1_non_negative'
6 ; CHECK-NEXT: Classifying expressions for: @test_1_non_negative
7 ; CHECK-NEXT: %i = phi i32 [ 0, %entry ], [ %i.next, %loop ]
8 ; CHECK-NEXT: --> {0,+,1}<nuw><nsw><%loop> U: [0,2147483647) S: [0,2147483647) Exits: (-1 + (1 smax %n))<nsw> LoopDispositions: { %loop: Computable }
9 ; CHECK-NEXT: %a = sub i32 %n, %i
10 ; CHECK-NEXT: --> {%n,+,-1}<nw><%loop> U: full-set S: full-set Exits: (1 + (-1 * (1 smax %n))<nsw> + %n) LoopDispositions: { %loop: Computable }
11 ; CHECK-NEXT: %i.next = add nuw nsw i32 %i, 1
12 ; CHECK-NEXT: --> {1,+,1}<nuw><nsw><%loop> U: [1,-2147483648) S: [1,-2147483648) Exits: (1 smax %n) LoopDispositions: { %loop: Computable }
13 ; CHECK-NEXT: Determining loop execution counts for: @test_1_non_negative
14 ; CHECK-NEXT: Loop %loop: backedge-taken count is (-1 + (1 smax %n))<nsw>
15 ; CHECK-NEXT: Loop %loop: constant max backedge-taken count is 2147483646
16 ; CHECK-NEXT: Loop %loop: symbolic max backedge-taken count is (-1 + (1 smax %n))<nsw>
17 ; CHECK-NEXT: Loop %loop: Predicated backedge-taken count is (-1 + (1 smax %n))<nsw>
18 ; CHECK-NEXT: Predicates:
19 ; CHECK-NEXT: Loop %loop: Trip multiple is 1
22 %precond = icmp sge i32 %n, 0
23 br i1 %precond, label %loop, label %fail
26 %i = phi i32 [0, %entry], [%i.next, %loop] ; 0...n-1
27 %a = sub i32 %n, %i ; n...0
28 %i.next = add nuw nsw i32 %i, 1
29 %cond = icmp slt i32 %i.next, %n
30 br i1 %cond, label %loop, label %exit
39 define i32 @test_2_non_positive(i32 %n) {
40 ; CHECK-LABEL: 'test_2_non_positive'
41 ; CHECK-NEXT: Classifying expressions for: @test_2_non_positive
42 ; CHECK-NEXT: %minus.n = mul i32 %n, -1
43 ; CHECK-NEXT: --> (-1 * %n) U: full-set S: full-set
44 ; CHECK-NEXT: %i = phi i32 [ 0, %entry ], [ %i.next, %loop ]
45 ; CHECK-NEXT: --> {0,+,1}<nuw><nsw><%loop> U: [0,2147483647) S: [0,2147483647) Exits: (-1 + (1 smax %n))<nsw> LoopDispositions: { %loop: Computable }
46 ; CHECK-NEXT: %minus.i = mul i32 %i, -1
47 ; CHECK-NEXT: --> {0,+,-1}<nsw><%loop> U: [-2147483646,1) S: [-2147483646,1) Exits: (1 + (-1 * (1 smax %n))<nsw>)<nsw> LoopDispositions: { %loop: Computable }
48 ; CHECK-NEXT: %a = sub i32 %minus.n, %minus.i
49 ; CHECK-NEXT: --> {(-1 * %n),+,1}<nw><%loop> U: full-set S: full-set Exits: (-1 + (-1 * %n) + (1 smax %n)) LoopDispositions: { %loop: Computable }
50 ; CHECK-NEXT: %i.next = add nuw nsw i32 %i, 1
51 ; CHECK-NEXT: --> {1,+,1}<nuw><nsw><%loop> U: [1,-2147483648) S: [1,-2147483648) Exits: (1 smax %n) LoopDispositions: { %loop: Computable }
52 ; CHECK-NEXT: Determining loop execution counts for: @test_2_non_positive
53 ; CHECK-NEXT: Loop %loop: backedge-taken count is (-1 + (1 smax %n))<nsw>
54 ; CHECK-NEXT: Loop %loop: constant max backedge-taken count is 2147483646
55 ; CHECK-NEXT: Loop %loop: symbolic max backedge-taken count is (-1 + (1 smax %n))<nsw>
56 ; CHECK-NEXT: Loop %loop: Predicated backedge-taken count is (-1 + (1 smax %n))<nsw>
57 ; CHECK-NEXT: Predicates:
58 ; CHECK-NEXT: Loop %loop: Trip multiple is 1
61 %precond = icmp sge i32 %n, 0
62 %minus.n = mul i32 %n, -1
63 br i1 %precond, label %loop, label %fail
66 %i = phi i32 [0, %entry], [%i.next, %loop] ; 0...n-1
67 %minus.i = mul i32 %i, -1 ; -(n-1)...0
68 %a = sub i32 %minus.n, %minus.i ; -n...-1
69 %i.next = add nuw nsw i32 %i, 1
70 %cond = icmp slt i32 %i.next, %n
71 br i1 %cond, label %loop, label %exit