1 ; RUN: opt < %s -disable-output "-passes=print<scalar-evolution>" 2>&1 2>&1 | FileCheck %s
3 ; CHECK: Loop %bb: backedge-taken count is (((-3 + (-1 * (1 umin (-3 + (-1 * %x) + (1000 umax (3 + %x)))))<nuw><nsw> + (-1 * %x) + (1000 umax (3 + %x))) /u 3) + (1 umin (-3 + (-1 * %x) + (1000 umax (3 + %x)))))
4 ; CHECK: Loop %bb: constant max backedge-taken count is 334
7 ; This is a tricky testcase for unsigned wrap detection which ScalarEvolution
8 ; doesn't yet know how to do.
10 define i32 @f(i32 %x) nounwind readnone {
12 %0 = icmp ugt i32 %x, 999 ; <i1> [#uses=1]
13 br i1 %0, label %bb2, label %bb.nph
15 bb.nph: ; preds = %entry
18 bb: ; preds = %bb.nph, %bb1
19 %indvar = phi i32 [ 0, %bb.nph ], [ %indvar.next, %bb1 ] ; <i32> [#uses=2]
20 %tmp = mul i32 %indvar, 3 ; <i32> [#uses=1]
21 %x_addr.04 = add i32 %tmp, %x ; <i32> [#uses=1]
22 %1 = add i32 %x_addr.04, 3 ; <i32> [#uses=2]
26 %2 = icmp ugt i32 %1, 999 ; <i1> [#uses=1]
27 %indvar.next = add i32 %indvar, 1 ; <i32> [#uses=1]
28 br i1 %2, label %bb1.bb2_crit_edge, label %bb
30 bb1.bb2_crit_edge: ; preds = %bb1
31 %.lcssa = phi i32 [ %1, %bb1 ] ; <i32> [#uses=1]
34 bb2: ; preds = %bb1.bb2_crit_edge, %entry
35 %x_addr.0.lcssa = phi i32 [ %.lcssa, %bb1.bb2_crit_edge ], [ %x, %entry ] ; <i32> [#uses=1]
36 ret i32 %x_addr.0.lcssa