Mesa (staging/20.2): aco: disable omod if the sign of zeros should be preserved

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Thu Dec 3 18:46:23 UTC 2020


Module: Mesa
Branch: staging/20.2
Commit: e902dd869635bee3884cfa89cca18e6207168263
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=e902dd869635bee3884cfa89cca18e6207168263

Author: Rhys Perry <pendingchaos02 at gmail.com>
Date:   Fri Nov 13 15:10:58 2020 +0000

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 <pendingchaos02 at gmail.com>
Reviewed-by: Samuel Pitoiset <samuel.pitoiset at gmail.com>
Fixes: df645fa369d ("aco: implement VK_KHR_shader_float_controls")
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/7605>

---

 .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<Instruction>& 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);



More information about the mesa-commit mailing list