aboutsummaryrefslogtreecommitdiffstats
path: root/src/mesa
diff options
context:
space:
mode:
authorMatt Turner <[email protected]>2014-09-01 15:38:58 -0700
committerMatt Turner <[email protected]>2014-09-24 09:42:46 -0700
commit235f451f7a11ea5dfa941dcb6f5fc628455e9249 (patch)
tree204ff7ae1e73f5b29071905a6120b93e9710acea /src/mesa
parent90bfeb22444df6ce779251522e47bf169e130f8e (diff)
i965/fs: Make count_to_loop_end() use basic blocks.
When the instructions aren't in a flat list, this wouldn't have worked. Also, this should be faster. Reviewed-by: Topi Pohjolainen <[email protected]>
Diffstat (limited to 'src/mesa')
-rw-r--r--src/mesa/drivers/dri/i965/brw_fs_reg_allocate.cpp31
1 files changed, 16 insertions, 15 deletions
diff --git a/src/mesa/drivers/dri/i965/brw_fs_reg_allocate.cpp b/src/mesa/drivers/dri/i965/brw_fs_reg_allocate.cpp
index 24c3d3a21d6..80ef0a25201 100644
--- a/src/mesa/drivers/dri/i965/brw_fs_reg_allocate.cpp
+++ b/src/mesa/drivers/dri/i965/brw_fs_reg_allocate.cpp
@@ -190,27 +190,28 @@ brw_fs_alloc_reg_sets(struct intel_screen *screen)
brw_alloc_reg_set(screen, 2);
}
-int
-count_to_loop_end(fs_inst *do_inst)
+static int
+count_to_loop_end(const bblock_t *block)
{
+ if (block->end->opcode == BRW_OPCODE_WHILE)
+ return block->end_ip;
+
int depth = 1;
- int ip = 1;
- for (fs_inst *inst = (fs_inst *)do_inst->next;
+ /* Skip the first block, since we don't want to count the do the calling
+ * function found.
+ */
+ for (block = (bblock_t *)block->link.next;
depth > 0;
- inst = (fs_inst *)inst->next) {
- switch (inst->opcode) {
- case BRW_OPCODE_DO:
+ block = (bblock_t *)block->link.next) {
+ if (block->start->opcode == BRW_OPCODE_DO)
depth++;
- break;
- case BRW_OPCODE_WHILE:
+ if (block->end->opcode == BRW_OPCODE_WHILE) {
depth--;
- break;
- default:
- break;
+ if (depth == 0)
+ return block->end_ip;
}
- ip++;
}
- return ip;
+ unreachable("not reached");
}
/**
@@ -253,7 +254,7 @@ fs_visitor::setup_payload_interference(struct ra_graph *g,
* the end now.
*/
if (loop_depth == 1)
- loop_end_ip = ip + count_to_loop_end(inst);
+ loop_end_ip = count_to_loop_end(block);
break;
case BRW_OPCODE_WHILE:
loop_depth--;