aco: allow to swap operands for some 16-bit float instructions
authorSamuel Pitoiset <samuel.pitoiset@gmail.com>
Thu, 9 Apr 2020 14:41:00 +0000 (16:41 +0200)
committerMarge Bot <eric+marge@anholt.net>
Mon, 15 Jun 2020 18:24:22 +0000 (18:24 +0000)
No fossil-db changes.

Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Reviewed-by: Daniel Schürmann <daniel@schuermann.dev>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/5245>

src/amd/compiler/aco_optimizer.cpp

index 0934a6f3272665fb4ba22ccd6a39cd84e91ed502..5e68e3f3b4328a807589dea96e8090bbc725ccc0 100644 (file)
@@ -509,26 +509,41 @@ bool can_swap_operands(aco_ptr<Instruction>& instr)
       return false;
 
    switch (instr->opcode) {
+   case aco_opcode::v_add_f16:
    case aco_opcode::v_add_f32:
+   case aco_opcode::v_mul_f16:
    case aco_opcode::v_mul_f32:
    case aco_opcode::v_or_b32:
    case aco_opcode::v_and_b32:
    case aco_opcode::v_xor_b32:
+   case aco_opcode::v_max_f16:
    case aco_opcode::v_max_f32:
+   case aco_opcode::v_min_f16:
    case aco_opcode::v_min_f32:
    case aco_opcode::v_max_i32:
    case aco_opcode::v_min_i32:
    case aco_opcode::v_max_u32:
    case aco_opcode::v_min_u32:
+   case aco_opcode::v_cmp_eq_f16:
    case aco_opcode::v_cmp_eq_f32:
+   case aco_opcode::v_cmp_lg_f16:
    case aco_opcode::v_cmp_lg_f32:
       return true;
+   case aco_opcode::v_sub_f16:
+      instr->opcode = aco_opcode::v_subrev_f16;
+      return true;
    case aco_opcode::v_sub_f32:
       instr->opcode = aco_opcode::v_subrev_f32;
       return true;
+   case aco_opcode::v_cmp_lt_f16:
+      instr->opcode = aco_opcode::v_cmp_gt_f16;
+      return true;
    case aco_opcode::v_cmp_lt_f32:
       instr->opcode = aco_opcode::v_cmp_gt_f32;
       return true;
+   case aco_opcode::v_cmp_ge_f16:
+      instr->opcode = aco_opcode::v_cmp_le_f16;
+      return true;
    case aco_opcode::v_cmp_ge_f32:
       instr->opcode = aco_opcode::v_cmp_le_f32;
       return true;