diff --git a/src/panfrost/bifrost/valhall/test/test-merge-flow.cpp b/src/panfrost/bifrost/valhall/test/test-merge-flow.cpp index 37d8b3e19dc..d5dbc8cb4a8 100644 --- a/src/panfrost/bifrost/valhall/test/test-merge-flow.cpp +++ b/src/panfrost/bifrost/valhall/test/test-merge-flow.cpp @@ -292,3 +292,14 @@ TEST_F(MergeFlow, DeletePointlessDiscard) { }); } +TEST_F(MergeFlow, PreserveTerminalBarriers) { + CASE({ + bi_barrier(b); + flow(WAIT); + flow(END); + }, + { + bi_barrier(b)->flow = VA_FLOW_WAIT; + flow(END); + }); +} diff --git a/src/panfrost/bifrost/valhall/va_merge_flow.c b/src/panfrost/bifrost/valhall/va_merge_flow.c index a6987f8a6e7..42475c24164 100644 --- a/src/panfrost/bifrost/valhall/va_merge_flow.c +++ b/src/panfrost/bifrost/valhall/va_merge_flow.c @@ -83,9 +83,11 @@ merge_end_reconverge(bi_block *block) if (last->op != BI_OPCODE_NOP) return; if (last->flow != VA_FLOW_RECONVERGE && last->flow != VA_FLOW_END) return; - /* End implies all other flow control, so remove blocking flow control */ + /* End implies all other flow control except for waiting on barriers (slot + * #7, with VA_FLOW_WAIT), so remove blocking flow control. + */ if (last->flow == VA_FLOW_END) { - while (penult->op == BI_OPCODE_NOP) { + while (penult->op == BI_OPCODE_NOP && penult->flow != VA_FLOW_WAIT) { bi_remove_instruction(penult); /* There may be nothing left */