diff options
author | Alyssa Rosenzweig <alyssa@rosenzweig.io> | 2023-06-20 15:31:22 -0400 |
---|---|---|
committer | Alyssa Rosenzweig <alyssa@rosenzweig.io> | 2023-06-30 16:29:35 -0400 |
commit | f9a0423a20a3d94874404ef026e71c280e001ef8 (patch) | |
tree | 60923968335b7dde1b0d2b71295ca6b7c5b4dc4a /src/panfrost/util | |
parent | 0e97dc25d7736dc4c2a1d8e82cc62b64d003825a (diff) |
pan/mdg: Propagate modifiers in the backend
It really isn't that hard. This drops the roundmode optimization but otherwise
should be at parity to what there was before, and it's massively more competent
at it anyway.
total instructions in shared programs: 1514477 -> 1508444 (-0.40%)
instructions in affected programs: 645848 -> 639815 (-0.93%)
helped: 2712
HURT: 187
Instructions are helped.
total bundles in shared programs: 645069 -> 642999 (-0.32%)
bundles in affected programs: 136233 -> 134163 (-1.52%)
helped: 1242
HURT: 319
Bundles are helped.
total quadwords in shared programs: 1130469 -> 1125969 (-0.40%)
quadwords in affected programs: 379780 -> 375280 (-1.18%)
helped: 1878
HURT: 376
Quadwords are helped.
total registers in shared programs: 90577 -> 90633 (0.06%)
registers in affected programs: 5627 -> 5683 (1.00%)
helped: 309
HURT: 294
Inconclusive result (value mean confidence interval includes 0).
total threads in shared programs: 55594 -> 55607 (0.02%)
threads in affected programs: 118 -> 131 (11.02%)
helped: 43
HURT: 33
Inconclusive result (value mean confidence interval includes 0).
total spills in shared programs: 1399 -> 1371 (-2.00%)
spills in affected programs: 345 -> 317 (-8.12%)
helped: 10
HURT: 4
total fills in shared programs: 5273 -> 5133 (-2.66%)
fills in affected programs: 1035 -> 895 (-13.53%)
helped: 12
HURT: 4
Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
Reviewed-by: Italo Nicola <italonicola@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/23769>
Diffstat (limited to 'src/panfrost/util')
-rw-r--r-- | src/panfrost/util/meson.build | 1 | ||||
-rw-r--r-- | src/panfrost/util/nir_mod_helpers.c | 124 | ||||
-rw-r--r-- | src/panfrost/util/pan_ir.h | 4 |
3 files changed, 0 insertions, 129 deletions
diff --git a/src/panfrost/util/meson.build b/src/panfrost/util/meson.build index 791923f91df..aeb8343f441 100644 --- a/src/panfrost/util/meson.build +++ b/src/panfrost/util/meson.build @@ -22,7 +22,6 @@ libpanfrost_util_files = files( 'lcra.c', 'lcra.h', - 'nir_mod_helpers.c', 'pan_collect_varyings.c', 'pan_ir.c', 'pan_ir.h', diff --git a/src/panfrost/util/nir_mod_helpers.c b/src/panfrost/util/nir_mod_helpers.c deleted file mode 100644 index 466a4d4252a..00000000000 --- a/src/panfrost/util/nir_mod_helpers.c +++ /dev/null @@ -1,124 +0,0 @@ -/* - * Copyright (C) 2020 Collabora, Ltd. - * Copyright (C) 2014 Intel Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice (including the next - * paragraph) shall be included in all copies or substantial portions of the - * Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS - * IN THE SOFTWARE. - */ - -#include "nir.h" -#include "pan_ir.h" - -/* Check if a given ALU source is the result of a particular componentwise 1-op - * ALU source (principally fneg or fabs). If so, return true and rewrite the - * source to be the argument, respecting swizzles as needed. If not (or it - * cannot be proven), return false and leave the source untouched. - */ - -bool -pan_has_source_mod(nir_alu_src *src, nir_op op) -{ - if (!src->src.is_ssa || - src->src.ssa->parent_instr->type != nir_instr_type_alu) - return false; - - nir_alu_instr *alu = nir_instr_as_alu(src->src.ssa->parent_instr); - - if (alu->op != op) - return false; - - /* This only works for unary ops */ - assert(nir_op_infos[op].num_inputs == 1); - - /* If the copied source is not SSA, moving it might not be valid */ - if (!alu->src[0].src.is_ssa) - return false; - - /* Okay - we've found the modifier we wanted. Let's construct the new ALU - * src. In a scalar world, this is just psrc, but for vector archs we need - * to respect the swizzle, so we compose. - */ - - nir_alu_src nsrc = { - .src = alu->src[0].src, - }; - - for (unsigned i = 0; i < NIR_MAX_VEC_COMPONENTS; ++i) { - /* (a o b)(i) = a(b(i)) ... swizzle composition is intense. */ - nsrc.swizzle[i] = alu->src[0].swizzle[src->swizzle[i]]; - } - - *src = nsrc; - return true; -} - -/* Check if a given instruction's result will be fed into a - * componentwise 1-op ALU instruction (principally fsat without - * swizzles). If so, return true and rewrite the destination. The - * backend will need to track the new destinations to avoid - * incorrect double-emits. */ - -bool -pan_has_dest_mod(nir_dest **odest, nir_op op) -{ - /* This only works for unary ops */ - assert(nir_op_infos[op].num_inputs == 1); - - /* If not SSA, this might not be legal */ - nir_dest *dest = *odest; - if (!dest->is_ssa) - return false; - - /* Check the uses. We want a single use, with the op `op` */ - if (!list_is_singular(&dest->ssa.uses)) - return false; - - nir_src *use = list_first_entry(&dest->ssa.uses, nir_src, use_link); - if (use->is_if) - return false; - - nir_instr *parent = use->parent_instr; - - /* Check if the op is `op` */ - if (parent->type != nir_instr_type_alu) - return false; - - nir_alu_instr *alu = nir_instr_as_alu(parent); - if (alu->op != op) - return false; - - /* We can't do expansions without a move in the middle */ - unsigned nr_components = nir_dest_num_components(alu->dest.dest); - - if (nir_dest_num_components(*dest) != nr_components) - return false; - - /* We don't handle swizzles here, so check for the identity */ - for (unsigned i = 0; i < nr_components; ++i) { - if (alu->src[0].swizzle[i] != i) - return false; - } - - if (!alu->dest.dest.is_ssa) - return false; - - /* Otherwise, we're good */ - *odest = &alu->dest.dest; - return true; -} diff --git a/src/panfrost/util/pan_ir.h b/src/panfrost/util/pan_ir.h index 046729929a9..0faf816ec5b 100644 --- a/src/panfrost/util/pan_ir.h +++ b/src/panfrost/util/pan_ir.h @@ -418,10 +418,6 @@ pan_dest_index(nir_dest *dst) /* IR printing helpers */ void pan_print_alu_type(nir_alu_type t, FILE *fp); -/* Until it can be upstreamed.. */ -bool pan_has_source_mod(nir_alu_src *src, nir_op op); -bool pan_has_dest_mod(nir_dest **dest, nir_op op); - /* NIR passes to do some backend-specific lowering */ #define PAN_WRITEOUT_C 1 |