]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
[hsa] Satisfy conditional move operand type constrains
authorMartin Jambor <mjambor@suse.cz>
Fri, 26 Feb 2016 17:42:06 +0000 (18:42 +0100)
committerMartin Jambor <jamborm@gcc.gnu.org>
Fri, 26 Feb 2016 17:42:06 +0000 (18:42 +0100)
2016-02-26  Martin Jambor  <mjambor@suse.cz>

* hsa.h (is_a_helper): New overload for hsa_op_immed for
hsa_op_with_type operands.
(hsa_unsigned_type_for_type): Declare.
* hsa.c (hsa_unsigned_type_for_type): New function.
* hsa-gen.c (gen_hsa_binary_operation): Use hsa_unsigned_type_for_type.
(gen_hsa_insns_for_operation_assignment): Satisfy constrains of
the finalizer.  Do not emit extra move.

From-SVN: r233749

gcc/ChangeLog
gcc/hsa-gen.c
gcc/hsa.c
gcc/hsa.h

index de2189a84078e82a7900130009d7e9a254f4c5d9..bf03f181b164f7319f1759f15120415a219d1677 100644 (file)
@@ -1,3 +1,13 @@
+2016-02-26  Martin Jambor  <mjambor@suse.cz>
+
+       * hsa.h (is_a_helper): New overload for hsa_op_immed for
+       hsa_op_with_type operands.
+       (hsa_unsigned_type_for_type): Declare.
+       * hsa.c (hsa_unsigned_type_for_type): New function.
+       * hsa-gen.c (gen_hsa_binary_operation): Use hsa_unsigned_type_for_type.
+       (gen_hsa_insns_for_operation_assignment): Satisfy constrains of
+       the finalizer.  Do not emit extra move.
+
 2016-02-26  Martin Jambor  <mjambor@suse.cz>
 
        * hsa-gen.c (gen_hsa_ternary_atomic_for_builtin): Fail in presence of
index 7a7ec41ab8011124fc4331b408ca674287f570e4..be402ddda71e034032892da35a67b6a37e2bdb63 100644 (file)
@@ -3022,7 +3022,7 @@ gen_hsa_binary_operation (int opcode, hsa_op_reg *dest,
       && is_a <hsa_op_immed *> (op2))
     {
       hsa_op_immed *i = dyn_cast <hsa_op_immed *> (op2);
-      i->set_type (hsa_uint_for_bitsize (hsa_type_bit_size (i->m_type)));
+      i->set_type (hsa_unsigned_type_for_type (i->m_type));
     }
 
   hsa_insn_basic *insn = new hsa_insn_basic (3, opcode, dest->m_type, dest,
@@ -3233,27 +3233,21 @@ gen_hsa_insns_for_operation_assignment (gimple *assign, hsa_bb *hbb)
            ctrl = r;
          }
 
-       hsa_op_with_type *rhs2_reg = hsa_reg_or_immed_for_gimple_op (rhs2, hbb);
-       hsa_op_with_type *rhs3_reg = hsa_reg_or_immed_for_gimple_op (rhs3, hbb);
-
-       BrigType16_t btype = hsa_bittype_for_type (dest->m_type);
-       hsa_op_reg *tmp = new hsa_op_reg (btype);
+       hsa_op_with_type *op2 = hsa_reg_or_immed_for_gimple_op (rhs2, hbb);
+       hsa_op_with_type *op3 = hsa_reg_or_immed_for_gimple_op (rhs3, hbb);
 
-       rhs2_reg->m_type = btype;
-       rhs3_reg->m_type = btype;
+       BrigType16_t utype = hsa_unsigned_type_for_type (dest->m_type);
+       if (is_a <hsa_op_immed *> (op2))
+         op2->m_type = utype;
+       if (is_a <hsa_op_immed *> (op3))
+         op3->m_type = utype;
 
        hsa_insn_basic *insn
-         = new hsa_insn_basic (4, BRIG_OPCODE_CMOV, tmp->m_type, tmp, ctrl,
-                               rhs2_reg, rhs3_reg);
+         = new hsa_insn_basic (4, BRIG_OPCODE_CMOV,
+                               hsa_bittype_for_type (dest->m_type),
+                               dest, ctrl, op2, op3);
 
        hbb->append_insn (insn);
-
-       /* As operands of a CMOV insn must be Bx types, we have to emit
-          a conversion insn.  */
-       hsa_insn_basic *mov = new hsa_insn_basic (2, BRIG_OPCODE_MOV,
-                                                 dest->m_type, dest, tmp);
-       hbb->append_insn (mov);
-
        return;
       }
     case COMPLEX_EXPR:
index f0b320573bff24eecd36fcaecbefcab1a8e899b7..9537e295cb52935d9f792e10a19eb52059dae4fc 100644 (file)
--- a/gcc/hsa.c
+++ b/gcc/hsa.c
@@ -472,6 +472,14 @@ hsa_bittype_for_type (BrigType16_t t)
   return hsa_bittype_for_bitsize (hsa_type_bit_size (t));
 }
 
+/* Return HSA unsigned integer type with the same size as the type T.  */
+
+BrigType16_t
+hsa_unsigned_type_for_type (BrigType16_t t)
+{
+  return hsa_uint_for_bitsize (hsa_type_bit_size (t));
+}
+
 /* Return true if and only if TYPE is a floating point number type.  */
 
 bool
index f0436f3cf69190ecdf5680b869cdbcc5d626f3ee..275a954f88dee5bd373070dc3ecf1bbe8603b207 100644 (file)
--- a/gcc/hsa.h
+++ b/gcc/hsa.h
@@ -199,6 +199,17 @@ is_a_helper <hsa_op_immed *>::test (hsa_op_base *p)
   return p->m_kind == BRIG_KIND_OPERAND_CONSTANT_BYTES;
 }
 
+/* Likewise, but for a more specified base. */
+
+template <>
+template <>
+inline bool
+is_a_helper <hsa_op_immed *>::test (hsa_op_with_type *p)
+{
+  return p->m_kind == BRIG_KIND_OPERAND_CONSTANT_BYTES;
+}
+
+
 /* HSA register operand.  */
 
 class hsa_op_reg : public hsa_op_with_type
@@ -1326,6 +1337,7 @@ BrigType16_t hsa_bittype_for_bitsize (unsigned bitsize);
 BrigType16_t hsa_uint_for_bitsize (unsigned bitsize);
 BrigType16_t hsa_float_for_bitsize (unsigned bitsize);
 BrigType16_t hsa_bittype_for_type (BrigType16_t t);
+BrigType16_t hsa_unsigned_type_for_type (BrigType16_t t);
 bool hsa_type_float_p (BrigType16_t type);
 bool hsa_type_integer_p (BrigType16_t type);
 bool hsa_btype_p (BrigType16_t type);