diff --git a/src/amd/vulkan/radv_pipeline.c b/src/amd/vulkan/radv_pipeline.c index 28c0dbd8928..4077aaed7fa 100644 --- a/src/amd/vulkan/radv_pipeline.c +++ b/src/amd/vulkan/radv_pipeline.c @@ -416,7 +416,7 @@ radv_postprocess_nir(struct radv_device *device, const struct radv_graphics_stat NIR_PASS(_, stage->nir, nir_lower_alu_width, opt_vectorize_callback, device); - nir_move_options sink_opts = nir_move_const_undef | nir_move_copies; + nir_move_options sink_opts = nir_move_const_undef | nir_move_copies | nir_dont_move_byte_word_vecs; if (!stage->key.optimisations_disabled) { NIR_PASS(_, stage->nir, nir_opt_licm); @@ -424,7 +424,7 @@ radv_postprocess_nir(struct radv_device *device, const struct radv_graphics_stat sink_opts |= nir_move_load_input; NIR_PASS(_, stage->nir, nir_opt_sink, sink_opts); - NIR_PASS(_, stage->nir, nir_opt_move, nir_move_load_input | nir_move_const_undef | nir_move_copies); + NIR_PASS(_, stage->nir, nir_opt_move, sink_opts | nir_move_load_input); } /* Lower VS inputs. We need to do this after nir_opt_sink, because @@ -625,7 +625,7 @@ radv_postprocess_nir(struct radv_device *device, const struct radv_graphics_stat NIR_PASS(_, stage->nir, nir_opt_sink, sink_opts); nir_move_options move_opts = nir_move_const_undef | nir_move_load_ubo | nir_move_load_input | - nir_move_comparisons | nir_move_copies | nir_move_alu; + nir_move_comparisons | nir_move_copies | nir_dont_move_byte_word_vecs | nir_move_alu; NIR_PASS(_, stage->nir, nir_opt_move, move_opts); /* Run nir_opt_move again to make sure that comparision are as close as possible to the first use to prevent SCC diff --git a/src/compiler/nir/nir.h b/src/compiler/nir/nir.h index 04476ecc932..3947faa2ea2 100644 --- a/src/compiler/nir/nir.h +++ b/src/compiler/nir/nir.h @@ -6148,6 +6148,7 @@ typedef enum { nir_move_load_ssbo = (1 << 5), nir_move_load_uniform = (1 << 6), nir_move_alu = (1 << 7), + nir_dont_move_byte_word_vecs = (1 << 8), } nir_move_options; bool nir_can_move_instr(nir_instr *instr, nir_move_options options); diff --git a/src/compiler/nir/nir_opt_sink.c b/src/compiler/nir/nir_opt_sink.c index 28db929c5bb..5715c1cd118 100644 --- a/src/compiler/nir/nir_opt_sink.c +++ b/src/compiler/nir/nir_opt_sink.c @@ -70,8 +70,13 @@ can_sink_instr(nir_instr *instr, nir_move_options options, bool *can_mov_out_of_ case nir_instr_type_alu: { nir_alu_instr *alu = nir_instr_as_alu(instr); - if (nir_op_is_vec_or_mov(alu->op) || alu->op == nir_op_b2i32) + if (nir_op_is_vec_or_mov(alu->op) || alu->op == nir_op_b2i32) { + if (nir_op_is_vec(alu->op) && alu->def.bit_size < 32 && + (options & nir_dont_move_byte_word_vecs)) { + return false; + } return options & nir_move_copies; + } if (nir_alu_instr_is_comparison(alu)) return options & nir_move_comparisons;