Mesa (7.9): glsl: Clean up code by adding a new is_break() function.
Ian Romanick
idr at kemper.freedesktop.org
Mon Dec 27 21:33:19 UTC 2010
Module: Mesa
Branch: 7.9
Commit: 760288bec142d49c7f9a541a1b83116a1955b636
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=760288bec142d49c7f9a541a1b83116a1955b636
Author: Kenneth Graunke <kenneth at whitecape.org>
Date: Wed Dec 1 15:06:47 2010 -0800
glsl: Clean up code by adding a new is_break() function.
(cherry picked from commit 528fa8ce329c22d6376d075c2afa69f177423bfa)
---
src/glsl/loop_unroll.cpp | 17 +++++++++++------
1 files changed, 11 insertions(+), 6 deletions(-)
diff --git a/src/glsl/loop_unroll.cpp b/src/glsl/loop_unroll.cpp
index 90797bd..9979106 100644
--- a/src/glsl/loop_unroll.cpp
+++ b/src/glsl/loop_unroll.cpp
@@ -43,6 +43,14 @@ public:
};
+static bool
+is_break(ir_instruction *ir)
+{
+ return ir != NULL && ir->ir_type == ir_type_loop_jump
+ && ((ir_loop_jump *) ir)->is_break();
+}
+
+
ir_visitor_status
loop_unroll_visitor::visit_leave(ir_loop *ir)
{
@@ -93,14 +101,12 @@ loop_unroll_visitor::visit_leave(ir_loop *ir)
ir_instruction *last =
(ir_instruction *) last_if->then_instructions.get_tail();
- if (last && last->ir_type == ir_type_loop_jump
- && ((ir_loop_jump*) last)->is_break()) {
+ if (is_break(last)) {
continue_from_then_branch = false;
} else {
last = (ir_instruction *) last_if->then_instructions.get_tail();
- if (last && last->ir_type == ir_type_loop_jump
- && ((ir_loop_jump*) last)->is_break())
+ if (is_break(last))
continue_from_then_branch = true;
else
/* Bail out if neither if-statement branch ends with a break.
@@ -141,8 +147,7 @@ loop_unroll_visitor::visit_leave(ir_loop *ir)
this->progress = true;
return visit_continue;
- } else if (last_ir->ir_type == ir_type_loop_jump
- && ((ir_loop_jump *)last_ir)->is_break()) {
+ } else if (is_break(last_ir)) {
/* If the only loop-jump is a break at the end of the loop, the loop
* will execute exactly once. Remove the break, set the iteration
* count, and fall through to the normal unroller.
More information about the mesa-commit
mailing list