[llvm] 84909d7 - [AMDGCN] Allow unscheduling of bundled insns
Julian Brown via llvm-commits
llvm-commits at lists.llvm.org
Tue Mar 18 09:59:11 PDT 2025
Author: Julian Brown
Date: 2025-03-18T11:56:51-05:00
New Revision: 84909d797782a0dcf240f79a8e5e863d8165c03f
URL: https://github.com/llvm/llvm-project/commit/84909d797782a0dcf240f79a8e5e863d8165c03f
DIFF: https://github.com/llvm/llvm-project/commit/84909d797782a0dcf240f79a8e5e863d8165c03f.diff
LOG: [AMDGCN] Allow unscheduling of bundled insns
This is a patch arising from AMD's fuzzing project.
In the test case, the scheduling algorithm decides to undo an attempted
schedule, but is unprepared to handle bundled instructions at that
point -- and those can arise via the expansion of intrinsics earlier
in compilation. The fix is to use the splice method instead of
remove/insert, since that can handle bundles properly.
Added:
llvm/test/CodeGen/AMDGPU/sema-v-unsched-bundle.ll
Modified:
llvm/lib/Target/AMDGPU/GCNSchedStrategy.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Target/AMDGPU/GCNSchedStrategy.cpp b/llvm/lib/Target/AMDGPU/GCNSchedStrategy.cpp
index c277223de13ac..5dcf523430fd2 100644
--- a/llvm/lib/Target/AMDGPU/GCNSchedStrategy.cpp
+++ b/llvm/lib/Target/AMDGPU/GCNSchedStrategy.cpp
@@ -1567,8 +1567,7 @@ void GCNSchedStage::revertScheduling() {
}
if (MI->getIterator() != DAG.RegionEnd) {
- DAG.BB->remove(MI);
- DAG.BB->insert(DAG.RegionEnd, MI);
+ DAG.BB->splice(DAG.RegionEnd, DAG.BB, MI);
if (!MI->isDebugInstr())
DAG.LIS->handleMove(*MI, true);
}
diff --git a/llvm/test/CodeGen/AMDGPU/sema-v-unsched-bundle.ll b/llvm/test/CodeGen/AMDGPU/sema-v-unsched-bundle.ll
new file mode 100644
index 0000000000000..5ff2f24d294dc
--- /dev/null
+++ b/llvm/test/CodeGen/AMDGPU/sema-v-unsched-bundle.ll
@@ -0,0 +1,18 @@
+; REQUIRES: asserts
+; RUN: llc -mtriple=amdgcn -O1 -mcpu=gfx90a -debug-only=machine-scheduler -filetype=null < %s 2>&1 | FileCheck --check-prefix=DEBUG %s
+
+; DEBUG: Attempting to revert scheduling.
+
+ at G = global <32 x i8> splat (i8 1)
+ at G.1 = global <32 x i8> splat (i8 127)
+
+define amdgpu_kernel void @gws_sema_v_offset0(i32 %val, <32 x i1>* %inp) {
+ %LGV1 = load <32 x i8>, ptr @G.1, align 32
+ %LGV = load <32 x i8>, ptr @G, align 32
+ call void @llvm.amdgcn.ds.gws.sema.v(i32 0)
+ %C = icmp ne <32 x i8> %LGV, %LGV1
+ store <32 x i1> %C, ptr %inp, align 4
+ ret void
+}
+
+declare void @llvm.amdgcn.ds.gws.sema.v(i32)
More information about the llvm-commits
mailing list