2 ; RUN: opt < %s -indvars -loop-deletion -S | FileCheck %s
4 ; Check IndVarSimplify should not replace exit value because or else
5 ; udiv will be introduced by expand and the cost will be high.
7 ; CHECK-LABEL: @_Z3fooPKcjj(
10 declare void @_Z3mixRjj(i32* dereferenceable(4), i32)
11 declare void @llvm.lifetime.start(i64, i8* nocapture)
12 declare void @llvm.lifetime.end(i64, i8* nocapture)
14 define i32 @_Z3fooPKcjj(i8* nocapture readonly %s, i32 %len, i32 %c) {
16 %a = alloca i32, align 4
17 %tmp = bitcast i32* %a to i8*
18 call void @llvm.lifetime.start(i64 4, i8* %tmp)
19 store i32 -1640531527, i32* %a, align 4
20 %cmp8 = icmp ugt i32 %len, 11
21 br i1 %cmp8, label %while.body.lr.ph, label %while.end
23 while.body.lr.ph: ; preds = %entry
26 while.body: ; preds = %while.body, %while.body.lr.ph
27 %keylen.010 = phi i32 [ %len, %while.body.lr.ph ], [ %sub, %while.body ]
28 %s.addr.09 = phi i8* [ %s, %while.body.lr.ph ], [ %add.ptr, %while.body ]
29 %tmp1 = bitcast i8* %s.addr.09 to i32*
30 %tmp2 = load i32, i32* %tmp1, align 4
31 %shl.i = shl i32 %tmp2, 1
32 %and.i = and i32 %shl.i, 16843008
33 %tmp3 = load i32, i32* %a, align 4
34 %sub.i = add i32 %tmp3, %tmp2
35 %add = sub i32 %sub.i, %and.i
36 store i32 %add, i32* %a, align 4
37 %add.ptr = getelementptr inbounds i8, i8* %s.addr.09, i64 12
38 %sub = add i32 %keylen.010, -12
39 %cmp = icmp ugt i32 %sub, 11
40 br i1 %cmp, label %while.body, label %while.cond.while.end_crit_edge
42 while.cond.while.end_crit_edge: ; preds = %while.body
43 %sub.lcssa = phi i32 [ %sub, %while.body ]
46 while.end: ; preds = %while.cond.while.end_crit_edge, %entry
47 %keylen.0.lcssa = phi i32 [ %sub.lcssa, %while.cond.while.end_crit_edge ], [ %len, %entry ]
48 call void @_Z3mixRjj(i32* dereferenceable(4) %a, i32 %keylen.0.lcssa)
49 %tmp4 = load i32, i32* %a, align 4
50 call void @llvm.lifetime.end(i64 4, i8* %tmp)