1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt -passes='loop-unroll-and-jam' < %s -mcpu=cortex-a55 -mtriple=aarch64-none-linux-eabi -S | FileCheck %s
4 target datalayout = "e-m:e-p:32:32-i64:64-v128:64:128-a:0:32-n32-S64"
6 define void @unj(i32 %I, i32 %argj, ptr noalias nocapture %A, ptr noalias nocapture readonly %B) #0 {
9 ; CHECK-NEXT: [[CMP:%.*]] = icmp eq i32 [[ARGJ:%.*]], 0
10 ; CHECK-NEXT: br i1 [[CMP]], label [[FOR_END:%.*]], label [[FOR_PREHEADER:%.*]]
11 ; CHECK: for.preheader:
12 ; CHECK-NEXT: br label [[FOR_OUTER:%.*]]
14 ; CHECK-NEXT: br label [[FOR_INNER:%.*]]
16 ; CHECK-NEXT: [[J:%.*]] = phi i32 [ 0, [[FOR_OUTER]] ], [ [[INC:%.*]], [[FOR_INNER]] ]
17 ; CHECK-NEXT: [[SUM:%.*]] = phi i32 [ 0, [[FOR_OUTER]] ], [ [[ADD:%.*]], [[FOR_INNER]] ]
18 ; CHECK-NEXT: [[J_1:%.*]] = phi i32 [ 0, [[FOR_OUTER]] ], [ [[INC_1:%.*]], [[FOR_INNER]] ]
19 ; CHECK-NEXT: [[SUM_1:%.*]] = phi i32 [ 0, [[FOR_OUTER]] ], [ [[ADD_1:%.*]], [[FOR_INNER]] ]
20 ; CHECK-NEXT: [[J_2:%.*]] = phi i32 [ 0, [[FOR_OUTER]] ], [ [[INC_2:%.*]], [[FOR_INNER]] ]
21 ; CHECK-NEXT: [[SUM_2:%.*]] = phi i32 [ 0, [[FOR_OUTER]] ], [ [[ADD_2:%.*]], [[FOR_INNER]] ]
22 ; CHECK-NEXT: [[J_3:%.*]] = phi i32 [ 0, [[FOR_OUTER]] ], [ [[INC_3:%.*]], [[FOR_INNER]] ]
23 ; CHECK-NEXT: [[SUM_3:%.*]] = phi i32 [ 0, [[FOR_OUTER]] ], [ [[ADD_3:%.*]], [[FOR_INNER]] ]
24 ; CHECK-NEXT: [[ARRAYIDX:%.*]] = getelementptr inbounds i32, ptr [[B:%.*]], i32 [[J]]
25 ; CHECK-NEXT: [[TMP0:%.*]] = load i32, ptr [[ARRAYIDX]], align 4
26 ; CHECK-NEXT: [[SUB:%.*]] = add i32 [[SUM]], 10
27 ; CHECK-NEXT: [[ADD]] = sub i32 [[SUB]], [[TMP0]]
28 ; CHECK-NEXT: [[INC]] = add nuw i32 [[J]], 1
29 ; CHECK-NEXT: [[ARRAYIDX_1:%.*]] = getelementptr inbounds i32, ptr [[B]], i32 [[J_1]]
30 ; CHECK-NEXT: [[TMP1:%.*]] = load i32, ptr [[ARRAYIDX_1]], align 4
31 ; CHECK-NEXT: [[SUB_1:%.*]] = add i32 [[SUM_1]], 10
32 ; CHECK-NEXT: [[ADD_1]] = sub i32 [[SUB_1]], [[TMP1]]
33 ; CHECK-NEXT: [[INC_1]] = add nuw i32 [[J_1]], 1
34 ; CHECK-NEXT: [[ARRAYIDX_2:%.*]] = getelementptr inbounds i32, ptr [[B]], i32 [[J_2]]
35 ; CHECK-NEXT: [[TMP2:%.*]] = load i32, ptr [[ARRAYIDX_2]], align 4
36 ; CHECK-NEXT: [[SUB_2:%.*]] = add i32 [[SUM_2]], 10
37 ; CHECK-NEXT: [[ADD_2]] = sub i32 [[SUB_2]], [[TMP2]]
38 ; CHECK-NEXT: [[INC_2]] = add nuw i32 [[J_2]], 1
39 ; CHECK-NEXT: [[ARRAYIDX_3:%.*]] = getelementptr inbounds i32, ptr [[B]], i32 [[J_3]]
40 ; CHECK-NEXT: [[TMP3:%.*]] = load i32, ptr [[ARRAYIDX_3]], align 4
41 ; CHECK-NEXT: [[SUB_3:%.*]] = add i32 [[SUM_3]], 10
42 ; CHECK-NEXT: [[ADD_3]] = sub i32 [[SUB_3]], [[TMP3]]
43 ; CHECK-NEXT: [[INC_3]] = add nuw i32 [[J_3]], 1
44 ; CHECK-NEXT: [[EXITCOND_3:%.*]] = icmp eq i32 [[INC_3]], [[ARGJ]]
45 ; CHECK-NEXT: br i1 [[EXITCOND_3]], label [[FOR_LATCH:%.*]], label [[FOR_INNER]]
47 ; CHECK-NEXT: [[ADD_LCSSA:%.*]] = phi i32 [ [[ADD]], [[FOR_INNER]] ]
48 ; CHECK-NEXT: [[ADD_LCSSA_1:%.*]] = phi i32 [ [[ADD_1]], [[FOR_INNER]] ]
49 ; CHECK-NEXT: [[ADD_LCSSA_2:%.*]] = phi i32 [ [[ADD_2]], [[FOR_INNER]] ]
50 ; CHECK-NEXT: [[ADD_LCSSA_3:%.*]] = phi i32 [ [[ADD_3]], [[FOR_INNER]] ]
51 ; CHECK-NEXT: store i32 [[ADD_LCSSA]], ptr [[A:%.*]], align 4
52 ; CHECK-NEXT: [[ARRAYIDX6_1:%.*]] = getelementptr inbounds i32, ptr [[A]], i32 1
53 ; CHECK-NEXT: store i32 [[ADD_LCSSA_1]], ptr [[ARRAYIDX6_1]], align 4
54 ; CHECK-NEXT: [[ARRAYIDX6_2:%.*]] = getelementptr inbounds i32, ptr [[A]], i32 2
55 ; CHECK-NEXT: store i32 [[ADD_LCSSA_2]], ptr [[ARRAYIDX6_2]], align 4
56 ; CHECK-NEXT: [[ARRAYIDX6_3:%.*]] = getelementptr inbounds i32, ptr [[A]], i32 3
57 ; CHECK-NEXT: store i32 [[ADD_LCSSA_3]], ptr [[ARRAYIDX6_3]], align 4
58 ; CHECK-NEXT: br label [[FOR_END_LOOPEXIT:%.*]]
59 ; CHECK: for.end.loopexit:
60 ; CHECK-NEXT: br label [[FOR_END]]
62 ; CHECK-NEXT: ret void
65 %cmp = icmp eq i32 %argj, 0
66 br i1 %cmp, label %for.end, label %for.preheader
72 %i = phi i32 [ %add8, %for.latch ], [ 0, %for.preheader ]
76 %j = phi i32 [ 0, %for.outer ], [ %inc, %for.inner ]
77 %sum = phi i32 [ 0, %for.outer ], [ %add, %for.inner ]
78 %arrayidx = getelementptr inbounds i32, ptr %B, i32 %j
79 %0 = load i32, ptr %arrayidx, align 4
80 %sub = add i32 %sum, 10
81 %add = sub i32 %sub, %0
82 %inc = add nuw i32 %j, 1
83 %exitcond = icmp eq i32 %inc, %argj
84 br i1 %exitcond, label %for.latch, label %for.inner
87 %arrayidx6 = getelementptr inbounds i32, ptr %A, i32 %i
88 store i32 %add, ptr %arrayidx6, align 4
89 %add8 = add nuw nsw i32 %i, 1
90 %exitcond23 = icmp eq i32 %add8, 4
91 br i1 %exitcond23, label %for.end, label %for.outer