glsl: Handle empty if statement encountered during loop analysis.
authorPaul Berry <stereotype441@gmail.com>
Wed, 24 Jul 2013 15:04:44 +0000 (08:04 -0700)
committerPaul Berry <stereotype441@gmail.com>
Thu, 25 Jul 2013 16:37:02 +0000 (09:37 -0700)
The is_loop_terminator() function was asserting that the following
kind of if statement could never occur:

    if (...) { } else { }

(presumably based on the assumption that such an if statement would be
eliminated by previous optimization stages).  But that isn't the
case--it's possible that previous optimization stages might simplify
more complex code down to this empty if statement, in which case it
won't be eliminated until the next time through the optimization loop.

So is_loop_terminator() needs to handle it.  Fortunately it's easy to
handle--it's not a loop terminator because it does nothing.

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=64330
CC: mesa-stable@lists.freedesktop.org
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
src/glsl/loop_analysis.cpp

index 191e92de7c48f7689837f5c769a2784702bf16f2..40897bb6fa8d44c531f0d2894c7eff89169658e2 100644 (file)
@@ -503,7 +503,8 @@ is_loop_terminator(ir_if *ir)
 
    ir_instruction *const inst =
       (ir_instruction *) ir->then_instructions.get_head();
-   assert(inst != NULL);
+   if (inst == NULL)
+      return false;
 
    if (inst->ir_type != ir_type_loop_jump)
       return false;