1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt -passes=loop-bound-split -S < %s | FileCheck %s
4 @B = external global [10 x i16], align 1
9 ; CHECK-NEXT: br label [[ENTRY_SPLIT:%.*]]
11 ; CHECK-NEXT: br label [[FOR_COND:%.*]]
13 ; CHECK-NEXT: [[I_0:%.*]] = phi i16 [ 0, [[ENTRY_SPLIT]] ], [ [[INC_0:%.*]], [[FOR_INC:%.*]] ]
14 ; CHECK-NEXT: [[I_1:%.*]] = phi i16 [ 10, [[ENTRY_SPLIT]] ], [ [[INC_0]], [[FOR_INC]] ]
15 ; CHECK-NEXT: [[I_2:%.*]] = phi i16 [ 10, [[ENTRY_SPLIT]] ], [ [[INC_2:%.*]], [[FOR_INC]] ]
16 ; CHECK-NEXT: [[I_3:%.*]] = phi i16 [ 15, [[ENTRY_SPLIT]] ], [ 30, [[FOR_INC]] ]
17 ; CHECK-NEXT: [[EXITCOND_NOT:%.*]] = icmp eq i16 [[I_0]], 5
18 ; CHECK-NEXT: br i1 [[EXITCOND_NOT]], label [[ENTRY_SPLIT_SPLIT:%.*]], label [[FOR_BODY:%.*]]
20 ; CHECK-NEXT: [[CMP1:%.*]] = icmp ult i16 [[I_0]], 5
21 ; CHECK-NEXT: [[ARRAYIDX:%.*]] = getelementptr inbounds [10 x i16], ptr @B, i16 0, i16 [[I_0]]
22 ; CHECK-NEXT: [[TMP0:%.*]] = load i16, ptr [[ARRAYIDX]], align 1
23 ; CHECK-NEXT: br i1 true, label [[IF_THEN:%.*]], label [[IF_ELSE:%.*]]
25 ; CHECK-NEXT: call void @foo(i16 [[TMP0]], i16 [[I_3]])
26 ; CHECK-NEXT: br label [[FOR_INC]]
28 ; CHECK-NEXT: call void @bar(i16 [[TMP0]], i16 [[I_3]])
29 ; CHECK-NEXT: br label [[FOR_INC]]
31 ; CHECK-NEXT: [[INC_0]] = add nuw nsw i16 [[I_0]], 1
32 ; CHECK-NEXT: [[INC_2]] = add nuw nsw i16 [[I_2]], 2
33 ; CHECK-NEXT: br label [[FOR_COND]]
34 ; CHECK: entry.split.split:
35 ; CHECK-NEXT: [[I_0_LCSSA:%.*]] = phi i16 [ [[I_0]], [[FOR_COND]] ]
36 ; CHECK-NEXT: [[I_1_LCSSA:%.*]] = phi i16 [ [[I_1]], [[FOR_COND]] ]
37 ; CHECK-NEXT: [[I_2_LCSSA:%.*]] = phi i16 [ [[I_2]], [[FOR_COND]] ]
38 ; CHECK-NEXT: [[I_3_LCSSA:%.*]] = phi i16 [ [[I_3]], [[FOR_COND]] ]
39 ; CHECK-NEXT: [[TMP1:%.*]] = icmp ne i16 [[I_0_LCSSA]], 10
40 ; CHECK-NEXT: br i1 [[TMP1]], label [[FOR_COND_SPLIT_PREHEADER:%.*]], label [[FOR_END:%.*]]
41 ; CHECK: for.cond.split.preheader:
42 ; CHECK-NEXT: br label [[FOR_COND_SPLIT:%.*]]
43 ; CHECK: for.cond.split:
44 ; CHECK-NEXT: [[I_0_SPLIT:%.*]] = phi i16 [ [[INC_0_SPLIT:%.*]], [[FOR_INC_SPLIT:%.*]] ], [ [[I_0_LCSSA]], [[FOR_COND_SPLIT_PREHEADER]] ]
45 ; CHECK-NEXT: [[I_1_SPLIT:%.*]] = phi i16 [ [[INC_0_SPLIT]], [[FOR_INC_SPLIT]] ], [ [[I_1_LCSSA]], [[FOR_COND_SPLIT_PREHEADER]] ]
46 ; CHECK-NEXT: [[I_2_SPLIT:%.*]] = phi i16 [ [[INC_2_SPLIT:%.*]], [[FOR_INC_SPLIT]] ], [ [[I_2_LCSSA]], [[FOR_COND_SPLIT_PREHEADER]] ]
47 ; CHECK-NEXT: [[I_3_SPLIT:%.*]] = phi i16 [ 30, [[FOR_INC_SPLIT]] ], [ [[I_3_LCSSA]], [[FOR_COND_SPLIT_PREHEADER]] ]
48 ; CHECK-NEXT: [[EXITCOND_NOT_SPLIT:%.*]] = icmp eq i16 [[I_0_SPLIT]], 10
49 ; CHECK-NEXT: br i1 [[EXITCOND_NOT_SPLIT]], label [[FOR_END_LOOPEXIT:%.*]], label [[FOR_BODY_SPLIT:%.*]]
50 ; CHECK: for.body.split:
51 ; CHECK-NEXT: [[CMP1_SPLIT:%.*]] = icmp ult i16 [[I_0_SPLIT]], 5
52 ; CHECK-NEXT: [[ARRAYIDX_SPLIT:%.*]] = getelementptr inbounds [10 x i16], ptr @B, i16 0, i16 [[I_0_SPLIT]]
53 ; CHECK-NEXT: [[TMP2:%.*]] = load i16, ptr [[ARRAYIDX_SPLIT]], align 1
54 ; CHECK-NEXT: br i1 false, label [[IF_THEN_SPLIT:%.*]], label [[IF_ELSE_SPLIT:%.*]]
55 ; CHECK: if.else.split:
56 ; CHECK-NEXT: call void @bar(i16 [[TMP2]], i16 [[I_3_SPLIT]])
57 ; CHECK-NEXT: br label [[FOR_INC_SPLIT]]
58 ; CHECK: if.then.split:
59 ; CHECK-NEXT: call void @foo(i16 [[TMP2]], i16 [[I_3_SPLIT]])
60 ; CHECK-NEXT: br label [[FOR_INC_SPLIT]]
61 ; CHECK: for.inc.split:
62 ; CHECK-NEXT: [[INC_0_SPLIT]] = add nuw nsw i16 [[I_0_SPLIT]], 1
63 ; CHECK-NEXT: [[INC_2_SPLIT]] = add nuw nsw i16 [[I_2_SPLIT]], 2
64 ; CHECK-NEXT: br label [[FOR_COND_SPLIT]]
65 ; CHECK: for.end.loopexit:
66 ; CHECK-NEXT: br label [[FOR_END]]
68 ; CHECK-NEXT: ret void
73 for.cond: ; preds = %for.inc, %entry
74 %i.0 = phi i16 [ 0, %entry ], [ %inc.0, %for.inc ]
75 %i.1 = phi i16 [ 10, %entry ], [ %inc.0, %for.inc ]
76 %i.2 = phi i16 [ 10, %entry ], [ %inc.2, %for.inc ]
77 %i.3 = phi i16 [ 15, %entry ], [ 30, %for.inc ]
78 %exitcond.not = icmp eq i16 %i.0, 10
79 br i1 %exitcond.not, label %for.end, label %for.body
81 for.body: ; preds = %for.cond
82 %cmp1 = icmp ult i16 %i.0, 5
83 %arrayidx = getelementptr inbounds [10 x i16], ptr @B, i16 0, i16 %i.0
84 %0 = load i16, ptr %arrayidx, align 1
85 br i1 %cmp1, label %if.then, label %if.else
87 if.then: ; preds = %for.body
88 call void @foo(i16 %0, i16 %i.3)
91 if.else: ; preds = %for.body
92 call void @bar(i16 %0, i16 %i.3)
95 for.inc: ; preds = %if.else, %if.then
96 %inc.0 = add nuw nsw i16 %i.0, 1
97 %inc.2 = add nuw nsw i16 %i.2, 2
100 for.end: ; preds = %for.cond
104 declare void @foo(i16, i16)
105 declare void @bar(i16, i16)