1; RUN: opt < %s -analyze -enable-new-pm=0 -scalar-evolution | FileCheck %s
2; RUN: opt < %s -disable-output "-passes=print<scalar-evolution>" 2>&1 | FileCheck %s
3
4; CHECK:  %tmp9 = shl i64 %tmp8, 33
5; CHECK-NEXT:  -->  {{.*}} Exits: (-8589934592 + (8589934592 * (zext i32 %arg2 to i64)))
6; CHECK-NEXT:  %tmp10 = ashr exact i64 %tmp9, 0
7; CHECK-NEXT:  -->  {{.*}} Exits: (-8589934592 + (8589934592 * (zext i32 %arg2 to i64)))
8
9define void @foo(i32* nocapture %arg, i32 %arg1, i32 %arg2) {
10bb:
11  %tmp = icmp sgt i32 %arg2, 0
12  br i1 %tmp, label %bb3, label %bb6
13
14bb3:                                              ; preds = %bb
15  %tmp4 = zext i32 %arg2 to i64
16  br label %bb7
17
18bb5:                                              ; preds = %bb7
19  br label %bb6
20
21bb6:                                              ; preds = %bb5, %bb
22  ret void
23
24bb7:                                              ; preds = %bb7, %bb3
25  %tmp8 = phi i64 [ %tmp18, %bb7 ], [ 0, %bb3 ]
26  %tmp9 = shl i64 %tmp8, 33
27  %tmp10 = ashr exact i64 %tmp9, 0
28  %tmp11 = getelementptr inbounds i32, i32* %arg, i64 %tmp10
29  %tmp12 = load i32, i32* %tmp11, align 4
30  %tmp13 = sub nsw i32 %tmp12, %arg1
31  store i32 %tmp13, i32* %tmp11, align 4
32  %tmp14 = or i64 %tmp10, 1
33  %tmp15 = getelementptr inbounds i32, i32* %arg, i64 %tmp14
34  %tmp16 = load i32, i32* %tmp15, align 4
35  %tmp17 = mul nsw i32 %tmp16, %arg1
36  store i32 %tmp17, i32* %tmp15, align 4
37  %tmp18 = add nuw nsw i64 %tmp8, 1
38  %tmp19 = icmp eq i64 %tmp18, %tmp4
39  br i1 %tmp19, label %bb5, label %bb7
40}
41