freedreno/ir3: rename depth->dce

Since DCE is the only remaining function of this pass, after the pre-RA
scheduler rewrite.

Signed-off-by: Rob Clark <robdclark@chromium.org>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4440>
This commit is contained in:
Rob Clark
2020-04-04 10:29:53 -07:00
committed by Marge Bot
parent cf74048fd1
commit 751c11a8c7
7 changed files with 18 additions and 68 deletions
+1 -1
View File
@@ -29,7 +29,7 @@ ir3_SOURCES := \
ir3/ir3_context.h \
ir3/ir3_cp.c \
ir3/ir3_cf.c \
ir3/ir3_depth.c \
ir3/ir3_dce.c \
ir3/ir3_delay.c \
ir3/ir3_group.c \
ir3/ir3_image.c \
-1
View File
@@ -1149,7 +1149,6 @@ ir3_clear_mark(struct ir3 *ir)
}
}
/* note: this will destroy instr->depth, don't do it until after sched! */
unsigned
ir3_count_instructions(struct ir3 *ir)
{
+5 -21
View File
@@ -306,25 +306,9 @@ struct ir3_instruction {
} input;
};
/* transient values used during various algorithms: */
union {
/* The instruction depth is the max dependency distance to output.
*
* You can also think of it as the "cost", if we did any sort of
* optimization for register footprint. Ie. a value that is just
* result of moving a const to a reg would have a low cost, so to
* it could make sense to duplicate the instruction at various
* points where the result is needed to reduce register footprint.
*/
int depth;
/* When we get to the RA stage, we no longer need depth, but
* we do need instruction's position/name:
*/
struct {
uint16_t ip;
uint16_t name;
};
};
/* When we get to the RA stage, we need instruction's position/name: */
uint16_t ip;
uint16_t name;
/* used for per-pass extra instruction data.
*
@@ -1199,9 +1183,9 @@ unsigned ir3_delay_calc(struct ir3_block *block, struct ir3_instruction *instr,
bool soft, bool pred);
void ir3_remove_nops(struct ir3 *ir);
/* depth calculation: */
/* dead code elimination: */
struct ir3_shader_variant;
void ir3_depth(struct ir3 *ir, struct ir3_shader_variant *so);
void ir3_dce(struct ir3 *ir, struct ir3_shader_variant *so);
/* fp16 conversion folding */
void ir3_cf(struct ir3 *ir);
+2 -2
View File
@@ -3640,9 +3640,9 @@ ir3_compile_shader_nir(struct ir3_compiler *compiler,
ir3_debug_print(ir, "AFTER GROUPING");
ir3_depth(ir, so);
ir3_dce(ir, so);
ir3_debug_print(ir, "AFTER DEPTH");
ir3_debug_print(ir, "AFTER DCE");
/* do SethiUllman numbering before scheduling: */
ir3_sun(ir);
@@ -30,26 +30,11 @@
#include "ir3_shader.h"
/*
* Instruction Depth:
*
* Calculates weighted instruction depth, ie. the sum of # of needed
* instructions plus delay slots back to original input (ie INPUT or
* CONST). That is to say, an instructions depth is:
*
* depth(instr) {
* d = 0;
* // for each src register:
* foreach (src in instr->regs[1..n])
* d = max(d, delayslots(src->instr, n) + depth(src->instr));
* return d + 1;
* }
*
* After an instruction's depth is calculated, it is inserted into the
* blocks depth sorted list, which is used by the scheduling pass.
* Dead code elimination:
*/
static void
ir3_instr_depth(struct ir3_instruction *instr, unsigned boost, bool falsedep)
instr_dce(struct ir3_instruction *instr, bool falsedep)
{
struct ir3_instruction *src;
@@ -60,26 +45,9 @@ ir3_instr_depth(struct ir3_instruction *instr, unsigned boost, bool falsedep)
if (ir3_instr_check_mark(instr))
return;
instr->depth = 0;
foreach_ssa_src_n (src, i, instr) {
unsigned sd;
/* visit child to compute it's depth: */
ir3_instr_depth(src, boost, __is_false_dep(instr, i));
/* for array writes, no need to delay on previous write: */
if (i == 0)
continue;
sd = ir3_delayslots(src, instr, i, true) + src->depth;
sd += boost;
instr->depth = MAX2(instr->depth, sd);
instr_dce(src, __is_false_dep(instr, i));
}
if (!is_meta(instr))
instr->depth++;
}
static bool
@@ -129,7 +97,7 @@ remove_unused_by_block(struct ir3_block *block)
}
static bool
compute_depth_and_remove_unused(struct ir3 *ir, struct ir3_shader_variant *so)
find_and_remove_unused(struct ir3 *ir, struct ir3_shader_variant *so)
{
unsigned i;
bool progress = false;
@@ -154,15 +122,15 @@ compute_depth_and_remove_unused(struct ir3 *ir, struct ir3_shader_variant *so)
struct ir3_instruction *out;
foreach_output (out, ir)
ir3_instr_depth(out, 0, false);
instr_dce(out, false);
foreach_block (block, &ir->block_list) {
for (i = 0; i < block->keeps_count; i++)
ir3_instr_depth(block->keeps[i], 0, false);
instr_dce(block->keeps[i], false);
/* We also need to account for if-condition: */
if (block->condition)
ir3_instr_depth(block->condition, 6, false);
instr_dce(block->condition, false);
}
/* remove un-used instructions: */
@@ -211,7 +179,7 @@ compute_depth_and_remove_unused(struct ir3 *ir, struct ir3_shader_variant *so)
}
void
ir3_depth(struct ir3 *ir, struct ir3_shader_variant *so)
ir3_dce(struct ir3 *ir, struct ir3_shader_variant *so)
{
void *mem_ctx = ralloc_context(NULL);
bool progress;
@@ -219,7 +187,7 @@ ir3_depth(struct ir3 *ir, struct ir3_shader_variant *so)
ir3_find_ssa_uses(ir, mem_ctx, true);
do {
progress = compute_depth_and_remove_unused(ir, so);
progress = find_and_remove_unused(ir, so);
} while (progress);
ralloc_free(mem_ctx);
-1
View File
@@ -72,7 +72,6 @@ static void print_instr_name(struct ir3_instruction *instr, bool flags)
#endif
printf("%04u:", instr->name);
printf("%04u:", instr->ip);
printf("%03d:", instr->depth);
if (instr->flags & IR3_INSTR_UNUSED) {
printf("XXX: ");
} else {
+1 -1
View File
@@ -55,8 +55,8 @@ libfreedreno_ir3_files = files(
'ir3_context.h',
'ir3_cf.c',
'ir3_cp.c',
'ir3_dce.c',
'ir3_delay.c',
'ir3_depth.c',
'ir3_group.c',
'ir3_image.c',
'ir3_image.h',