diff --git a/src/gallium/drivers/r300/compiler/radeon_optimize.c b/src/gallium/drivers/r300/compiler/radeon_optimize.c index 475d8964963..116d431227d 100644 --- a/src/gallium/drivers/r300/compiler/radeon_optimize.c +++ b/src/gallium/drivers/r300/compiler/radeon_optimize.c @@ -1374,6 +1374,21 @@ static void merge_ARL(struct radeon_compiler * c, struct rc_instruction * inst) } } +/** + * Apply various optimizations specific to the A0 adress register loads. + */ +static void optimize_A0_loads(struct radeon_compiler * c) { + struct rc_instruction * inst = c->Program.Instructions.Next; + + while (inst != &c->Program.Instructions) { + struct rc_instruction * cur = inst; + inst = inst->Next; + if (cur->U.I.Opcode == RC_OPCODE_ARL) { + merge_ARL(c, cur); + } + } +} + void rc_optimize(struct radeon_compiler * c, void *user) { struct rc_instruction * inst = c->Program.Instructions.Next; @@ -1393,6 +1408,10 @@ void rc_optimize(struct radeon_compiler * c, void *user) } } + if (c->type == RC_VERTEX_PROGRAM) { + optimize_A0_loads(c); + } + /* Merge MOVs to same source in different channels using the constant * swizzle. */ @@ -1419,6 +1438,10 @@ void rc_optimize(struct radeon_compiler * c, void *user) } } + if (c->type != RC_FRAGMENT_PROGRAM) { + return; + } + /* Presubtract operations. */ inst = c->Program.Instructions.Next; while(inst != &c->Program.Instructions) { @@ -1427,19 +1450,7 @@ void rc_optimize(struct radeon_compiler * c, void *user) peephole(c, cur); } - - if (!c->has_omod) { - inst = c->Program.Instructions.Next; - while (inst != &c->Program.Instructions) { - struct rc_instruction * cur = inst; - inst = inst->Next; - if (cur->U.I.Opcode == RC_OPCODE_ARL) { - merge_ARL(c, cur); - } - } - return; - } - + /* Output modifiers. */ inst = c->Program.Instructions.Next; struct rc_list * var_list = NULL; while(inst != &c->Program.Instructions) { diff --git a/src/gallium/drivers/r300/compiler/tests/rc_test_helpers.c b/src/gallium/drivers/r300/compiler/tests/rc_test_helpers.c index 008bf5d3174..0c85579ca9c 100644 --- a/src/gallium/drivers/r300/compiler/tests/rc_test_helpers.c +++ b/src/gallium/drivers/r300/compiler/tests/rc_test_helpers.c @@ -513,6 +513,7 @@ void init_compiler( rc_init_regalloc_state(rs, program_type); rc_init(c, rs); + c->type = program_type; c->is_r500 = is_r500; c->max_temp_regs = is_r500 ? 128 : (is_r400 ? 64 : 32); c->max_constants = is_r500 ? 256 : 32;