diff mbox

wide-int, rtl

Message ID 20CE4C78-00CC-410E-98AB-A454B37E0FC9@comcast.net
State New
Headers show

Commit Message

Mike Stump Jan. 2, 2014, 10:19 p.m. UTC
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?

Comments

Eric Botcazou Jan. 2, 2014, 10:26 p.m. UTC | #1
> 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.

Almost OK, but remove the strange quotes in the comment for the INTEGER_CST 
case of expand_expr_real_1 (and optionally add the fast path for the common 
case written down by Richard).
Kenneth Zadeck Jan. 2, 2014, 10:44 p.m. UTC | #2
On 01/02/2014 05:26 PM, Eric Botcazou wrote:
>> 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.
> Almost OK, but remove the strange quotes in the comment for the INTEGER_CST
> case of expand_expr_real_1 (and optionally add the fast path for the common
> case written down by Richard).
>
eric,

the fast path is not any faster.   that was why we did not do it. And by 
the time you add the tests it would be slower.    The thing is that on 
the inside of the so called fast path, you are still converting the tree 
to wide-int first and that conversion still is checking the rest of 
these things.

the quotes will be removed before committing.

kenny
Eric Botcazou Jan. 5, 2014, 9:39 a.m. UTC | #3
> the fast path is not any faster.   that was why we did not do it. And by
> the time you add the tests it would be slower.    The thing is that on
> the inside of the so called fast path, you are still converting the tree
> to wide-int first and that conversion still is checking the rest of
> these things.

OK, thanks for the explanation.
diff mbox

Patch

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);