glsl: Small optimization for constant conditionals
authorIago Toral Quiroga <itoral@igalia.com>
Tue, 15 Apr 2014 10:30:40 +0000 (12:30 +0200)
committerKenneth Graunke <kenneth@whitecape.org>
Thu, 17 Apr 2014 06:39:57 +0000 (23:39 -0700)
Once the relevant branch has been identified do not iterate over the
instructions in the branch, do a linked list insertion instead to avoid the
loop.

Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
src/glsl/opt_if_simplification.cpp

index 2bec8252ea510d67077a8caeb803a3c2d34929f4..e05f03190aa10e8d7035e4787b0e4e231b18be8b 100644 (file)
@@ -90,15 +90,9 @@ ir_if_simplification_visitor::visit_leave(ir_if *ir)
        * that matters out.
        */
       if (condition_constant->value.b[0]) {
-        foreach_list_safe(n, &ir->then_instructions) {
-           ir_instruction *then_ir = (ir_instruction *) n;
-           ir->insert_before(then_ir);
-        }
+         ir->insert_before(&ir->then_instructions);
       } else {
-        foreach_list_safe(n, &ir->else_instructions) {
-           ir_instruction *else_ir = (ir_instruction *) n;
-           ir->insert_before(else_ir);
-        }
+         ir->insert_before(&ir->else_instructions);
       }
       ir->remove();
       this->made_progress = true;