On 30 January 2018 at 06:33, Dave Airlie <airl...@gmail.com> wrote:
> On 30 January 2018 at 06:25, Gert Wollny <gw.foss...@gmail.com> wrote:
>> Am Montag, den 29.01.2018, 20:32 +0100 schrieb Roland Scheidegger:
>>>
>>> Am I correct assuming that for something like
>>>    while (foo) {
>>>       if (bar) {
>>>          do something;
>>>       } else {
>>>          /* nothing */
>>>       }
>>>    }
>>> The else clause wouldn't get optimized away neither?
>>> (This of course is a trivial example, but I suppose it would extend
>>> to cases where the optimizer actually optimized away the alu
>>> instructions in the else clause).
>>> In this case, this indeed looks rather harsh.
>> This is indeed the case (unless the if is eliminated completely in the
>> if_conversion).
>>
>>> I would have said in theory somehow the break should be some op which
>>> (despite not having a dst) has side-effects so it would not be
>>> subject to elimination somewhere (as there would be a if->next node
>>> in this case then).
>> It is the else that vanishes, but only if there is only a break in the
>> else path, if there there is also an ALU clause, then the else branch
>> is created propperly.
>>
>>> Albeit I'm completely oblivious how it really gets optimized away, is
>>> that based on liveness analysis or something? The sb code is a
>>> mystery to me...
>> I'm trying to understand it, but is is very dificult to grasp how it
>> works even with the debugging output. Well, maybe Dave has a better
>> idea.
>>
>
> I'm reading the paper the whole depart region stuff is based on today,
> maybe I'll come out enlightened or more confused.
>

I'm more confused, but I've attached a patch that I think works, but I'm not
sure it doesn't blow up the world, and I have to head off now.

Dave.
From 0ffea4924a82d1c23f0bb29076bf359bfbcf1207 Mon Sep 17 00:00:00 2001
From: Dave Airlie <airl...@redhat.com>
Date: Tue, 30 Jan 2018 15:34:24 +1000
Subject: [PATCH] sb/hacky patch

---
 src/gallium/drivers/r600/sb/sb_bc_finalize.cpp | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/src/gallium/drivers/r600/sb/sb_bc_finalize.cpp b/src/gallium/drivers/r600/sb/sb_bc_finalize.cpp
index 099b295..0e8d7e1 100644
--- a/src/gallium/drivers/r600/sb/sb_bc_finalize.cpp
+++ b/src/gallium/drivers/r600/sb/sb_bc_finalize.cpp
@@ -208,7 +208,9 @@ void bc_finalizer::finalize_if(region_node* r) {
 		r->push_front(if_jump);
 		r->push_back(if_pop);
 
-		bool has_else = n_if->next;
+		/* if outer node is a depart, we need to have an else
+		   to create the correct flow control */
+		bool has_else = n_if->next || repdep1->is_depart();
 
 		if (has_else) {
 			cf_node *nelse = sh.create_cf(CF_OP_ELSE);
-- 
2.1.0

_______________________________________________
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev

Reply via email to