1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt -passes=indvars -S %s | FileCheck %s
4 %struct.A = type { i8 }
9 define void @_Z3fn1v() {
10 ; CHECK-LABEL: @_Z3fn1v(
11 ; CHECK-NEXT: [[X2:%.*]] = load i32, ptr @d, align 4
12 ; CHECK-NEXT: [[X3:%.*]] = icmp slt i32 [[X2]], 1
13 ; CHECK-NEXT: [[X4:%.*]] = select i1 [[X3]], i32 1, i32 [[X2]]
14 ; CHECK-NEXT: [[X5:%.*]] = load ptr, ptr @c, align 8
15 ; CHECK-NEXT: [[J_SROA_0_0_COPYLOAD:%.*]] = load i8, ptr [[X5]], align 1
16 ; CHECK-NEXT: br label [[DOTPREHEADER4_LR_PH:%.*]]
17 ; CHECK: .preheader4.lr.ph:
18 ; CHECK-NEXT: [[TMP1:%.*]] = add nsw i32 [[X4]], -1
19 ; CHECK-NEXT: [[TMP2:%.*]] = zext nneg i32 [[TMP1]] to i64
20 ; CHECK-NEXT: [[TMP3:%.*]] = add nuw nsw i64 [[TMP2]], 1
21 ; CHECK-NEXT: [[TMP4:%.*]] = sext i8 [[J_SROA_0_0_COPYLOAD]] to i64
22 ; CHECK-NEXT: [[TMP5:%.*]] = mul i64 [[TMP3]], [[TMP4]]
23 ; CHECK-NEXT: br label [[DOTPREHEADER4:%.*]]
25 ; CHECK-NEXT: [[K_09:%.*]] = phi ptr [ undef, [[DOTPREHEADER4_LR_PH]] ], [ [[X25:%.*]], [[X22:%.*]] ]
26 ; CHECK-NEXT: [[X8:%.*]] = icmp ult i32 0, 4
27 ; CHECK-NEXT: br i1 [[X8]], label [[DOTPREHEADER_LR_PH:%.*]], label [[X22]]
28 ; CHECK: .preheader.lr.ph:
29 ; CHECK-NEXT: br label [[DOTPREHEADER:%.*]]
31 ; CHECK-NEXT: br label [[X17:%.*]]
33 ; CHECK-NEXT: br i1 false, label [[DOTPREHEADER]], label [[DOT_CRIT_EDGE_8:%.*]]
34 ; CHECK: ._crit_edge.8:
35 ; CHECK-NEXT: [[SCEVGEP:%.*]] = getelementptr i8, ptr [[K_09]], i64 [[TMP5]]
36 ; CHECK-NEXT: br label [[X22]]
38 ; CHECK-NEXT: [[K_1_LCSSA:%.*]] = phi ptr [ [[SCEVGEP]], [[DOT_CRIT_EDGE_8]] ], [ [[K_09]], [[DOTPREHEADER4]] ]
39 ; CHECK-NEXT: [[X25]] = getelementptr i8, ptr [[K_1_LCSSA]]
40 ; CHECK-NEXT: br label [[DOTPREHEADER4]]
42 %x2 = load i32, ptr @d
43 %x3 = icmp slt i32 %x2, 1
44 %x4 = select i1 %x3, i32 1, i32 %x2
45 %x5 = load ptr, ptr @c
46 %j.sroa.0.0.copyload = load i8, ptr %x5
47 br label %.preheader4.lr.ph
49 .preheader4.lr.ph: ; preds = %0
52 .preheader4: ; preds = %x22, %.preheader4.lr.ph
53 %k.09 = phi ptr [ undef, %.preheader4.lr.ph ], [ %x25, %x22 ]
54 %x8 = icmp ult i32 0, 4
55 br i1 %x8, label %.preheader.lr.ph, label %x22
57 .preheader.lr.ph: ; preds = %.preheader4
60 .preheader: ; preds = %x17, %.preheader.lr.ph
61 %k.17 = phi ptr [ %k.09, %.preheader.lr.ph ], [ %x19, %x17 ]
62 %v.06 = phi i32 [ 0, %.preheader.lr.ph ], [ %x20, %x17 ]
65 x17: ; preds = %.preheader
66 %x18 = sext i8 %j.sroa.0.0.copyload to i64
67 %x19 = getelementptr i8, ptr %k.17, i64 %x18
68 %x20 = add i32 %v.06, 1
69 %x21 = icmp ult i32 %x20, %x4
70 br i1 %x21, label %.preheader, label %._crit_edge.8
72 ._crit_edge.8: ; preds = %x17
73 %split = phi ptr [ %x19, %x17 ]
76 x22: ; preds = %._crit_edge.8, %.preheader4
77 %k.1.lcssa = phi ptr [ %split, %._crit_edge.8 ], [ %k.09, %.preheader4 ]
78 %x25 = getelementptr i8, ptr %k.1.lcssa