glsl: fix lowering conditional returns in subroutines
authorFabian Bieler <der.fabe@gmx.net>
Wed, 1 Dec 2010 13:44:58 +0000 (14:44 +0100)
committerKenneth Graunke <kenneth@whitecape.org>
Thu, 9 Dec 2010 19:28:06 +0000 (11:28 -0800)
this fix applies to the lower_sub_return 'branch' of the lower_jumps pass

Fixes piglit tests glsl-functions-5 and glsl-functions-6.

src/glsl/lower_jumps.cpp

index 9cd15ef73666e609c12e9c071354a81f8582749e..d99e0aa7398b95490c06defc13f59f300607a1f2 100644 (file)
@@ -512,7 +512,11 @@ lower_continue:
       if(this->loop.may_set_return_flag) {
          assert(this->function.return_flag);
          ir_if* return_if = new(ir) ir_if(new(ir) ir_dereference_variable(this->function.return_flag));
-         return_if->then_instructions.push_tail(new(ir) ir_loop_jump(saved_loop.loop ? ir_loop_jump::jump_break : ir_loop_jump::jump_continue));
+         saved_loop.may_set_return_flag = true;
+         if(saved_loop.loop)
+            return_if->then_instructions.push_tail(new(ir) ir_loop_jump(ir_loop_jump::jump_break));
+         else
+            move_outer_block_inside(ir, &return_if->else_instructions);
          ir->insert_after(return_if);
       }