]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
Add commentary to (SET_)TYPE_VECTOR_SUBPARTS
authorrsandifo <rsandifo@138bc75d-0d04-0410-961f-82ee72b054a4>
Fri, 26 Apr 2019 09:59:31 +0000 (09:59 +0000)
committerrsandifo <rsandifo@138bc75d-0d04-0410-961f-82ee72b054a4>
Fri, 26 Apr 2019 09:59:31 +0000 (09:59 +0000)
2019-04-26  Richard Sandiford  <richard.sandiford@arm.com>

gcc/
* tree.h (TYPE_VECTOR_SUBPARTS, SET_TYPE_VECTOR_SUBPARTS): Add
commentary about the encoding of precision.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@270593 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/ChangeLog
gcc/tree.h

index 3a927ed00d32bcf13393ace1c40b09d6961b4772..3330d1c8905f3521215c49f5aa6885ffe3e93dbd 100644 (file)
@@ -1,3 +1,8 @@
+2019-04-26  Richard Sandiford  <richard.sandiford@arm.com>
+
+       * tree.h (TYPE_VECTOR_SUBPARTS, SET_TYPE_VECTOR_SUBPARTS): Add
+       commentary about the encoding of precision.
+
 2019-04-25  Andreas Tobler  <andreast@gcc.gnu.org>
 
        * config/i386/freebsd64.h: Add bits for 32-bit multilib support.
index 2f2f109451a1125d5ee95922659c04ed111ab544..f03008244359295806616c44fc695b766ed6e74a 100644 (file)
@@ -3734,6 +3734,8 @@ TYPE_VECTOR_SUBPARTS (const_tree node)
   unsigned int precision = VECTOR_TYPE_CHECK (node)->type_common.precision;
   if (NUM_POLY_INT_COEFFS == 2)
     {
+      /* See the corresponding code in SET_TYPE_VECTOR_SUBPARTS for a
+        description of the encoding.  */
       poly_uint64 res = 0;
       res.coeffs[0] = HOST_WIDE_INT_1U << (precision & 0xff);
       if (precision & 0x100)
@@ -3756,6 +3758,21 @@ SET_TYPE_VECTOR_SUBPARTS (tree node, poly_uint64 subparts)
   gcc_assert (index >= 0);
   if (NUM_POLY_INT_COEFFS == 2)
     {
+      /* We have two coefficients that are each in the range 1 << [0, 63],
+        so supporting all combinations would require 6 bits per coefficient
+        and 12 bits in total.  Since the precision field is only 10 bits
+        in size, we need to be more restrictive than that.
+
+        At present, coeff[1] is always either 0 (meaning that the number
+        of units is constant) or equal to coeff[0] (meaning that the number
+        of units is N + X * N for some target-dependent zero-based runtime
+        parameter X).  We can therefore encode coeff[1] in a single bit.
+
+        The most compact encoding would be to use mask 0x3f for coeff[0]
+        and 0x40 for coeff[1], leaving 0x380 unused.  It's possible to
+        get slightly more efficient code on some hosts if we instead
+        treat the shift amount as an independent byte, so here we use
+        0xff for coeff[0] and 0x100 for coeff[1].  */
       unsigned HOST_WIDE_INT coeff1 = subparts.coeffs[1];
       gcc_assert (coeff1 == 0 || coeff1 == coeff0);
       VECTOR_TYPE_CHECK (node)->type_common.precision