glsl: Consider the "else" branch when looking for loop breaks.
authorKenneth Graunke <kenneth@whitecape.org>
Wed, 1 Dec 2010 23:33:56 +0000 (15:33 -0800)
committerIan Romanick <ian.d.romanick@intel.com>
Fri, 10 Dec 2010 00:42:05 +0000 (16:42 -0800)
Found this bug by code inspection.  Based off the comments just before
this code, the intent is to find whether the break exists in the "then"
branch or the "else" branch.  However, the code actually looked at the
last instruction in the "then" branch twice.

src/glsl/loop_unroll.cpp

index 4e6acda907ed91f1abaa5337dca4e20a35c2cfe3..c5001ba953040629026f5fe762b9e4b035480da8 100644 (file)
@@ -104,7 +104,7 @@ loop_unroll_visitor::visit_leave(ir_loop *ir)
         if (is_break(last)) {
            continue_from_then_branch = false;
         } else {
-           last = (ir_instruction *) last_if->then_instructions.get_tail();
+           last = (ir_instruction *) last_if->else_instructions.get_tail();
 
            if (is_break(last))
               continue_from_then_branch = true;