From 94e281b9e08c46ebc7112ecf251e71a1a666805b Mon Sep 17 00:00:00 2001 From: Alyssa Rosenzweig Date: Fri, 26 Jul 2019 08:50:22 -0700 Subject: [PATCH] pan/midgard: Specialize mod checking by type when checking constants MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Fixes inlining of integer constants. total quadwords in shared programs: 3585 -> 3568 (-0.47%) quadwords in affected programs: 625 -> 608 (-2.72%) helped: 13 HURT: 0 helped stats (abs) min: 1 max: 2 x̄: 1.31 x̃: 1 helped stats (rel) min: 1.27% max: 9.52% x̄: 3.84% x̃: 2.94% 95% mean confidence interval for quadwords value: -1.60 -1.02 95% mean confidence interval for quadwords %-change: -5.60% -2.07% Quadwords are helped. Signed-off-by: Alyssa Rosenzweig --- src/panfrost/midgard/compiler.h | 1 + src/panfrost/midgard/midgard_compile.c | 3 ++- src/panfrost/midgard/mir.c | 16 ++++++++++------ 3 files changed, 13 insertions(+), 7 deletions(-) diff --git a/src/panfrost/midgard/compiler.h b/src/panfrost/midgard/compiler.h index 84a00fb0174..53d995a109e 100644 --- a/src/panfrost/midgard/compiler.h +++ b/src/panfrost/midgard/compiler.h @@ -390,6 +390,7 @@ void mir_print_instruction(midgard_instruction *ins); void mir_print_bundle(midgard_bundle *ctx); void mir_print_block(midgard_block *block); void mir_print_shader(compiler_context *ctx); +bool mir_nontrivial_raw_mod(midgard_vector_alu_src src, bool is_int); bool mir_nontrivial_source2_mod(midgard_instruction *ins); bool mir_nontrivial_mod(midgard_vector_alu_src src, bool is_int, unsigned mask); bool mir_nontrivial_outmod(midgard_instruction *ins); diff --git a/src/panfrost/midgard/midgard_compile.c b/src/panfrost/midgard/midgard_compile.c index b49f50dc584..48f7bbd38b5 100644 --- a/src/panfrost/midgard/midgard_compile.c +++ b/src/panfrost/midgard/midgard_compile.c @@ -1902,7 +1902,8 @@ embedded_to_inline_constant(compiler_context *ctx) /* We don't know how to handle these with a constant */ - if (src->mod || src->half || src->rep_low || src->rep_high) { + bool is_int = midgard_is_integer_op(ins->alu.op); + if (mir_nontrivial_raw_mod(*src, is_int) || src->half || src->rep_low || src->rep_high) { DBG("Bailing inline constant...\n"); continue; } diff --git a/src/panfrost/midgard/mir.c b/src/panfrost/midgard/mir.c index 75da2fb0864..963652eed3d 100644 --- a/src/panfrost/midgard/mir.c +++ b/src/panfrost/midgard/mir.c @@ -109,13 +109,18 @@ mir_single_use(compiler_context *ctx, unsigned value) } bool -mir_nontrivial_mod(midgard_vector_alu_src src, bool is_int, unsigned mask) +mir_nontrivial_raw_mod(midgard_vector_alu_src src, bool is_int) { - /* abs or neg */ - if (!is_int && src.mod) return true; + if (is_int) + return src.mod == midgard_int_shift; + else + return src.mod; +} - /* Other int mods don't matter in isolation */ - if (is_int && src.mod == midgard_int_shift) return true; +bool +mir_nontrivial_mod(midgard_vector_alu_src src, bool is_int, unsigned mask) +{ + if (mir_nontrivial_raw_mod(src, is_int)) return true; /* size-conversion */ if (src.half) return true; @@ -128,7 +133,6 @@ mir_nontrivial_mod(midgard_vector_alu_src src, bool is_int, unsigned mask) return false; } - bool mir_nontrivial_source2_mod(midgard_instruction *ins) { -- 2.30.2