1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
3 ; RUN: opt < %s -passes=indvars -S | FileCheck %s
5 ; Check IndVarSimplify doesn't replace external use of the induction var
6 ; "%inc.i.i" with "%.sroa.speculated + 1" because it is not profitable.
9 define void @foo(i32 %sub.ptr.div.i, ptr %ref.i1174) local_unnamed_addr {
12 ; CHECK-NEXT: [[CMP_I1137:%.*]] = icmp ugt i32 [[SUB_PTR_DIV_I:%.*]], 3
13 ; CHECK-NEXT: [[DOTSROA_SPECULATED:%.*]] = select i1 [[CMP_I1137]], i32 3, i32 [[SUB_PTR_DIV_I]]
14 ; CHECK-NEXT: [[CMP6483126:%.*]] = icmp eq i32 [[DOTSROA_SPECULATED]], 0
15 ; CHECK-NEXT: br i1 [[CMP6483126]], label [[XZ_EXIT:%.*]], label [[FOR_BODY650_LR_PH:%.*]]
16 ; CHECK: for.body650.lr.ph:
17 ; CHECK-NEXT: br label [[FOR_BODY650:%.*]]
19 ; CHECK-NEXT: [[INC_I_I_LCSSA:%.*]] = phi i32 [ [[INC_I_I:%.*]], [[FOR_BODY650]] ]
20 ; CHECK-NEXT: br label [[XZ_EXIT]]
22 ; CHECK-NEXT: [[DB_SROA_9_0_LCSSA:%.*]] = phi i32 [ 1, [[ENTRY:%.*]] ], [ [[INC_I_I_LCSSA]], [[LOOPEXIT:%.*]] ]
23 ; CHECK-NEXT: br label [[END:%.*]]
25 ; CHECK-NEXT: [[IV:%.*]] = phi i32 [ 0, [[FOR_BODY650_LR_PH]] ], [ [[INC655:%.*]], [[FOR_BODY650]] ]
26 ; CHECK-NEXT: [[IV2:%.*]] = phi i32 [ 1, [[FOR_BODY650_LR_PH]] ], [ [[INC_I_I]], [[FOR_BODY650]] ]
27 ; CHECK-NEXT: [[ARRAYIDX_I_I1105:%.*]] = getelementptr inbounds i8, ptr [[REF_I1174:%.*]], i32 [[IV2]]
28 ; CHECK-NEXT: store i8 7, ptr [[ARRAYIDX_I_I1105]], align 1
29 ; CHECK-NEXT: [[INC_I_I]] = add nuw nsw i32 [[IV2]], 1
30 ; CHECK-NEXT: [[INC655]] = add nuw nsw i32 [[IV]], 1
31 ; CHECK-NEXT: [[CMP648:%.*]] = icmp eq i32 [[INC655]], [[DOTSROA_SPECULATED]]
32 ; CHECK-NEXT: br i1 [[CMP648]], label [[LOOPEXIT]], label [[FOR_BODY650]]
34 ; CHECK-NEXT: ret void
37 %cmp.i1137 = icmp ugt i32 %sub.ptr.div.i, 3
38 %.sroa.speculated = select i1 %cmp.i1137, i32 3, i32 %sub.ptr.div.i
39 %cmp6483126 = icmp eq i32 %.sroa.speculated, 0
40 br i1 %cmp6483126, label %XZ.exit, label %for.body650.lr.ph
46 %inc.i.i.lcssa = phi i32 [ %inc.i.i, %for.body650 ]
50 %DB.sroa.9.0.lcssa = phi i32 [ 1, %entry ], [ %inc.i.i.lcssa, %loopexit ]
54 %iv = phi i32 [ 0, %for.body650.lr.ph ], [ %inc655, %for.body650 ]
55 %iv2 = phi i32 [ 1, %for.body650.lr.ph ], [ %inc.i.i, %for.body650 ]
56 %arrayidx.i.i1105 = getelementptr inbounds i8, ptr %ref.i1174, i32 %iv2
57 store i8 7, ptr %arrayidx.i.i1105, align 1
58 %inc.i.i = add i32 %iv2, 1
59 %inc655 = add i32 %iv, 1
60 %cmp648 = icmp eq i32 %inc655, %.sroa.speculated
61 br i1 %cmp648, label %loopexit, label %for.body650