From 2a420bdf92f595092f47db23e6fa483095acb9c8 Mon Sep 17 00:00:00 2001 From: Iago Toral Quiroga Date: Wed, 19 Jan 2022 09:48:49 +0100 Subject: [PATCH] broadcom/compiler: lower packing after vectorization MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The vectorization pass can inject 32_2x16 (un)packing opcodes upon successful vectorization of 16-bit operations into 32-bit counterparts, so make sure we lower these to something our backend can handle. Reviewed-by: Alejandro PiƱeiro Part-of: --- src/broadcom/compiler/nir_to_vir.c | 9 ++++++++- src/broadcom/vulkan/v3dv_pipeline.c | 3 +++ src/gallium/drivers/v3d/v3d_screen.c | 3 +++ 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/src/broadcom/compiler/nir_to_vir.c b/src/broadcom/compiler/nir_to_vir.c index 3a2465fbe10..01d920cb470 100644 --- a/src/broadcom/compiler/nir_to_vir.c +++ b/src/broadcom/compiler/nir_to_vir.c @@ -1901,7 +1901,14 @@ v3d_optimize_nir(struct v3d_compile *c, struct nir_shader *s) .callback = mem_vectorize_callback, .robust_modes = 0, }; - NIR_PASS(progress, s, nir_opt_load_store_vectorize, &vectorize_opts); + bool vectorize_progress = false; + NIR_PASS(vectorize_progress, s, nir_opt_load_store_vectorize, + &vectorize_opts); + if (vectorize_progress) { + NIR_PASS(progress, s, nir_lower_alu_to_scalar, NULL, NULL); + NIR_PASS(progress, s, nir_lower_pack); + progress = true; + } if (lower_flrp != 0) { bool lower_flrp_progress = false; diff --git a/src/broadcom/vulkan/v3dv_pipeline.c b/src/broadcom/vulkan/v3dv_pipeline.c index 2a7ba0ee34b..10694cc180d 100644 --- a/src/broadcom/vulkan/v3dv_pipeline.c +++ b/src/broadcom/vulkan/v3dv_pipeline.c @@ -215,6 +215,9 @@ const nir_shader_compiler_options v3dv_nir_options = { .lower_unpack_snorm_4x8 = true, .lower_pack_half_2x16 = true, .lower_unpack_half_2x16 = true, + .lower_pack_32_2x16 = true, + .lower_pack_32_2x16_split = true, + .lower_unpack_32_2x16_split = true, /* FIXME: see if we can avoid the uadd_carry and usub_borrow lowering and * get the tests to pass since it might produce slightly better code. */ diff --git a/src/gallium/drivers/v3d/v3d_screen.c b/src/gallium/drivers/v3d/v3d_screen.c index 1864b95be0e..3a9019c070f 100644 --- a/src/gallium/drivers/v3d/v3d_screen.c +++ b/src/gallium/drivers/v3d/v3d_screen.c @@ -705,6 +705,9 @@ static const nir_shader_compiler_options v3d_nir_options = { .lower_unpack_snorm_4x8 = true, .lower_pack_half_2x16 = true, .lower_unpack_half_2x16 = true, + .lower_pack_32_2x16 = true, + .lower_pack_32_2x16_split = true, + .lower_unpack_32_2x16_split = true, .lower_fdiv = true, .lower_find_lsb = true, .lower_ffma16 = true,