This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: patch to canonize unsigned tree-csts


On 10/15/2013 02:30 PM, Richard Sandiford wrote:
Richard Sandiford <rdsandiford@googlemail.com> writes:
       if (small_prec)
         ;
       else if (precision == xprecision)
         while (len >= 0 && val[len - 1] == -1)
           len--;
Err, len > 0 obviously.
you were only close. patch tested on ppc and committed as revision 203739.

Index: gcc/tree.c
===================================================================
--- gcc/tree.c  (revision 203701)
+++ gcc/tree.c  (working copy)
@@ -1204,7 +1204,7 @@ wide_int_to_tree (tree type, const wide_
     }

   wide_int cst = wide_int::from (pcst, prec, sgn);
-  unsigned int len = int (cst.get_len ());
+  unsigned int len = cst.get_len ();
   unsigned int small_prec = prec & (HOST_BITS_PER_WIDE_INT - 1);
   bool recanonize = sgn == UNSIGNED
     && small_prec
Index: gcc/tree.h
===================================================================
--- gcc/tree.h  (revision 203701)
+++ gcc/tree.h  (working copy)
@@ -5204,13 +5204,13 @@ wi::int_traits <const_tree>::decompose (
              scratch[len - 1] = sext_hwi (val[len - 1], precision);
              return wi::storage_ref (scratch, len, precision);
            }
-       }
-
-      if (precision < xprecision + HOST_BITS_PER_WIDE_INT)
-       {
- len = wi::force_to_size (scratch, val, len, xprecision, precision, UNS
IGNED);
-         return wi::storage_ref (scratch, len, precision);
-       }
+       }
+      /* We have to futz here because a large unsigned int with
+        precision 128 may look (0x0 0xFFFFFFFFFFFFFFFF 0xF...) as a
+        tree-cst and as (0xF...) as a wide-int.  */
+      else if (precision == xprecision && len == max_len)
+        while (len > 1 && val[len - 1] == (HOST_WIDE_INT)-1)
+          len--;
     }

   /* Signed and the rest of the unsigned cases are easy.  */


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]