1 ; NOTE: Assertions have been autogenerated by utils/update_analyze_test_checks.py
2 ; RUN: opt < %s -disable-output "-passes=print<scalar-evolution>" 2>&1 | FileCheck %s
4 define void @foo(ptr nocapture %arg, i32 %arg1, i32 %arg2) {
6 ; CHECK-NEXT: Classifying expressions for: @foo
7 ; CHECK-NEXT: %tmp4 = zext i32 %arg2 to i64
8 ; CHECK-NEXT: --> (zext i32 %arg2 to i64) U: [0,4294967296) S: [0,4294967296)
9 ; CHECK-NEXT: %tmp8 = phi i64 [ %tmp18, %bb7 ], [ 0, %bb3 ]
10 ; CHECK-NEXT: --> {0,+,1}<nuw><nsw><%bb7> U: [0,2147483647) S: [0,2147483647) Exits: (-1 + (zext i32 %arg2 to i64))<nsw> LoopDispositions: { %bb7: Computable }
11 ; CHECK-NEXT: %tmp9 = shl i64 %tmp8, 33
12 ; CHECK-NEXT: --> {0,+,8589934592}<nuw><%bb7> U: [0,-17179869183) S: [-9223372036854775808,9223372028264841217) Exits: (-8589934592 + (8589934592 * (zext i32 %arg2 to i64))) LoopDispositions: { %bb7: Computable }
13 ; CHECK-NEXT: %tmp10 = ashr exact i64 %tmp9, 32
14 ; CHECK-NEXT: --> (sext i32 {0,+,2}<%bb7> to i64) U: [0,-1) S: [-2147483648,2147483647) Exits: (sext i32 (-2 + (2 * %arg2)) to i64) LoopDispositions: { %bb7: Computable }
15 ; CHECK-NEXT: %tmp11 = getelementptr inbounds i32, ptr %arg, i64 %tmp10
16 ; CHECK-NEXT: --> ((4 * (sext i32 {0,+,2}<%bb7> to i64))<nsw> + %arg) U: full-set S: full-set Exits: ((4 * (sext i32 (-2 + (2 * %arg2)) to i64))<nsw> + %arg) LoopDispositions: { %bb7: Computable }
17 ; CHECK-NEXT: %tmp12 = load i32, ptr %tmp11, align 4
18 ; CHECK-NEXT: --> %tmp12 U: full-set S: full-set Exits: <<Unknown>> LoopDispositions: { %bb7: Variant }
19 ; CHECK-NEXT: %tmp13 = sub nsw i32 %tmp12, %arg1
20 ; CHECK-NEXT: --> ((-1 * %arg1) + %tmp12) U: full-set S: full-set Exits: <<Unknown>> LoopDispositions: { %bb7: Variant }
21 ; CHECK-NEXT: %tmp14 = or disjoint i64 %tmp10, 1
22 ; CHECK-NEXT: --> (1 + (sext i32 {0,+,2}<%bb7> to i64))<nuw><nsw> U: [1,0) S: [-2147483647,2147483648) Exits: (1 + (sext i32 (-2 + (2 * %arg2)) to i64))<nuw><nsw> LoopDispositions: { %bb7: Computable }
23 ; CHECK-NEXT: %tmp15 = getelementptr inbounds i32, ptr %arg, i64 %tmp14
24 ; CHECK-NEXT: --> (4 + (4 * (sext i32 {0,+,2}<%bb7> to i64))<nsw> + %arg) U: full-set S: full-set Exits: (4 + (4 * (sext i32 (-2 + (2 * %arg2)) to i64))<nsw> + %arg) LoopDispositions: { %bb7: Computable }
25 ; CHECK-NEXT: %tmp16 = load i32, ptr %tmp15, align 4
26 ; CHECK-NEXT: --> %tmp16 U: full-set S: full-set Exits: <<Unknown>> LoopDispositions: { %bb7: Variant }
27 ; CHECK-NEXT: %tmp17 = mul nsw i32 %tmp16, %arg1
28 ; CHECK-NEXT: --> (%arg1 * %tmp16) U: full-set S: full-set Exits: <<Unknown>> LoopDispositions: { %bb7: Variant }
29 ; CHECK-NEXT: %tmp18 = add nuw nsw i64 %tmp8, 1
30 ; CHECK-NEXT: --> {1,+,1}<nuw><nsw><%bb7> U: [1,2147483648) S: [1,2147483648) Exits: (zext i32 %arg2 to i64) LoopDispositions: { %bb7: Computable }
31 ; CHECK-NEXT: Determining loop execution counts for: @foo
32 ; CHECK-NEXT: Loop %bb7: backedge-taken count is (-1 + (zext i32 %arg2 to i64))<nsw>
33 ; CHECK-NEXT: Loop %bb7: constant max backedge-taken count is 2147483646
34 ; CHECK-NEXT: Loop %bb7: symbolic max backedge-taken count is (-1 + (zext i32 %arg2 to i64))<nsw>
35 ; CHECK-NEXT: Loop %bb7: Predicated backedge-taken count is (-1 + (zext i32 %arg2 to i64))<nsw>
36 ; CHECK-NEXT: Predicates:
37 ; CHECK-NEXT: Loop %bb7: Trip multiple is 1
40 %tmp = icmp sgt i32 %arg2, 0
41 br i1 %tmp, label %bb3, label %bb6
44 %tmp4 = zext i32 %arg2 to i64
50 bb6: ; preds = %bb5, %bb
53 bb7: ; preds = %bb7, %bb3
54 %tmp8 = phi i64 [ %tmp18, %bb7 ], [ 0, %bb3 ]
55 %tmp9 = shl i64 %tmp8, 33
56 %tmp10 = ashr exact i64 %tmp9, 32
57 %tmp11 = getelementptr inbounds i32, ptr %arg, i64 %tmp10
58 %tmp12 = load i32, ptr %tmp11, align 4
59 %tmp13 = sub nsw i32 %tmp12, %arg1
60 store i32 %tmp13, ptr %tmp11, align 4
61 %tmp14 = or disjoint i64 %tmp10, 1
62 %tmp15 = getelementptr inbounds i32, ptr %arg, i64 %tmp14
63 %tmp16 = load i32, ptr %tmp15, align 4
64 %tmp17 = mul nsw i32 %tmp16, %arg1
65 store i32 %tmp17, ptr %tmp15, align 4
66 %tmp18 = add nuw nsw i64 %tmp8, 1
67 %tmp19 = icmp eq i64 %tmp18, %tmp4
68 br i1 %tmp19, label %bb5, label %bb7
71 define void @goo(ptr nocapture %arg3, i32 %arg4, i32 %arg5) {
73 ; CHECK-NEXT: Classifying expressions for: @goo
74 ; CHECK-NEXT: %t4 = zext i32 %arg5 to i128
75 ; CHECK-NEXT: --> (zext i32 %arg5 to i128) U: [0,4294967296) S: [0,4294967296)
76 ; CHECK-NEXT: %t8 = phi i128 [ %t18, %bb7 ], [ 0, %bb3 ]
77 ; CHECK-NEXT: --> {0,+,1}<nuw><nsw><%bb7> U: [0,2147483647) S: [0,2147483647) Exits: (-1 + (zext i32 %arg5 to i128))<nsw> LoopDispositions: { %bb7: Computable }
78 ; CHECK-NEXT: %t9 = shl i128 %t8, 100
79 ; CHECK-NEXT: --> {0,+,1267650600228229401496703205376}<%bb7> U: [0,-1267650600228229401496703205375) S: [-170141183460469231731687303715884105728,170141182192818631503457902219180900353) Exits: (-1267650600228229401496703205376 + (1267650600228229401496703205376 * (zext i32 %arg5 to i128))) LoopDispositions: { %bb7: Computable }
80 ; CHECK-NEXT: %t10 = ashr exact i128 %t9, 1
81 ; CHECK-NEXT: --> (sext i127 {0,+,633825300114114700748351602688}<%bb7> to i128) U: [0,-633825300114114700748351602687) S: [-85070591730234615865843651857942052864,85070591096409315751728951109590450177) Exits: (sext i127 (-633825300114114700748351602688 + (633825300114114700748351602688 * (zext i32 %arg5 to i127))) to i128) LoopDispositions: { %bb7: Computable }
82 ; CHECK-NEXT: %t11 = getelementptr inbounds i32, ptr %arg3, i128 %t10
83 ; CHECK-NEXT: --> %arg3 U: full-set S: full-set Exits: %arg3 LoopDispositions: { %bb7: Invariant }
84 ; CHECK-NEXT: %t12 = load i32, ptr %t11, align 4
85 ; CHECK-NEXT: --> %t12 U: full-set S: full-set Exits: <<Unknown>> LoopDispositions: { %bb7: Variant }
86 ; CHECK-NEXT: %t13 = sub nsw i32 %t12, %arg4
87 ; CHECK-NEXT: --> ((-1 * %arg4) + %t12) U: full-set S: full-set Exits: <<Unknown>> LoopDispositions: { %bb7: Variant }
88 ; CHECK-NEXT: %t14 = or disjoint i128 %t10, 1
89 ; CHECK-NEXT: --> (1 + (sext i127 {0,+,633825300114114700748351602688}<%bb7> to i128))<nuw><nsw> U: [1,-633825300114114700748351602686) S: [-85070591730234615865843651857942052863,85070591096409315751728951109590450178) Exits: (1 + (sext i127 (-633825300114114700748351602688 + (633825300114114700748351602688 * (zext i32 %arg5 to i127))) to i128))<nuw><nsw> LoopDispositions: { %bb7: Computable }
90 ; CHECK-NEXT: %t15 = getelementptr inbounds i32, ptr %arg3, i128 %t14
91 ; CHECK-NEXT: --> (4 + %arg3)<nuw> U: [4,0) S: [4,0) Exits: (4 + %arg3)<nuw> LoopDispositions: { %bb7: Invariant }
92 ; CHECK-NEXT: %t16 = load i32, ptr %t15, align 4
93 ; CHECK-NEXT: --> %t16 U: full-set S: full-set Exits: <<Unknown>> LoopDispositions: { %bb7: Variant }
94 ; CHECK-NEXT: %t17 = mul nsw i32 %t16, %arg4
95 ; CHECK-NEXT: --> (%arg4 * %t16) U: full-set S: full-set Exits: <<Unknown>> LoopDispositions: { %bb7: Variant }
96 ; CHECK-NEXT: %t18 = add nuw nsw i128 %t8, 1
97 ; CHECK-NEXT: --> {1,+,1}<nuw><nsw><%bb7> U: [1,2147483648) S: [1,2147483648) Exits: (zext i32 %arg5 to i128) LoopDispositions: { %bb7: Computable }
98 ; CHECK-NEXT: Determining loop execution counts for: @goo
99 ; CHECK-NEXT: Loop %bb7: backedge-taken count is (-1 + (zext i32 %arg5 to i128))<nsw>
100 ; CHECK-NEXT: Loop %bb7: constant max backedge-taken count is 2147483646
101 ; CHECK-NEXT: Loop %bb7: symbolic max backedge-taken count is (-1 + (zext i32 %arg5 to i128))<nsw>
102 ; CHECK-NEXT: Loop %bb7: Predicated backedge-taken count is (-1 + (zext i32 %arg5 to i128))<nsw>
103 ; CHECK-NEXT: Predicates:
104 ; CHECK-NEXT: Loop %bb7: Trip multiple is 1
107 %t = icmp sgt i32 %arg5, 0
108 br i1 %t, label %bb3, label %bb6
111 %t4 = zext i32 %arg5 to i128
117 bb6: ; preds = %bb5, %bb
120 bb7: ; preds = %bb7, %bb3
121 %t8 = phi i128 [ %t18, %bb7 ], [ 0, %bb3 ]
122 %t9 = shl i128 %t8, 100
123 %t10 = ashr exact i128 %t9, 1
124 %t11 = getelementptr inbounds i32, ptr %arg3, i128 %t10
125 %t12 = load i32, ptr %t11, align 4
126 %t13 = sub nsw i32 %t12, %arg4
127 store i32 %t13, ptr %t11, align 4
128 %t14 = or disjoint i128 %t10, 1
129 %t15 = getelementptr inbounds i32, ptr %arg3, i128 %t14
130 %t16 = load i32, ptr %t15, align 4
131 %t17 = mul nsw i32 %t16, %arg4
132 store i32 %t17, ptr %t15, align 4
133 %t18 = add nuw nsw i128 %t8, 1
134 %t19 = icmp eq i128 %t18, %t4
135 br i1 %t19, label %bb5, label %bb7