xref: /llvm-project/llvm/test/Analysis/ScalarEvolution/trip-count5.ll (revision 92619956eb27ef08dd24045307593fc3d7f78db0)
1; RUN: opt < %s -disable-output "-passes=print<scalar-evolution>" 2>&1 | FileCheck %s
2
3; ScalarEvolution should be able to compute a maximum trip count
4; value sufficient to fold away both sext casts.
5
6target 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"
7
8define float @t(ptr %pTmp1, ptr %peakWeight, ptr %nrgReducePeakrate, i32 %bim) nounwind {
9; CHECK-LABEL: Classifying expressions for: @t
10entry:
11	%tmp3 = load float, ptr %peakWeight, align 4
12	%tmp2538 = icmp sgt i32 %bim, 0
13	br i1 %tmp2538, label %bb.nph, label %bb4
14
15bb.nph:
16	br label %bb
17
18bb:
19	%distERBhi.036 = phi float [ %tmp10, %bb1 ], [ 0.000000e+00, %bb.nph ]
20	%hiPart.035 = phi i32 [ %tmp12, %bb1 ], [ 0, %bb.nph ]
21	%peakCount.034 = phi float [ %tmp19, %bb1 ], [ %tmp3, %bb.nph ]
22	%tmp6 = sext i32 %hiPart.035 to i64
23	%tmp7 = getelementptr float, ptr %pTmp1, i64 %tmp6
24; CHECK:  %tmp6 = sext i32 %hiPart.035 to i64
25; CHECK-NEXT:  -->  {0,+,1}<nuw><nsw><%bb>
26	%tmp8 = load float, ptr %tmp7, align 4
27	%tmp10 = fadd float %tmp8, %distERBhi.036
28	%tmp12 = add i32 %hiPart.035, 1
29	%tmp15 = sext i32 %tmp12 to i64
30	%tmp16 = getelementptr float, ptr %peakWeight, i64 %tmp15
31; CHECK:  %tmp15 = sext i32 %tmp12 to i64
32; CHECK-NEXT:  -->  {1,+,1}<nuw><nsw><%bb>
33	%tmp17 = load float, ptr %tmp16, align 4
34	%tmp19 = fadd float %tmp17, %peakCount.034
35	br label %bb1
36
37bb1:
38	%tmp21 = fcmp olt float %tmp10, 2.500000e+00
39	%tmp25 = icmp slt i32 %tmp12, %bim
40	%tmp27 = and i1 %tmp21, %tmp25
41	br i1 %tmp27, label %bb, label %bb1.bb4_crit_edge
42
43bb1.bb4_crit_edge:
44	br label %bb4
45
46bb4:
47	%distERBhi.0.lcssa = phi float [ %tmp10, %bb1.bb4_crit_edge ], [ 0.000000e+00, %entry ]
48	%peakCount.0.lcssa = phi float [ %tmp19, %bb1.bb4_crit_edge ], [ %tmp3, %entry ]
49	%tmp31 = fdiv float %peakCount.0.lcssa, %distERBhi.0.lcssa
50	ret float %tmp31
51}
52