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

Author: Ian Romanick <[email protected]>
Date:   Tue May 23 20:55:04 2023 -0700

intel/fs: Allow HF const in MAD on Gfx12.5 if all sources are HF

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 | 26 +++++++++++++++++++------
 1 file changed, 20 insertions(+), 6 deletions(-)

diff --git a/src/intel/compiler/brw_fs_combine_constants.cpp 
b/src/intel/compiler/brw_fs_combine_constants.cpp
index 92f524c0694..41d14faa648 100644
--- a/src/intel/compiler/brw_fs_combine_constants.cpp
+++ b/src/intel/compiler/brw_fs_combine_constants.cpp
@@ -339,13 +339,23 @@ representable_as_uw(unsigned ud, uint16_t *uw)
 }
 
 static bool
-supports_src_as_imm(const struct intel_device_info *devinfo, enum opcode op)
+supports_src_as_imm(const struct intel_device_info *devinfo, const fs_inst 
*inst)
 {
-   switch (op) {
+   if (devinfo->ver < 12)
+      return false;
+
+   switch (inst->opcode) {
    case BRW_OPCODE_ADD3:
-      return devinfo->verx10 >= 125;
+      /* ADD3 only exists on Gfx12.5+. */
+      return true;
+
    case BRW_OPCODE_MAD:
-      return devinfo->ver == 12 && devinfo->verx10 < 125;
+      /* Integer types can always mix sizes. Floating point types can mix
+       * sizes on Gfx12. On Gfx12.5, floating point sources must all be HF or
+       * all be F.
+       */
+      return devinfo->verx10 < 125 || inst->src[0].type != BRW_REGISTER_TYPE_F;
+
    default:
       return false;
    }
@@ -357,11 +367,15 @@ can_promote_src_as_imm(const struct intel_device_info 
*devinfo, fs_inst *inst,
 {
    bool can_promote = false;
 
-   /* Experiment shows that we can only support src0 as immediate */
+   /* Experiment shows that we can only support src0 as immediate for MAD on
+    * Gfx12. ADD3 can use src0 or src2 in Gfx12.5, but constant propagation
+    * only propagates into src0. It's possible that src2 works for W or UW MAD
+    * on Gfx12.5.
+    */
    if (src_idx != 0)
       return false;
 
-   if (!supports_src_as_imm(devinfo, inst->opcode))
+   if (!supports_src_as_imm(devinfo, inst))
       return false;
 
    /* TODO - Fix the codepath below to use a bfloat16 immediate on XeHP,

Reply via email to