From e902dd869635bee3884cfa89cca18e6207168263 Mon Sep 17 00:00:00 2001 From: Rhys Perry Date: Fri, 13 Nov 2020 15:10:58 +0000 Subject: [PATCH] aco: disable omod if the sign of zeros should be preserved The RDNA ISA doc says that omod doesn't preserve -0.0 in 6.2.2. LLVM appears to always disable omod in this situation, but clamp is unaffected. Signed-off-by: Rhys Perry Reviewed-by: Samuel Pitoiset Fixes: df645fa369d ("aco: implement VK_KHR_shader_float_controls") Part-of: --- .pick_status.json | 2 +- src/amd/compiler/aco_optimizer.cpp | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/.pick_status.json b/.pick_status.json index 21e9ef2ba1a..7099de00f18 100644 --- a/.pick_status.json +++ b/.pick_status.json @@ -7546,7 +7546,7 @@ "description": "aco: disable omod if the sign of zeros should be preserved", "nominated": true, "nomination_type": 1, - "resolution": 0, + "resolution": 3, "master_sha": null, "because_sha": "df645fa369d12be4d5e0fd9e4f6d4455caf2f4c3" }, diff --git a/src/amd/compiler/aco_optimizer.cpp b/src/amd/compiler/aco_optimizer.cpp index fba46f6d5ac..62a1cad97e5 100644 --- a/src/amd/compiler/aco_optimizer.cpp +++ b/src/amd/compiler/aco_optimizer.cpp @@ -2539,7 +2539,11 @@ bool apply_omod_clamp(opt_ctx &ctx, Block& block, aco_ptr& instr) /* apply omod / clamp modifiers if the def is used only once and the instruction can have modifiers */ if (!instr->definitions.empty() && ctx.uses[instr->definitions[0].tempId()] == 1 && can_use_VOP3(ctx, instr) && instr_info.can_use_output_modifiers[(int)instr->opcode]) { - bool can_use_omod = (instr->definitions[0].bytes() == 4 ? block.fp_mode.denorm32 : block.fp_mode.denorm16_64) == 0; + bool can_use_omod; + if (instr->definitions[0].bytes() == 4) + can_use_omod = block.fp_mode.denorm32 == 0 && !block.fp_mode.preserve_signed_zero_inf_nan32; + else + can_use_omod = block.fp_mode.denorm16_64 == 0 && !block.fp_mode.preserve_signed_zero_inf_nan16_64; ssa_info& def_info = ctx.info[instr->definitions[0].tempId()]; if (can_use_omod && def_info.is_omod2() && ctx.uses[def_info.temp.id()]) { to_VOP3(ctx, instr);