1; RUN: llc -march=hexagon -mcpu=hexagonv5 < %s | FileCheck %s 2; 3; Remove the unnecessary 'add' instruction used for the hardware loop setup. 4 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]+}}) 8; CHECK: loop0 9 10define void @matrix_mul_matrix(i32 %N, i32* nocapture %C, i16* nocapture readnone %A, i16* nocapture readnone %B) #0 { 11entry: 12 %cmp4 = icmp eq i32 %N, 0 13 br i1 %cmp4, label %for.end, label %for.body.preheader 14 15for.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 19 20for.body.preheader9: 21 br label %for.body 22 23for.body: 24 %arrayidx.phi = phi i32* [ %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, i32* %arrayidx.phi, align 4 27 %inc = add i32 %i.05, 1 28 %arrayidx.inc = getelementptr i32, i32* %arrayidx.phi, i32 1 29 store i32 %inc, i32* %arrayidx.inc, align 4 30 %inc.1 = add i32 %i.05, 2 31 %arrayidx.inc.1 = getelementptr i32, i32* %arrayidx.phi, i32 2 32 store i32 %inc.1, i32* %arrayidx.inc.1, align 4 33 %inc.2 = add i32 %i.05, 3 34 %arrayidx.inc.2 = getelementptr i32, i32* %arrayidx.phi, i32 3 35 store i32 %inc.2, i32* %arrayidx.inc.2, align 4 36 %inc.3 = add i32 %i.05, 4 37 %arrayidx.inc.3 = getelementptr i32, i32* %arrayidx.phi, i32 4 38 store i32 %inc.3, i32* %arrayidx.inc.3, align 4 39 %inc.4 = add i32 %i.05, 5 40 %arrayidx.inc.4 = getelementptr i32, i32* %arrayidx.phi, i32 5 41 store i32 %inc.4, i32* %arrayidx.inc.4, align 4 42 %inc.5 = add i32 %i.05, 6 43 %arrayidx.inc.5 = getelementptr i32, i32* %arrayidx.phi, i32 6 44 store i32 %inc.5, i32* %arrayidx.inc.5, align 4 45 %inc.6 = add i32 %i.05, 7 46 %arrayidx.inc.6 = getelementptr i32, i32* %arrayidx.phi, i32 7 47 store i32 %inc.6, i32* %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, i32* %arrayidx.phi, i32 8 51 br i1 %exitcond.7, label %for.body, label %for.end.loopexit.ur-lcssa 52 53for.end.loopexit.ur-lcssa: 54 %1 = icmp eq i32 %inc.7, %N 55 br i1 %1, label %for.end, label %for.body.ur.preheader 56 57for.body.ur.preheader: 58 %arrayidx.phi.ur.ph = phi i32* [ %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 ] 60 br label %for.body.ur 61 62for.body.ur: 63 %arrayidx.phi.ur = phi i32* [ %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, i32* %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, i32* %arrayidx.phi.ur, i32 1 69 br i1 %exitcond.ur, label %for.end.loopexit, label %for.body.ur 70 71for.end.loopexit: 72 br label %for.end 73 74for.end: 75 ret void 76} 77