radv, aco: Packed iadd_sat/uadd_sat.
authorGeorg Lehmann <dadschoorse@gmail.com>
Thu, 20 Jan 2022 19:50:15 +0000 (20:50 +0100)
committerMarge Bot <emma+marge@anholt.net>
Mon, 28 Mar 2022 20:02:52 +0000 (20:02 +0000)
Signed-off-by: Georg Lehmann <dadschoorse@gmail.com>
Reviewed-by: Daniel Schürmann <daniel@schuermann.dev>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15421>

src/amd/compiler/aco_instruction_selection.cpp
src/amd/compiler/aco_instruction_selection_setup.cpp
src/amd/vulkan/radv_pipeline.c

index 99be3539ee9ff41c9fe13e17289ad3f79f407676..90bb0a37a25a1b3892a271e8190b849a296dfaa7 100644 (file)
@@ -1823,6 +1823,12 @@ visit_alu_instr(isel_context* ctx, nir_alu_instr* instr)
       break;
    }
    case nir_op_uadd_sat: {
+      if (dst.regClass() == v1 && instr->dest.dest.ssa.bit_size == 16) {
+         Instruction* add_instr =
+            emit_vop3p_instruction(ctx, instr, aco_opcode::v_pk_add_u16, dst);
+         add_instr->vop3p().clamp = 1;
+         break;
+      }
       Temp src0 = get_alu_src(ctx, instr->src[0]);
       Temp src1 = get_alu_src(ctx, instr->src[1]);
       if (dst.regClass() == s1) {
@@ -1901,6 +1907,12 @@ visit_alu_instr(isel_context* ctx, nir_alu_instr* instr)
       break;
    }
    case nir_op_iadd_sat: {
+      if (dst.regClass() == v1 && instr->dest.dest.ssa.bit_size == 16) {
+         Instruction* add_instr =
+            emit_vop3p_instruction(ctx, instr, aco_opcode::v_pk_add_i16, dst);
+         add_instr->vop3p().clamp = 1;
+         break;
+      }
       Temp src0 = get_alu_src(ctx, instr->src[0]);
       Temp src1 = get_alu_src(ctx, instr->src[1]);
       if (dst.regClass() == s1) {
index 6d0efade16be7cfe1c3eb188681ee1250ee48bd8..664fe3a768dc70cc901463b0620c07851d31dda9 100644 (file)
@@ -557,6 +557,8 @@ init_context(isel_context* ctx, nir_shader* shader)
                case nir_op_b2f32:
                case nir_op_mov: break;
                case nir_op_iadd:
+               case nir_op_iadd_sat:
+               case nir_op_uadd_sat:
                case nir_op_isub:
                case nir_op_imul:
                case nir_op_imin:
index 6193323f12881d301036613fd653045fb3a48a4b..bcf6d552a4c45c4f70f2bcd28b6e1b9f9d67487d 100644 (file)
@@ -3667,6 +3667,8 @@ opt_vectorize_callback(const nir_instr *instr, void *_)
    case nir_op_fmin:
    case nir_op_fmax:
    case nir_op_iadd:
+   case nir_op_iadd_sat:
+   case nir_op_uadd_sat:
    case nir_op_isub:
    case nir_op_imul:
    case nir_op_imin: