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: wide-int, rtl


So, Kenny hopefully resolved or answered your previous email, and the only thing outstanding was the MAX_BITS_PER_UNIT.  That part of the patch is now gone (resolved in a much nicer way in another patch).

So, I'd like to ping the original patch and Kenny's patch to resolve the issues you found.  If you have any other concerns or thoughts, let us know.

Ok?

Index: gcc/cselib.c
===================================================================
--- gcc/cselib.c	(revision 205749)
+++ gcc/cselib.c	(working copy)
@@ -1121,11 +1121,8 @@ cselib_hash_rtx (rtx x, int create, enum
       return hash ? hash : (unsigned int) CONST_INT;
 
     case CONST_WIDE_INT:
-      {
-	int i;
-	for (i = 0; i < CONST_WIDE_INT_NUNITS (x); i++)
-	  hash += CONST_WIDE_INT_ELT (x, i);
-      }
+      for (i = 0; i < CONST_WIDE_INT_NUNITS (x); i++)
+	hash += CONST_WIDE_INT_ELT (x, i);
       return hash;
 
     case CONST_DOUBLE:
Index: gcc/cse.c
===================================================================
--- gcc/cse.c	(revision 205749)
+++ gcc/cse.c	(working copy)
@@ -2337,11 +2337,8 @@ hash_rtx_cb (const_rtx x, enum machine_m
       return hash;
 
     case CONST_WIDE_INT:
-      {
-	int i;
-	for (i = 0; i < CONST_WIDE_INT_NUNITS (x); i++)
-	  hash += CONST_WIDE_INT_ELT (x, i);
-      }
+      for (i = 0; i < CONST_WIDE_INT_NUNITS (x); i++)
+	hash += CONST_WIDE_INT_ELT (x, i);
       return hash;
 
     case CONST_DOUBLE:
Index: gcc/rtl.h
===================================================================
--- gcc/rtl.h	(revision 205749)
+++ gcc/rtl.h	(working copy)
@@ -348,7 +348,10 @@ struct GTY((chain_next ("RTX_NEXT (&%h)"
   unsigned return_val : 1;
 
   union {
-    /* RTXs are free to use up to 32 bit from here.  */
+    /* The final union field is aligned to 64 bits on LP64 hosts,
+       giving a 32-bit gap after the fields above. We optimize the
+       layout for that case and use the gap for extra code-specific
+       information.  */
 
     /* In a CONST_WIDE_INT (aka hwivec_def), this is the number of
        HOST_WIDE_INTs in the hwivec_def.  */
Index: gcc/print-rtl.c
===================================================================
--- gcc/print-rtl.c	(revision 205749)
+++ gcc/print-rtl.c	(working copy)
@@ -619,8 +619,7 @@ print_rtx (const_rtx in_rtx)
       break;
 
     case CONST_WIDE_INT:
-      if (! flag_simple)
-	fprintf (outfile, " ");
+      fprintf (outfile, " ");
       cwi_output_hex (outfile, in_rtx);
       break;
 #endif
Index: gcc/expr.c
===================================================================
--- gcc/expr.c	(revision 205749)
+++ gcc/expr.c	(working copy)
@@ -727,12 +727,11 @@ convert_modes (enum machine_mode mode, e
   if (mode == oldmode)
     return x;
 
-  if (CONST_SCALAR_INT_P (x)
-      && GET_MODE_CLASS (mode) == MODE_INT)
+  if (CONST_SCALAR_INT_P (x) && GET_MODE_CLASS (mode) == MODE_INT)
     {
-      /* If the caller did not tell us the old mode, then there is
-	 not much to do with respect to canonization.  We have to assume
-	 that all the bits are significant.  */
+      /* If the caller did not tell us the old mode, then there is not
+	 much to do with respect to canonicalization.  We have to
+	 assume that all the bits are significant.  */
       if (GET_MODE_CLASS (oldmode) != MODE_INT)
 	oldmode = MAX_MODE_INT;
       wide_int w = wide_int::from (std::make_pair (x, oldmode),
@@ -5295,10 +5294,10 @@ store_expr (tree exp, rtx target, int ca
 			       &alt_rtl);
     }
 
-  /* If TEMP is a VOIDmode constant and the mode of the type of EXP is
-     not the same as that of TARGET, adjust the constant.  This is
-     needed, for example, in case it is a CONST_DOUBLE or
-     CONST_WIDE_INT and we want only a word-sized value.  */
+  /* If TEMP is a VOIDmode constant and the mode of the type of EXP is not
+     the same as that of TARGET, adjust the constant.  This is needed, for
+     example, in case it is a CONST_DOUBLE or CONST_WIDE_INT and we want 
+     only a word-sized value.  */
   if (CONSTANT_P (temp) && GET_MODE (temp) == VOIDmode
       && TREE_CODE (exp) != ERROR_MARK
       && GET_MODE (target) != TYPE_MODE (TREE_TYPE (exp)))
@@ -9477,19 +9476,18 @@ expand_expr_real_1 (tree exp, rtx target
       return decl_rtl;
 
     case INTEGER_CST:
-      {
-	tree type = TREE_TYPE (exp);
-	/* One could argue that GET_MODE_PRECISION (TYPE_MODE (type))
-	   should always be the same as TYPE_PRECISION (type).
-	   However, it is not.  Since we are converting from tree to
-	   rtl, we have to expose this ugly truth here.  */
-	temp = immed_wide_int_const (wide_int::from
-				       (exp,
-					GET_MODE_PRECISION (TYPE_MODE (type)),
-					TYPE_SIGN (type)),
-				     TYPE_MODE (type));
-	return temp;
-      }
+      /* "Given that TYPE_PRECISION (type) is not always equal to
+         GET_MODE_PRECISION (TYPE_MODE (type)), we need to extend from
+         the former to the latter according to the signedness of the
+         type". */
+
+      temp = immed_wide_int_const (wide_int::from
+				   (exp,
+				    GET_MODE_PRECISION (TYPE_MODE (type)),
+				    TYPE_SIGN (type)),
+				   TYPE_MODE (type));
+      return temp;
+
     case VECTOR_CST:
       {
 	tree tmp = NULL_TREE;
@@ -11149,8 +11147,7 @@ const_vector_from_tree (tree exp)
 	RTVEC_ELT (v, i) = CONST_FIXED_FROM_FIXED_VALUE (TREE_FIXED_CST (elt),
 							 inner);
       else
-	RTVEC_ELT (v, i)
-	  = immed_wide_int_const (elt, TYPE_MODE (TREE_TYPE (elt)));
+	RTVEC_ELT (v, i) = immed_wide_int_const (elt, inner);
     }
 
   return gen_rtx_CONST_VECTOR (mode, v);


Attachment: wide-int-rtl.diffs.txt.bz2
Description: BZip2 compressed data


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