diff options
-rw-r--r-- | src/amd/vulkan/radv_shader.c | 2 | ||||
-rw-r--r-- | src/broadcom/compiler/nir_to_vir.c | 2 | ||||
-rw-r--r-- | src/compiler/nir/nir.h | 2 | ||||
-rw-r--r-- | src/compiler/nir/nir_lower_alu_to_scalar.c | 15 | ||||
-rw-r--r-- | src/freedreno/ir3/ir3_nir.c | 2 | ||||
-rw-r--r-- | src/gallium/auxiliary/nir/tgsi_to_nir.c | 2 | ||||
-rw-r--r-- | src/gallium/drivers/lima/lima_program.c | 4 | ||||
-rw-r--r-- | src/gallium/drivers/nouveau/codegen/nv50_ir_from_nir.cpp | 2 | ||||
-rw-r--r-- | src/gallium/drivers/radeonsi/si_shader_nir.c | 2 | ||||
-rw-r--r-- | src/gallium/drivers/vc4/vc4_program.c | 2 | ||||
-rw-r--r-- | src/intel/compiler/brw_nir.c | 4 | ||||
-rw-r--r-- | src/mesa/state_tracker/st_glsl_to_nir.cpp | 4 |
12 files changed, 24 insertions, 19 deletions
diff --git a/src/amd/vulkan/radv_shader.c b/src/amd/vulkan/radv_shader.c index f60daf6d03d..17d6c5bc33a 100644 --- a/src/amd/vulkan/radv_shader.c +++ b/src/amd/vulkan/radv_shader.c @@ -150,7 +150,7 @@ radv_optimize_nir(struct nir_shader *shader, bool optimize_conservatively, NIR_PASS(progress, shader, nir_opt_copy_prop_vars); NIR_PASS(progress, shader, nir_opt_dead_write_vars); - NIR_PASS_V(shader, nir_lower_alu_to_scalar); + NIR_PASS_V(shader, nir_lower_alu_to_scalar, NULL); NIR_PASS_V(shader, nir_lower_phis_to_scalar); NIR_PASS(progress, shader, nir_copy_prop); diff --git a/src/broadcom/compiler/nir_to_vir.c b/src/broadcom/compiler/nir_to_vir.c index 67747b14bb0..f392d431a4d 100644 --- a/src/broadcom/compiler/nir_to_vir.c +++ b/src/broadcom/compiler/nir_to_vir.c @@ -1310,7 +1310,7 @@ v3d_optimize_nir(struct nir_shader *s) progress = false; NIR_PASS_V(s, nir_lower_vars_to_ssa); - NIR_PASS(progress, s, nir_lower_alu_to_scalar); + NIR_PASS(progress, s, nir_lower_alu_to_scalar, NULL); NIR_PASS(progress, s, nir_lower_phis_to_scalar); NIR_PASS(progress, s, nir_copy_prop); NIR_PASS(progress, s, nir_opt_remove_phis); 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; diff --git a/src/freedreno/ir3/ir3_nir.c b/src/freedreno/ir3/ir3_nir.c index c692274d8e3..8d2eef94e57 100644 --- a/src/freedreno/ir3/ir3_nir.c +++ b/src/freedreno/ir3/ir3_nir.c @@ -126,7 +126,7 @@ ir3_optimize_loop(nir_shader *s) OPT_V(s, nir_lower_vars_to_ssa); progress |= OPT(s, nir_opt_copy_prop_vars); progress |= OPT(s, nir_opt_dead_write_vars); - progress |= OPT(s, nir_lower_alu_to_scalar); + progress |= OPT(s, nir_lower_alu_to_scalar, NULL); progress |= OPT(s, nir_lower_phis_to_scalar); progress |= OPT(s, nir_copy_prop); diff --git a/src/gallium/auxiliary/nir/tgsi_to_nir.c b/src/gallium/auxiliary/nir/tgsi_to_nir.c index c55e8b84a41..aa9321f2be4 100644 --- a/src/gallium/auxiliary/nir/tgsi_to_nir.c +++ b/src/gallium/auxiliary/nir/tgsi_to_nir.c @@ -2050,7 +2050,7 @@ ttn_optimize_nir(nir_shader *nir, bool scalar) NIR_PASS_V(nir, nir_lower_vars_to_ssa); if (scalar) { - NIR_PASS_V(nir, nir_lower_alu_to_scalar); + NIR_PASS_V(nir, nir_lower_alu_to_scalar, NULL); NIR_PASS_V(nir, nir_lower_phis_to_scalar); } diff --git a/src/gallium/drivers/lima/lima_program.c b/src/gallium/drivers/lima/lima_program.c index e56912d8e21..08bedb1dd32 100644 --- a/src/gallium/drivers/lima/lima_program.c +++ b/src/gallium/drivers/lima/lima_program.c @@ -97,7 +97,7 @@ lima_program_optimize_vs_nir(struct nir_shader *s) progress = false; NIR_PASS_V(s, nir_lower_vars_to_ssa); - NIR_PASS(progress, s, nir_lower_alu_to_scalar); + NIR_PASS(progress, s, nir_lower_alu_to_scalar, NULL); NIR_PASS(progress, s, nir_lower_phis_to_scalar); NIR_PASS(progress, s, nir_copy_prop); NIR_PASS(progress, s, nir_opt_remove_phis); @@ -135,7 +135,7 @@ lima_program_optimize_fs_nir(struct nir_shader *s) progress = false; NIR_PASS_V(s, nir_lower_vars_to_ssa); - //NIR_PASS(progress, s, nir_lower_alu_to_scalar); + //NIR_PASS(progress, s, nir_lower_alu_to_scalar, NULL); NIR_PASS(progress, s, nir_lower_phis_to_scalar); NIR_PASS(progress, s, nir_copy_prop); NIR_PASS(progress, s, nir_opt_remove_phis); diff --git a/src/gallium/drivers/nouveau/codegen/nv50_ir_from_nir.cpp b/src/gallium/drivers/nouveau/codegen/nv50_ir_from_nir.cpp index 27381ee5ea6..02ae5d73b99 100644 --- a/src/gallium/drivers/nouveau/codegen/nv50_ir_from_nir.cpp +++ b/src/gallium/drivers/nouveau/codegen/nv50_ir_from_nir.cpp @@ -3437,7 +3437,7 @@ Converter::run() NIR_PASS_V(nir, nir_lower_regs_to_ssa); NIR_PASS_V(nir, nir_lower_load_const_to_scalar); NIR_PASS_V(nir, nir_lower_vars_to_ssa); - NIR_PASS_V(nir, nir_lower_alu_to_scalar); + NIR_PASS_V(nir, nir_lower_alu_to_scalar, NULL); NIR_PASS_V(nir, nir_lower_phis_to_scalar); do { diff --git a/src/gallium/drivers/radeonsi/si_shader_nir.c b/src/gallium/drivers/radeonsi/si_shader_nir.c index 8468ae90dde..10e72fd9f4d 100644 --- a/src/gallium/drivers/radeonsi/si_shader_nir.c +++ b/src/gallium/drivers/radeonsi/si_shader_nir.c @@ -828,7 +828,7 @@ si_nir_opts(struct nir_shader *nir) NIR_PASS(progress, nir, nir_opt_copy_prop_vars); NIR_PASS(progress, nir, nir_opt_dead_write_vars); - NIR_PASS_V(nir, nir_lower_alu_to_scalar); + NIR_PASS_V(nir, nir_lower_alu_to_scalar, NULL); NIR_PASS_V(nir, nir_lower_phis_to_scalar); /* (Constant) copy propagation is needed for txf with offsets. */ diff --git a/src/gallium/drivers/vc4/vc4_program.c b/src/gallium/drivers/vc4/vc4_program.c index 456af3a33d2..ca94619826f 100644 --- a/src/gallium/drivers/vc4/vc4_program.c +++ b/src/gallium/drivers/vc4/vc4_program.c @@ -1536,7 +1536,7 @@ vc4_optimize_nir(struct nir_shader *s) progress = false; NIR_PASS_V(s, nir_lower_vars_to_ssa); - NIR_PASS(progress, s, nir_lower_alu_to_scalar); + NIR_PASS(progress, s, nir_lower_alu_to_scalar, NULL); NIR_PASS(progress, s, nir_lower_phis_to_scalar); NIR_PASS(progress, s, nir_copy_prop); NIR_PASS(progress, s, nir_opt_remove_phis); diff --git a/src/intel/compiler/brw_nir.c b/src/intel/compiler/brw_nir.c index e1f5b28d874..a057f286ea8 100644 --- a/src/intel/compiler/brw_nir.c +++ b/src/intel/compiler/brw_nir.c @@ -561,7 +561,7 @@ brw_nir_optimize(nir_shader *nir, const struct brw_compiler *compiler, OPT(nir_opt_combine_stores, nir_var_all); if (is_scalar) { - OPT(nir_lower_alu_to_scalar); + OPT(nir_lower_alu_to_scalar, NULL); } OPT(nir_copy_prop); @@ -701,7 +701,7 @@ brw_preprocess_nir(const struct brw_compiler *compiler, nir_shader *nir, const bool is_scalar = compiler->scalar_stage[nir->info.stage]; if (is_scalar) { - OPT(nir_lower_alu_to_scalar); + OPT(nir_lower_alu_to_scalar, NULL); } if (nir->info.stage == MESA_SHADER_GEOMETRY) diff --git a/src/mesa/state_tracker/st_glsl_to_nir.cpp b/src/mesa/state_tracker/st_glsl_to_nir.cpp index 57064251313..a87284ef2a7 100644 --- a/src/mesa/state_tracker/st_glsl_to_nir.cpp +++ b/src/mesa/state_tracker/st_glsl_to_nir.cpp @@ -315,7 +315,7 @@ st_nir_opts(nir_shader *nir, bool scalar) NIR_PASS_V(nir, nir_lower_vars_to_ssa); if (scalar) { - NIR_PASS_V(nir, nir_lower_alu_to_scalar); + NIR_PASS_V(nir, nir_lower_alu_to_scalar, NULL); NIR_PASS_V(nir, nir_lower_phis_to_scalar); } @@ -431,7 +431,7 @@ st_glsl_to_nir(struct st_context *st, struct gl_program *prog, NIR_PASS_V(nir, nir_lower_var_copies); if (is_scalar) { - NIR_PASS_V(nir, nir_lower_alu_to_scalar); + NIR_PASS_V(nir, nir_lower_alu_to_scalar, NULL); } /* before buffers and vars_to_ssa */ |