From 558daa73f9adb1275ddcf00515c7f79f726b7ae1 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: --- src/amd/compiler/aco_optimizer.cpp | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/amd/compiler/aco_optimizer.cpp b/src/amd/compiler/aco_optimizer.cpp index 01dcafdcb44..62567941541 100644 --- a/src/amd/compiler/aco_optimizer.cpp +++ b/src/amd/compiler/aco_optimizer.cpp @@ -2606,9 +2606,14 @@ bool apply_omod_clamp(opt_ctx &ctx, Block& block, aco_ptr& instr) if (!instr->isSDWA() && !can_vop3) return false; - /* omod has no effect if denormals are enabled */ - bool can_use_omod = (instr->definitions[0].bytes() == 4 ? block.fp_mode.denorm32 : block.fp_mode.denorm16_64) == 0; - can_use_omod = can_use_omod && (can_vop3 || ctx.program->chip_class >= GFX9); /* SDWA omod is GFX9+ */ + /* omod flushes -0 to +0 and has no effect if denormals are enabled */ + bool can_use_omod = (can_vop3 || ctx.program->chip_class >= GFX9); /* SDWA omod is GFX9+ */ + if (instr->definitions[0].bytes() == 4) + can_use_omod = can_use_omod && block.fp_mode.denorm32 == 0 && + !block.fp_mode.preserve_signed_zero_inf_nan32; + else + can_use_omod = 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()];