Module: Mesa
Branch: main
Commit: 4f272bf001dec66d79511fc58f9f48e79ecd5fed
URL:    
http://cgit.freedesktop.org/mesa/mesa/commit/?id=4f272bf001dec66d79511fc58f9f48e79ecd5fed

Author: Ian Romanick <[email protected]>
Date:   Tue May 23 18:34:43 2023 -0700

intel/fs: Fix handling of W, UW, and HF constants in combine_constants

Sources that are already W, UW, or HF can be represented as those types
by definition. Pass them through. Previously an HF source on a MAD would
have been marked as !can_promote. I'm pretty sure this means it would
get moved out to a register, but I did not verify this.

For ADD3, a constant source could be D or UD. In this case, the value
must be tested to determine whether it can be represented as W or
UW. The patterns in opt_algebraic won't generate an ADD3 with constant
source, so this problem cannot occur yet.

Reviewed-by: Matt Turner <[email protected]>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/23262>

---

 src/intel/compiler/brw_fs_combine_constants.cpp | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/src/intel/compiler/brw_fs_combine_constants.cpp 
b/src/intel/compiler/brw_fs_combine_constants.cpp
index c73e38bde34..92f524c0694 100644
--- a/src/intel/compiler/brw_fs_combine_constants.cpp
+++ b/src/intel/compiler/brw_fs_combine_constants.cpp
@@ -376,7 +376,7 @@ can_promote_src_as_imm(const struct intel_device_info 
*devinfo, fs_inst *inst,
       }
       break;
    }
-   case BRW_REGISTER_TYPE_W: {
+   case BRW_REGISTER_TYPE_D: {
       int16_t w;
       if (representable_as_w(inst->src[src_idx].d, &w)) {
          inst->src[src_idx] = brw_imm_w(w);
@@ -384,7 +384,7 @@ can_promote_src_as_imm(const struct intel_device_info 
*devinfo, fs_inst *inst,
       }
       break;
    }
-   case BRW_REGISTER_TYPE_UW: {
+   case BRW_REGISTER_TYPE_UD: {
       uint16_t uw;
       if (representable_as_uw(inst->src[src_idx].ud, &uw)) {
          inst->src[src_idx] = brw_imm_uw(uw);
@@ -392,6 +392,11 @@ can_promote_src_as_imm(const struct intel_device_info 
*devinfo, fs_inst *inst,
       }
       break;
    }
+   case BRW_REGISTER_TYPE_W:
+   case BRW_REGISTER_TYPE_UW:
+   case BRW_REGISTER_TYPE_HF:
+      can_promote = true;
+      break;
    default:
       break;
    }

Reply via email to