aco: add a new Operand flag to indicate that is 16-bit
authorSamuel Pitoiset <samuel.pitoiset@gmail.com>
Fri, 6 Nov 2020 07:49:12 +0000 (08:49 +0100)
committerMarge Bot <eric+marge@anholt.net>
Thu, 12 Nov 2020 12:32:26 +0000 (12:32 +0000)
To indicate that the upper 16-bits are always 0 and that optimizing
v_mad_u32_u16 to v_mul_u32_u24 is valid.

Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Reviewed-by: Timur Kristóf <timur.kristof@gmail.com>
Reviewed-by: Rhys Perry <pendingchaos02@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/7425>

src/amd/compiler/aco_builder_h.py
src/amd/compiler/aco_ir.h
src/amd/compiler/aco_print_ir.cpp

index 426f91c..e2b12fb 100644 (file)
@@ -352,6 +352,12 @@ public:
    }
 
 % endfor
+
+   Operand set16bit(Operand op) {
+       op.set16bit(true);
+       return op;
+   }
+
    /* hand-written helpers */
    Temp as_uniform(Op op)
    {
index 39db82c..9ceb24a 100644 (file)
@@ -420,7 +420,7 @@ public:
    constexpr Operand()
       : reg_(PhysReg{128}), isTemp_(false), isFixed_(true), isConstant_(false),
         isKill_(false), isUndef_(true), isFirstKill_(false), constSize(0),
-        isLateKill_(false) {}
+        isLateKill_(false), is16bit_(false) {}
 
    explicit Operand(Temp r) noexcept
    {
@@ -746,6 +746,17 @@ public:
       else
          return other.isTemp() && other.getTemp() == getTemp();
    }
+
+   constexpr void set16bit(bool flag) noexcept
+   {
+      is16bit_ = flag;
+   }
+
+   constexpr bool is16bit() const noexcept
+   {
+      return is16bit_;
+   }
+
 private:
    union {
       uint32_t i;
@@ -763,6 +774,7 @@ private:
          uint8_t isFirstKill_:1;
          uint8_t constSize:2;
          uint8_t isLateKill_:1;
+         uint8_t is16bit_:1;
       };
       /* can't initialize bit-fields in c++11, so work around using a union */
       uint16_t control_ = 0;
index 2a90a0a..e679cef 100644 (file)
@@ -168,6 +168,8 @@ static void print_operand(const Operand *operand, FILE *output)
    } else {
       if (operand->isLateKill())
          fprintf(output, "(latekill)");
+      if (operand->is16bit())
+         fprintf(output, "(is16bit)");
 
       fprintf(output, "%%%d", operand->tempId());