2 ; RUN: opt < %s -indvars -S | FileCheck %s
4 ; Check IndVarSimplify doesn't replace external use of the induction var
5 ; "%inc.i.i" with "%.sroa.speculated + 1" because it is not profitable.
8 ; CHECK: %[[EXIT:.+]] = phi i32 [ %inc.i.i, %for.body650 ]
9 ; CHECK: %DB.sroa.9.0.lcssa = phi i32 [ 1, %entry ], [ %[[EXIT]], %loopexit ]
11 define void @foo(i32 %sub.ptr.div.i, i8* %ref.i1174) local_unnamed_addr {
13 %cmp.i1137 = icmp ugt i32 %sub.ptr.div.i, 3
14 %.sroa.speculated = select i1 %cmp.i1137, i32 3, i32 %sub.ptr.div.i
15 %cmp6483126 = icmp eq i32 %.sroa.speculated, 0
16 br i1 %cmp6483126, label %XZ.exit, label %for.body650.lr.ph
22 %inc.i.i.lcssa = phi i32 [ %inc.i.i, %for.body650 ]
26 %DB.sroa.9.0.lcssa = phi i32 [ 1, %entry ], [ %inc.i.i.lcssa, %loopexit ]
30 %iv = phi i32 [ 0, %for.body650.lr.ph ], [ %inc655, %for.body650 ]
31 %iv2 = phi i32 [ 1, %for.body650.lr.ph ], [ %inc.i.i, %for.body650 ]
32 %arrayidx.i.i1105 = getelementptr inbounds i8, i8* %ref.i1174, i32 %iv2
33 store i8 7, i8* %arrayidx.i.i1105, align 1
34 %inc.i.i = add i32 %iv2, 1
35 %inc655 = add i32 %iv, 1
36 %cmp648 = icmp eq i32 %inc655, %.sroa.speculated
37 br i1 %cmp648, label %loopexit, label %for.body650