1*9880d681SAndroid Build Coastguard Worker; RUN: llc -march=hexagon -hexagon-hwloop-preheader < %s | FileCheck %s 2*9880d681SAndroid Build Coastguard Worker 3*9880d681SAndroid Build Coastguard Worker; Generate hardware loops when we also need to add a new preheader. 4*9880d681SAndroid Build Coastguard Worker; we should generate two hardware loops for this test case. 5*9880d681SAndroid Build Coastguard Worker 6*9880d681SAndroid Build Coastguard Worker; CHECK: loop0 7*9880d681SAndroid Build Coastguard Worker; CHECK: endloop0 8*9880d681SAndroid Build Coastguard Worker; CHECK: loop0 9*9880d681SAndroid Build Coastguard Worker; CHECK: endloop0 10*9880d681SAndroid Build Coastguard Worker 11*9880d681SAndroid Build Coastguard Worker@g = external global i32 12*9880d681SAndroid Build Coastguard Worker 13*9880d681SAndroid Build Coastguard Workerdefine void @test(i32* nocapture %a, i32* nocapture %b, i32 %n) nounwind { 14*9880d681SAndroid Build Coastguard Workerentry: 15*9880d681SAndroid Build Coastguard Worker %tobool = icmp eq i32 %n, 0 16*9880d681SAndroid Build Coastguard Worker br i1 %tobool, label %for.body4.preheader, label %for.body.preheader 17*9880d681SAndroid Build Coastguard Worker 18*9880d681SAndroid Build Coastguard Workerfor.body.preheader: 19*9880d681SAndroid Build Coastguard Worker br label %for.body 20*9880d681SAndroid Build Coastguard Worker 21*9880d681SAndroid Build Coastguard Workerfor.body: 22*9880d681SAndroid Build Coastguard Worker %arrayidx.phi = phi i32* [ %arrayidx.inc, %for.body ], [ %a, %for.body.preheader ] 23*9880d681SAndroid Build Coastguard Worker %i.014 = phi i32 [ %inc, %for.body ], [ 0, %for.body.preheader ] 24*9880d681SAndroid Build Coastguard Worker %0 = load i32, i32* @g, align 4 25*9880d681SAndroid Build Coastguard Worker store i32 %0, i32* %arrayidx.phi, align 4 26*9880d681SAndroid Build Coastguard Worker %inc = add nsw i32 %i.014, 1 27*9880d681SAndroid Build Coastguard Worker %exitcond15 = icmp eq i32 %inc, 3 28*9880d681SAndroid Build Coastguard Worker %arrayidx.inc = getelementptr i32, i32* %arrayidx.phi, i32 1 29*9880d681SAndroid Build Coastguard Worker br i1 %exitcond15, label %for.body4.preheader.loopexit, label %for.body 30*9880d681SAndroid Build Coastguard Worker 31*9880d681SAndroid Build Coastguard Workerfor.body4.preheader.loopexit: 32*9880d681SAndroid Build Coastguard Worker br label %for.body4.preheader 33*9880d681SAndroid Build Coastguard Worker 34*9880d681SAndroid Build Coastguard Workerfor.body4.preheader: 35*9880d681SAndroid Build Coastguard Worker br label %for.body4 36*9880d681SAndroid Build Coastguard Worker 37*9880d681SAndroid Build Coastguard Workerfor.body4: 38*9880d681SAndroid Build Coastguard Worker %arrayidx5.phi = phi i32* [ %arrayidx5.inc, %for.body4 ], [ %b, %for.body4.preheader ] 39*9880d681SAndroid Build Coastguard Worker %i1.013 = phi i32 [ %inc7, %for.body4 ], [ 0, %for.body4.preheader ] 40*9880d681SAndroid Build Coastguard Worker %1 = load i32, i32* @g, align 4 41*9880d681SAndroid Build Coastguard Worker store i32 %1, i32* %arrayidx5.phi, align 4 42*9880d681SAndroid Build Coastguard Worker %inc7 = add nsw i32 %i1.013, 1 43*9880d681SAndroid Build Coastguard Worker %exitcond = icmp eq i32 %inc7, 3 44*9880d681SAndroid Build Coastguard Worker %arrayidx5.inc = getelementptr i32, i32* %arrayidx5.phi, i32 1 45*9880d681SAndroid Build Coastguard Worker br i1 %exitcond, label %for.end8, label %for.body4 46*9880d681SAndroid Build Coastguard Worker 47*9880d681SAndroid Build Coastguard Workerfor.end8: 48*9880d681SAndroid Build Coastguard Worker ret void 49*9880d681SAndroid Build Coastguard Worker} 50