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; ScalarEvolution should be able to compute a maximum trip count
5; value sufficient to fold away both sext casts.
6
7target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128"
8
9define float @t(float* %pTmp1, float* %peakWeight, float* %nrgReducePeakrate, i32 %bim) nounwind {
10; CHECK-LABEL: Classifying expressions for: @t
11entry:
12	%tmp3 = load float, float* %peakWeight, align 4
13	%tmp2538 = icmp sgt i32 %bim, 0
14	br i1 %tmp2538, label %bb.nph, label %bb4
15
16bb.nph:
17	br label %bb
18
19bb:
20	%distERBhi.036 = phi float [ %tmp10, %bb1 ], [ 0.000000e+00, %bb.nph ]
21	%hiPart.035 = phi i32 [ %tmp12, %bb1 ], [ 0, %bb.nph ]
22	%peakCount.034 = phi float [ %tmp19, %bb1 ], [ %tmp3, %bb.nph ]
23	%tmp6 = sext i32 %hiPart.035 to i64
24	%tmp7 = getelementptr float, float* %pTmp1, i64 %tmp6
25; CHECK:  %tmp6 = sext i32 %hiPart.035 to i64
26; CHECK-NEXT:  -->  {0,+,1}<nuw><nsw><%bb>
27	%tmp8 = load float, float* %tmp7, align 4
28	%tmp10 = fadd float %tmp8, %distERBhi.036
29	%tmp12 = add i32 %hiPart.035, 1
30	%tmp15 = sext i32 %tmp12 to i64
31	%tmp16 = getelementptr float, float* %peakWeight, i64 %tmp15
32; CHECK:  %tmp15 = sext i32 %tmp12 to i64
33; CHECK-NEXT:  -->  {1,+,1}<nuw><nsw><%bb>
34	%tmp17 = load float, float* %tmp16, align 4
35	%tmp19 = fadd float %tmp17, %peakCount.034
36	br label %bb1
37
38bb1:
39	%tmp21 = fcmp olt float %tmp10, 2.500000e+00
40	%tmp25 = icmp slt i32 %tmp12, %bim
41	%tmp27 = and i1 %tmp21, %tmp25
42	br i1 %tmp27, label %bb, label %bb1.bb4_crit_edge
43
44bb1.bb4_crit_edge:
45	br label %bb4
46
47bb4:
48	%distERBhi.0.lcssa = phi float [ %tmp10, %bb1.bb4_crit_edge ], [ 0.000000e+00, %entry ]
49	%peakCount.0.lcssa = phi float [ %tmp19, %bb1.bb4_crit_edge ], [ %tmp3, %entry ]
50	%tmp31 = fdiv float %peakCount.0.lcssa, %distERBhi.0.lcssa
51	ret float %tmp31
52}
53