Mesa (master): r600/sb: insert the else clause when we might depart from a loop
Dave Airlie
airlied at kemper.freedesktop.org
Tue Jan 30 18:49:34 UTC 2018
Module: Mesa
Branch: master
Commit: 8d633f067b8a3d74e3f39faea0773a229d4b93b3
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=8d633f067b8a3d74e3f39faea0773a229d4b93b3
Author: Dave Airlie <airlied at redhat.com>
Date: Tue Jan 30 16:38:51 2018 +1000
r600/sb: insert the else clause when we might depart from a loop
If there is a break inside the else clause and this means we
are breaking from a loop, the loop finalise will want to insert
the LOOP_BREAK/CONTINUE instruction, however if we don't emit
the else there is no where for these to end up, so they will end
up in the wrong place.
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=101442
Tested-By: Gert Wollny <gw.fossdev at gmail.com>
Cc: <mesa-stable at lists.freedesktop.org>
Reviewed-by: Roland Scheidegger <sroland at vmware.com>
Signed-off-by: Dave Airlie <airlied at redhat.com>
---
src/gallium/drivers/r600/sb/sb_bc_finalize.cpp | 17 +++++++++++++++++
1 file changed, 17 insertions(+)
diff --git a/src/gallium/drivers/r600/sb/sb_bc_finalize.cpp b/src/gallium/drivers/r600/sb/sb_bc_finalize.cpp
index 099b295f18..d3fab80020 100644
--- a/src/gallium/drivers/r600/sb/sb_bc_finalize.cpp
+++ b/src/gallium/drivers/r600/sb/sb_bc_finalize.cpp
@@ -208,8 +208,25 @@ void bc_finalizer::finalize_if(region_node* r) {
r->push_front(if_jump);
r->push_back(if_pop);
+ /* the depart/repeat 1 is actually part of the "else" code.
+ * if it's a depart for an outer loop region it will want to
+ * insert a LOOP_BREAK or LOOP_CONTINUE in here, so we need
+ * to emit the else clause.
+ */
bool has_else = n_if->next;
+ if (repdep1->is_depart()) {
+ depart_node *dep1 = static_cast<depart_node*>(repdep1);
+ if (dep1->target != r && dep1->target->is_loop())
+ has_else = true;
+ }
+
+ if (repdep1->is_repeat()) {
+ repeat_node *rep1 = static_cast<repeat_node*>(repdep1);
+ if (rep1->target != r && rep1->target->is_loop())
+ has_else = true;
+ }
+
if (has_else) {
cf_node *nelse = sh.create_cf(CF_OP_ELSE);
n_if->insert_after(nelse);
More information about the mesa-commit
mailing list