Hi,

in the first pre-release HSAIL/BRIG specifications, registers had a type
which they now don't, they only have size.  We have thought about
removing it from our internal representation but it is actually useful
to know what the type of the stored value is when it is actually
necessary to perform conversions.  Nevertheless, we still often create
unnecessary register moves, which however can be avoided by relaxing our
main conversion function like the patch below does.

Thanks,

Martin

2016-08-03  Martin Jambor  <mjam...@suse.cz>

        * hsa-gen.c (get_in_type): Return this if it is a register of
        matching size.
---
 gcc/hsa-gen.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/gcc/hsa-gen.c b/gcc/hsa-gen.c
index ecd6f8a..0e48377 100644
--- a/gcc/hsa-gen.c
+++ b/gcc/hsa-gen.c
@@ -984,6 +984,14 @@ hsa_op_with_type::get_in_type (BrigType16_t dtype, hsa_bb 
*hbb)
       dest = new hsa_op_reg (dtype);
       hbb->append_insn (new hsa_insn_cvt (dest, this));
     }
+  else if (is_a <hsa_op_reg *> (this))
+    {
+      /* In the end, HSA registers do not really have types, only sizes, so if
+        the sizes match, we can use the register directly.  */
+      gcc_checking_assert (hsa_type_bit_size (dtype)
+                          == hsa_type_bit_size (m_type));
+      return this;
+    }
   else
     {
       dest = new hsa_op_reg (m_type);
-- 
2.9.2

Reply via email to