Skip to content

Commit 84909d7

Browse files
committed
[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.
1 parent 6d38dbf commit 84909d7

File tree

2 files changed

+19
-2
lines changed

2 files changed

+19
-2
lines changed

llvm/lib/Target/AMDGPU/GCNSchedStrategy.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1567,8 +1567,7 @@ void GCNSchedStage::revertScheduling() {
15671567
}
15681568

15691569
if (MI->getIterator() != DAG.RegionEnd) {
1570-
DAG.BB->remove(MI);
1571-
DAG.BB->insert(DAG.RegionEnd, MI);
1570+
DAG.BB->splice(DAG.RegionEnd, DAG.BB, MI);
15721571
if (!MI->isDebugInstr())
15731572
DAG.LIS->handleMove(*MI, true);
15741573
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
; REQUIRES: asserts
2+
; RUN: llc -mtriple=amdgcn -O1 -mcpu=gfx90a -debug-only=machine-scheduler -filetype=null < %s 2>&1 | FileCheck --check-prefix=DEBUG %s
3+
4+
; DEBUG: Attempting to revert scheduling.
5+
6+
@G = global <32 x i8> splat (i8 1)
7+
@G.1 = global <32 x i8> splat (i8 127)
8+
9+
define amdgpu_kernel void @gws_sema_v_offset0(i32 %val, <32 x i1>* %inp) {
10+
%LGV1 = load <32 x i8>, ptr @G.1, align 32
11+
%LGV = load <32 x i8>, ptr @G, align 32
12+
call void @llvm.amdgcn.ds.gws.sema.v(i32 0)
13+
%C = icmp ne <32 x i8> %LGV, %LGV1
14+
store <32 x i1> %C, ptr %inp, align 4
15+
ret void
16+
}
17+
18+
declare void @llvm.amdgcn.ds.gws.sema.v(i32)

0 commit comments

Comments
 (0)