1 ; RUN: llc -march=hexagon -mcpu=hexagonv5 < %s | FileCheck %s
3 ; Remove the unnecessary 'add' instruction used for the hardware loop setup.
5 ; CHECK: [[OP0:r[0-9]+]] = add([[OP1:r[0-9]+]],#-[[OP2:[0-9]+]]
6 ; CHECK-NOT: add([[OP0]],#[[OP2]])
7 ; CHECK: lsr([[OP1]],#{{[0-9]+}})
10 define void @matrix_mul_matrix(i32 %N, ptr nocapture %C, ptr nocapture readnone %A, ptr nocapture readnone %B) #0 {
12 %cmp4 = icmp eq i32 %N, 0
13 br i1 %cmp4, label %for.end, label %for.body.preheader
16 %maxval = add i32 %N, -7
17 %0 = icmp sgt i32 %maxval, 0
18 br i1 %0, label %for.body.preheader9, label %for.body.ur.preheader
24 %arrayidx.phi = phi ptr [ %arrayidx.inc.7, %for.body ], [ %C, %for.body.preheader9 ]
25 %i.05 = phi i32 [ %inc.7, %for.body ], [ 0, %for.body.preheader9 ]
26 store i32 %i.05, ptr %arrayidx.phi, align 4
27 %inc = add i32 %i.05, 1
28 %arrayidx.inc = getelementptr i32, ptr %arrayidx.phi, i32 1
29 store i32 %inc, ptr %arrayidx.inc, align 4
30 %inc.1 = add i32 %i.05, 2
31 %arrayidx.inc.1 = getelementptr i32, ptr %arrayidx.phi, i32 2
32 store i32 %inc.1, ptr %arrayidx.inc.1, align 4
33 %inc.2 = add i32 %i.05, 3
34 %arrayidx.inc.2 = getelementptr i32, ptr %arrayidx.phi, i32 3
35 store i32 %inc.2, ptr %arrayidx.inc.2, align 4
36 %inc.3 = add i32 %i.05, 4
37 %arrayidx.inc.3 = getelementptr i32, ptr %arrayidx.phi, i32 4
38 store i32 %inc.3, ptr %arrayidx.inc.3, align 4
39 %inc.4 = add i32 %i.05, 5
40 %arrayidx.inc.4 = getelementptr i32, ptr %arrayidx.phi, i32 5
41 store i32 %inc.4, ptr %arrayidx.inc.4, align 4
42 %inc.5 = add i32 %i.05, 6
43 %arrayidx.inc.5 = getelementptr i32, ptr %arrayidx.phi, i32 6
44 store i32 %inc.5, ptr %arrayidx.inc.5, align 4
45 %inc.6 = add i32 %i.05, 7
46 %arrayidx.inc.6 = getelementptr i32, ptr %arrayidx.phi, i32 7
47 store i32 %inc.6, ptr %arrayidx.inc.6, align 4
48 %inc.7 = add i32 %i.05, 8
49 %exitcond.7 = icmp slt i32 %inc.7, %maxval
50 %arrayidx.inc.7 = getelementptr i32, ptr %arrayidx.phi, i32 8
51 br i1 %exitcond.7, label %for.body, label %for.end.loopexit.ur-lcssa
53 for.end.loopexit.ur-lcssa:
54 %1 = icmp eq i32 %inc.7, %N
55 br i1 %1, label %for.end, label %for.body.ur.preheader
57 for.body.ur.preheader:
58 %arrayidx.phi.ur.ph = phi ptr [ %C, %for.body.preheader ], [ %arrayidx.inc.7, %for.end.loopexit.ur-lcssa ]
59 %i.05.ur.ph = phi i32 [ 0, %for.body.preheader ], [ %inc.7, %for.end.loopexit.ur-lcssa ]
63 %arrayidx.phi.ur = phi ptr [ %arrayidx.inc.ur, %for.body.ur ], [ %arrayidx.phi.ur.ph, %for.body.ur.preheader ]
64 %i.05.ur = phi i32 [ %inc.ur, %for.body.ur ], [ %i.05.ur.ph, %for.body.ur.preheader ]
65 store i32 %i.05.ur, ptr %arrayidx.phi.ur, align 4
66 %inc.ur = add i32 %i.05.ur, 1
67 %exitcond.ur = icmp eq i32 %inc.ur, %N
68 %arrayidx.inc.ur = getelementptr i32, ptr %arrayidx.phi.ur, i32 1
69 br i1 %exitcond.ur, label %for.end.loopexit, label %for.body.ur