diff options
author | Jonathan Marek <[email protected]> | 2019-05-08 12:45:48 -0400 |
---|---|---|
committer | Jonathan Marek <[email protected]> | 2019-05-10 15:10:41 +0000 |
commit | d0bff89159bead4ba850182e5a30d0745510f773 (patch) | |
tree | 298e51fffbc2bdfeb27ebdc8cff1ba2673f872ec /src/compiler | |
parent | f8bda81887219d9a56b5427c20be3e63b5c3d136 (diff) |
nir: allow specifying a set of opcodes in lower_alu_to_scalar
This can be used by both etnaviv and freedreno/a2xx as they are both vec4
architectures with some instructions being scalar-only.
Signed-off-by: Jonathan Marek <[email protected]>
Reviewed-by: Christian Gmeiner <[email protected]>
Reviewed-by: Eric Anholt <[email protected]>
Diffstat (limited to 'src/compiler')
-rw-r--r-- | src/compiler/nir/nir.h | 2 | ||||
-rw-r--r-- | src/compiler/nir/nir_lower_alu_to_scalar.c | 15 |
2 files changed, 11 insertions, 6 deletions
diff --git a/src/compiler/nir/nir.h b/src/compiler/nir/nir.h index 301cc76e401..8441c9f26c5 100644 --- a/src/compiler/nir/nir.h +++ b/src/compiler/nir/nir.h @@ -3178,7 +3178,7 @@ bool nir_lower_alu(nir_shader *shader); bool nir_lower_flrp(nir_shader *shader, unsigned lowering_mask, bool always_precise, bool have_ffma); -bool nir_lower_alu_to_scalar(nir_shader *shader); +bool nir_lower_alu_to_scalar(nir_shader *shader, BITSET_WORD *lower_set); bool nir_lower_bool_to_float(nir_shader *shader); bool nir_lower_bool_to_int32(nir_shader *shader); bool nir_lower_int_to_float(nir_shader *shader); diff --git a/src/compiler/nir/nir_lower_alu_to_scalar.c b/src/compiler/nir/nir_lower_alu_to_scalar.c index 9b175878c15..71389c2f0c3 100644 --- a/src/compiler/nir/nir_lower_alu_to_scalar.c +++ b/src/compiler/nir/nir_lower_alu_to_scalar.c @@ -74,7 +74,7 @@ lower_reduction(nir_alu_instr *instr, nir_op chan_op, nir_op merge_op, } static bool -lower_alu_instr_scalar(nir_alu_instr *instr, nir_builder *b) +lower_alu_instr_scalar(nir_alu_instr *instr, nir_builder *b, BITSET_WORD *lower_set) { unsigned num_src = nir_op_infos[instr->op].num_inputs; unsigned i, chan; @@ -85,6 +85,9 @@ lower_alu_instr_scalar(nir_alu_instr *instr, nir_builder *b) b->cursor = nir_before_instr(&instr->instr); b->exact = instr->exact; + if (lower_set && !BITSET_TEST(lower_set, instr->op)) + return false; + #define LOWER_REDUCTION(name, chan, merge) \ case name##2: \ case name##3: \ @@ -254,7 +257,7 @@ lower_alu_instr_scalar(nir_alu_instr *instr, nir_builder *b) } static bool -nir_lower_alu_to_scalar_impl(nir_function_impl *impl) +nir_lower_alu_to_scalar_impl(nir_function_impl *impl, BITSET_WORD *lower_set) { nir_builder builder; nir_builder_init(&builder, impl); @@ -264,7 +267,8 @@ nir_lower_alu_to_scalar_impl(nir_function_impl *impl) nir_foreach_instr_safe(instr, block) { if (instr->type == nir_instr_type_alu) { progress = lower_alu_instr_scalar(nir_instr_as_alu(instr), - &builder) || progress; + &builder, + lower_set) || progress; } } } @@ -276,13 +280,14 @@ nir_lower_alu_to_scalar_impl(nir_function_impl *impl) } bool -nir_lower_alu_to_scalar(nir_shader *shader) +nir_lower_alu_to_scalar(nir_shader *shader, BITSET_WORD *lower_set) { bool progress = false; nir_foreach_function(function, shader) { if (function->impl) - progress = nir_lower_alu_to_scalar_impl(function->impl) || progress; + progress = nir_lower_alu_to_scalar_impl(function->impl, + lower_set) || progress; } return progress; |