From 60c711833ff5302d7085521db8115b59f53cedf6 Mon Sep 17 00:00:00 2001 From: Rhys Perry Date: Fri, 7 Jan 2022 16:13:00 +0000 Subject: [PATCH] aco: remove pack_half_2x16(a, 0) optimization MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This makes the compiler less predictable and should only have a very small effect on performance. fossil-db (Vega): Totals from 2410 (1.79% of 134756) affected shaders: CodeSize: 6911568 -> 6942840 (+0.45%) Fixes Horizon Zero Dawn artifacts. If a shader has: a = pack_half_2x16(a, 0) //rtne store(pack_half_2x16(0, b) | a) //rtne a = unpack_2x16(a).x It will become: store(pack_half_2x16(a, b)) //rtz a = unpack_2x16(pack_half_2x16(a, 0)).x //rtne So a later shader with "unpack_2x16(load()).x" will use "a" rounded to zero, while the previous shader will use "a" rounded to the nearest even. Signed-off-by: Rhys Perry Reviewed-by: Daniel Schürmann Fixes: 2f125908b35 ("radv,aco: lower_pack_half_2x16") Part-of: --- src/amd/compiler/aco_instruction_selection.cpp | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/src/amd/compiler/aco_instruction_selection.cpp b/src/amd/compiler/aco_instruction_selection.cpp index d9e1e1f9c9a..152659618e5 100644 --- a/src/amd/compiler/aco_instruction_selection.cpp +++ b/src/amd/compiler/aco_instruction_selection.cpp @@ -3250,12 +3250,8 @@ visit_alu_instr(isel_context* ctx, nir_alu_instr* instr) case nir_op_pack_32_4x8: bld.copy(Definition(dst), get_alu_src(ctx, instr->src[0], 4)); break; case nir_op_pack_half_2x16_split: { if (dst.regClass() == v1) { - nir_const_value* val = nir_src_as_const_value(instr->src[1].src); - if (val && val->u32 == 0 && ctx->program->chip_class <= GFX9) { - /* upper bits zero on GFX6-GFX9 */ - bld.vop1(aco_opcode::v_cvt_f16_f32, Definition(dst), get_alu_src(ctx, instr->src[0])); - } else if (!ctx->block->fp_mode.care_about_round16_64 || - ctx->block->fp_mode.round16_64 == fp_round_tz) { + if (!ctx->block->fp_mode.care_about_round16_64 || + ctx->block->fp_mode.round16_64 == fp_round_tz) { if (ctx->program->chip_class == GFX8 || ctx->program->chip_class == GFX9) emit_vop3a_instruction(ctx, instr, aco_opcode::v_cvt_pkrtz_f16_f32_e64, dst); else