diff --git a/llvm/lib/CodeGen/MachineScheduler.cpp b/llvm/lib/CodeGen/MachineScheduler.cpp --- a/llvm/lib/CodeGen/MachineScheduler.cpp +++ b/llvm/lib/CodeGen/MachineScheduler.cpp @@ -1609,7 +1609,7 @@ unsigned ChainPredID = DAG->SUnits.size(); for (const SDep &Pred : SU.Preds) { - if (Pred.isCtrl()) { + if (Pred.isCtrl() && !Pred.isArtificial()) { ChainPredID = Pred.getSUnit()->NodeNum; break; } diff --git a/llvm/test/CodeGen/AMDGPU/cluster_stores.ll b/llvm/test/CodeGen/AMDGPU/cluster_stores.ll new file mode 100644 --- /dev/null +++ b/llvm/test/CodeGen/AMDGPU/cluster_stores.ll @@ -0,0 +1,27 @@ +; RUN: llc -march=amdgcn -mcpu=gfx900 -debug-only=machine-scheduler -o /dev/null %s 2>&1 | FileCheck %s +; REQUIRES: asserts + +define amdgpu_kernel void @f(i32* noalias %lb, i32* noalias %sb) { +bb: +; CHECK-COUNT-3: Cluster ld/st + %la0 = getelementptr inbounds i32, i32* %lb, i32 0 + %ld0 = load i32, i32* %la0 + %la1 = getelementptr inbounds i32, i32* %lb, i32 2 + %ld1 = load i32, i32* %la1 + %la2 = getelementptr inbounds i32, i32* %lb, i32 4 + %ld2 = load i32, i32* %la2 + %la3 = getelementptr inbounds i32, i32* %lb, i32 6 + %ld3 = load i32, i32* %la3 + +; CHECK-COUNT-3: Cluster ld/st + %sa0 = getelementptr inbounds i32, i32* %sb, i32 0 + store i32 %ld0, i32* %sa0 + %sa1 = getelementptr inbounds i32, i32* %sb, i32 2 + store i32 %ld1, i32* %sa1 + %sa2 = getelementptr inbounds i32, i32* %sb, i32 4 + store i32 %ld2, i32* %sa2 + %sa3 = getelementptr inbounds i32, i32* %sb, i32 6 + store i32 %ld3, i32* %sa3 + + ret void +}