1 ; NOTE: Assertions have been autogenerated by utils/update_analyze_test_checks.py
2 ; RUN: opt -S -analyze -enable-new-pm=0 -scalar-evolution < %s | FileCheck %s
3 ; RUN: opt -S -disable-output "-passes=print<scalar-evolution>" < %s 2>&1 | FileCheck %s
5 define void @umin_unsigned_check(i64 %n) {
6 ; CHECK-LABEL: 'umin_unsigned_check'
7 ; CHECK-NEXT: Classifying expressions for: @umin_unsigned_check
8 ; CHECK-NEXT: %min.n = select i1 %min.cmp, i64 4096, i64 %n
9 ; CHECK-NEXT: --> (4096 umin %n) U: [0,4097) S: [0,4097)
10 ; CHECK-NEXT: %iv = phi i64 [ 0, %entry ], [ %iv.next, %loop ]
11 ; CHECK-NEXT: --> {0,+,1}<%loop> U: [0,4098) S: [0,4098) Exits: (1 + (4096 umin %n))<nuw><nsw> LoopDispositions: { %loop: Computable }
12 ; CHECK-NEXT: %iv.next = add i64 %iv, 1
13 ; CHECK-NEXT: --> {1,+,1}<%loop> U: [1,4099) S: [1,4099) Exits: (2 + (4096 umin %n))<nuw><nsw> LoopDispositions: { %loop: Computable }
14 ; CHECK-NEXT: Determining loop execution counts for: @umin_unsigned_check
15 ; CHECK-NEXT: Loop %loop: backedge-taken count is (1 + (4096 umin %n))<nuw><nsw>
16 ; CHECK-NEXT: Loop %loop: max backedge-taken count is 4097
17 ; CHECK-NEXT: Loop %loop: Predicated backedge-taken count is (1 + (4096 umin %n))<nuw><nsw>
18 ; CHECK-NEXT: Predicates:
19 ; CHECK: Loop %loop: Trip multiple is 1
22 %min.cmp = icmp ult i64 4096, %n
23 %min.n = select i1 %min.cmp, i64 4096, i64 %n
26 %iv = phi i64 [ 0, %entry ], [ %iv.next, %loop ]
27 %iv.next = add i64 %iv, 1
28 %exit = icmp ugt i64 %iv, %min.n
29 br i1 %exit, label %loop_exit, label %loop
35 define void @umin_signed_check(i64 %n) {
36 ; CHECK-LABEL: 'umin_signed_check'
37 ; CHECK-NEXT: Classifying expressions for: @umin_signed_check
38 ; CHECK-NEXT: %min.n = select i1 %min.cmp, i64 4096, i64 %n
39 ; CHECK-NEXT: --> (4096 umin %n) U: [0,4097) S: [0,4097)
40 ; CHECK-NEXT: %iv = phi i64 [ 0, %entry ], [ %iv.next, %loop ]
41 ; CHECK-NEXT: --> {0,+,1}<%loop> U: [0,4098) S: [0,4098) Exits: (1 + (4096 umin %n))<nuw><nsw> LoopDispositions: { %loop: Computable }
42 ; CHECK-NEXT: %iv.next = add i64 %iv, 1
43 ; CHECK-NEXT: --> {1,+,1}<%loop> U: [1,4099) S: [1,4099) Exits: (2 + (4096 umin %n))<nuw><nsw> LoopDispositions: { %loop: Computable }
44 ; CHECK-NEXT: Determining loop execution counts for: @umin_signed_check
45 ; CHECK-NEXT: Loop %loop: backedge-taken count is (1 + (4096 umin %n))<nuw><nsw>
46 ; CHECK-NEXT: Loop %loop: max backedge-taken count is 4097
47 ; CHECK-NEXT: Loop %loop: Predicated backedge-taken count is (1 + (4096 umin %n))<nuw><nsw>
48 ; CHECK-NEXT: Predicates:
49 ; CHECK: Loop %loop: Trip multiple is 1
52 %min.cmp = icmp ult i64 4096, %n
53 %min.n = select i1 %min.cmp, i64 4096, i64 %n
56 %iv = phi i64 [ 0, %entry ], [ %iv.next, %loop ]
57 %iv.next = add i64 %iv, 1
58 %exit = icmp sgt i64 %iv, %min.n
59 br i1 %exit, label %loop_exit, label %loop
65 define void @smin_signed_check(i64 %n) {
66 ; CHECK-LABEL: 'smin_signed_check'
67 ; CHECK-NEXT: Classifying expressions for: @smin_signed_check
68 ; CHECK-NEXT: %min.n = select i1 %min.cmp, i64 4096, i64 %n
69 ; CHECK-NEXT: --> (4096 smin %n) U: [-9223372036854775808,4097) S: [-9223372036854775808,4097)
70 ; CHECK-NEXT: %iv = phi i64 [ 0, %entry ], [ %iv.next, %loop ]
71 ; CHECK-NEXT: --> {0,+,1}<%loop> U: [0,4098) S: [0,4098) Exits: (0 smax (1 + (4096 smin %n))<nsw>) LoopDispositions: { %loop: Computable }
72 ; CHECK-NEXT: %iv.next = add i64 %iv, 1
73 ; CHECK-NEXT: --> {1,+,1}<%loop> U: [1,4099) S: [1,4099) Exits: (1 + (0 smax (1 + (4096 smin %n))<nsw>))<nuw><nsw> LoopDispositions: { %loop: Computable }
74 ; CHECK-NEXT: Determining loop execution counts for: @smin_signed_check
75 ; CHECK-NEXT: Loop %loop: backedge-taken count is (0 smax (1 + (4096 smin %n))<nsw>)
76 ; CHECK-NEXT: Loop %loop: max backedge-taken count is 4097
77 ; CHECK-NEXT: Loop %loop: Predicated backedge-taken count is (0 smax (1 + (4096 smin %n))<nsw>)
78 ; CHECK-NEXT: Predicates:
79 ; CHECK: Loop %loop: Trip multiple is 1
82 %min.cmp = icmp slt i64 4096, %n
83 %min.n = select i1 %min.cmp, i64 4096, i64 %n
86 %iv = phi i64 [ 0, %entry ], [ %iv.next, %loop ]
87 %iv.next = add i64 %iv, 1
88 %exit = icmp sgt i64 %iv, %min.n
89 br i1 %exit, label %loop_exit, label %loop
95 define void @smin_unsigned_check(i64 %n) {
96 ; CHECK-LABEL: 'smin_unsigned_check'
97 ; CHECK-NEXT: Classifying expressions for: @smin_unsigned_check
98 ; CHECK-NEXT: %min.n = select i1 %min.cmp, i64 4096, i64 %n
99 ; CHECK-NEXT: --> (4096 smin %n) U: [-9223372036854775808,4097) S: [-9223372036854775808,4097)
100 ; CHECK-NEXT: %iv = phi i64 [ 0, %entry ], [ %iv.next, %loop ]
101 ; CHECK-NEXT: --> {0,+,1}<%loop> U: full-set S: full-set Exits: <<Unknown>> LoopDispositions: { %loop: Computable }
102 ; CHECK-NEXT: %iv.next = add i64 %iv, 1
103 ; CHECK-NEXT: --> {1,+,1}<%loop> U: full-set S: full-set Exits: <<Unknown>> LoopDispositions: { %loop: Computable }
104 ; CHECK-NEXT: Determining loop execution counts for: @smin_unsigned_check
105 ; CHECK-NEXT: Loop %loop: Unpredictable backedge-taken count.
106 ; CHECK-NEXT: Loop %loop: Unpredictable max backedge-taken count.
107 ; CHECK-NEXT: Loop %loop: Unpredictable predicated backedge-taken count.
110 %min.cmp = icmp slt i64 4096, %n
111 %min.n = select i1 %min.cmp, i64 4096, i64 %n
114 %iv = phi i64 [ 0, %entry ], [ %iv.next, %loop ]
115 %iv.next = add i64 %iv, 1
116 %exit = icmp ugt i64 %iv, %min.n
117 br i1 %exit, label %loop_exit, label %loop