summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEmma Anholt <emma@anholt.net>2022-01-31 11:45:36 -0800
committerEmma Anholt <emma@anholt.net>2022-02-03 14:28:46 -0800
commit4f22f4ca1a8b18fad62a80ebcc68b7aa3e9078ee (patch)
treee8df6d59b021943b46ce8c6ae9d958c704bf13fd
parent17cea74b8cd3b1a56d923edeb40772b3e8b18ab2 (diff)
r300: Simplify DCE by assuming all output writes are used.
No change on shader-db. Reviewed-by: Matt Turner <mattst88@gmail.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14847>
-rw-r--r--src/gallium/drivers/r300/compiler/r3xx_fragprog.c13
-rw-r--r--src/gallium/drivers/r300/compiler/r3xx_vertprog.c14
-rw-r--r--src/gallium/drivers/r300/compiler/radeon_dataflow_deadcode.c16
3 files changed, 8 insertions, 35 deletions
diff --git a/src/gallium/drivers/r300/compiler/r3xx_fragprog.c b/src/gallium/drivers/r300/compiler/r3xx_fragprog.c
index 8aa4ef9e86b..1d41a552dd2 100644
--- a/src/gallium/drivers/r300/compiler/r3xx_fragprog.c
+++ b/src/gallium/drivers/r300/compiler/r3xx_fragprog.c
@@ -37,17 +37,6 @@
#include "r500_fragprog.h"
-static void dataflow_outputs_mark_use(void * userdata, void * data,
- void (*callback)(void *, unsigned int, unsigned int))
-{
- struct r300_fragment_program_compiler * c = userdata;
- callback(data, c->OutputColor[0], RC_MASK_XYZW);
- callback(data, c->OutputColor[1], RC_MASK_XYZW);
- callback(data, c->OutputColor[2], RC_MASK_XYZW);
- callback(data, c->OutputColor[3], RC_MASK_XYZW);
- callback(data, c->OutputDepth, RC_MASK_W);
-}
-
static void rc_rewrite_depth_out(struct radeon_compiler *cc, void *user)
{
struct r300_fragment_program_compiler *c = (struct r300_fragment_program_compiler*)cc;
@@ -128,7 +117,7 @@ void r3xx_compile_fragment_program(struct r300_fragment_program_compiler* c)
{"transform IF", 1, is_r500, rc_local_transform, rewrite_if},
{"native rewrite", 1, is_r500, rc_local_transform, native_rewrite_r500},
{"native rewrite", 1, !is_r500, rc_local_transform, native_rewrite_r300},
- {"deadcode", 1, opt, rc_dataflow_deadcode, dataflow_outputs_mark_use},
+ {"deadcode", 1, opt, rc_dataflow_deadcode, NULL},
{"emulate loops", 1, !is_r500, rc_emulate_loops, NULL},
{"register rename", 1, !is_r500 || opt, rc_rename_regs, NULL},
{"dataflow optimize", 1, opt, rc_optimize, NULL},
diff --git a/src/gallium/drivers/r300/compiler/r3xx_vertprog.c b/src/gallium/drivers/r300/compiler/r3xx_vertprog.c
index de0d98240f3..559a8ff54e7 100644
--- a/src/gallium/drivers/r300/compiler/r3xx_vertprog.c
+++ b/src/gallium/drivers/r300/compiler/r3xx_vertprog.c
@@ -772,18 +772,6 @@ static void rc_vs_add_artificial_outputs(struct radeon_compiler *c, void *user)
}
}
-static void dataflow_outputs_mark_used(void * userdata, void * data,
- void (*callback)(void *, unsigned int, unsigned int))
-{
- struct r300_vertex_program_compiler * c = userdata;
- int i;
-
- for(i = 0; i < 32; ++i) {
- if (c->RequiredOutputs & (1U << i))
- callback(data, i, RC_MASK_XYZW);
- }
-}
-
static int swizzle_is_native(rc_opcode opcode, struct rc_src_register reg)
{
(void) opcode;
@@ -909,7 +897,7 @@ void r3xx_compile_vertex_program(struct r300_vertex_program_compiler *c)
{"native rewrite", 1, is_r500, rc_local_transform, alu_rewrite_r500},
{"native rewrite", 1, !is_r500, rc_local_transform, alu_rewrite_r300},
{"emulate modifiers", 1, !is_r500, rc_local_transform, emulate_modifiers},
- {"deadcode", 1, opt, rc_dataflow_deadcode, dataflow_outputs_mark_used},
+ {"deadcode", 1, opt, rc_dataflow_deadcode, NULL},
{"dataflow optimize", 1, opt, rc_optimize, NULL},
/* This pass must be done after optimizations. */
{"source conflict resolve", 1, 1, rc_local_transform, resolve_src_conflicts},
diff --git a/src/gallium/drivers/r300/compiler/radeon_dataflow_deadcode.c b/src/gallium/drivers/r300/compiler/radeon_dataflow_deadcode.c
index 44fc13377fa..22b6d1ba58d 100644
--- a/src/gallium/drivers/r300/compiler/radeon_dataflow_deadcode.c
+++ b/src/gallium/drivers/r300/compiler/radeon_dataflow_deadcode.c
@@ -204,18 +204,10 @@ static void update_instruction(struct deadcode_state * s, struct rc_instruction
}
}
-static void mark_output_use(void * data, unsigned int index, unsigned int mask)
-{
- struct deadcode_state * s = data;
-
- mark_used(s, RC_FILE_OUTPUT, index, mask);
-}
-
void rc_dataflow_deadcode(struct radeon_compiler * c, void *user)
{
struct deadcode_state s;
unsigned int nr_instructions;
- rc_dataflow_mark_outputs_fn dce = (rc_dataflow_mark_outputs_fn)user;
unsigned int ip;
memset(&s, 0, sizeof(s));
@@ -225,13 +217,17 @@ void rc_dataflow_deadcode(struct radeon_compiler * c, void *user)
s.Instructions = memory_pool_malloc(&c->Pool, sizeof(struct instruction_state)*nr_instructions);
memset(s.Instructions, 0, sizeof(struct instruction_state)*nr_instructions);
- dce(c, &s, &mark_output_use);
-
for(struct rc_instruction * inst = c->Program.Instructions.Prev;
inst != &c->Program.Instructions;
inst = inst->Prev) {
const struct rc_opcode_info * opcode = rc_get_opcode_info(inst->U.I.Opcode);
+ /* Assume all output regs are live. Anything else should have been
+ * eliminated before it got to us.
+ */
+ if (opcode->HasDstReg)
+ mark_used(&s, RC_FILE_OUTPUT, inst->U.I.DstReg.Index, inst->U.I.DstReg.WriteMask);
+
switch(opcode->Opcode){
/* Mark all sources in the loop body as used before doing
* normal deadcode analysis. This is probably not optimal.