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]

Another baby step: expr.c don't use TREE_CST_RTL


This patch makes expr.c never look at TREE_CST_RTL.  There are a
couple of potential behavior changes to note:

 * varasm.c used (inaccurately) to think that INTEGER_CST nodes don't
   have a TREE_CST_RTL, so it avoided setting or using them.  No longer.

 * The COMPONENT_REF case of expand_expr thought it was necessary to
   avoid expanding <component_ref <constructor <foo, bar, quux>> 2> to
   <bar> if varasm.c had already emitted the embedded CONSTRUCTOR
   (detected by checking for TREE_CST_RTL != 0 on the constructor).  I
   could find no reason for this constraint, and it was inconsistent
   with the behavior for <array_ref <constructor <foo, bar, quux>> 2>,
   so I just killed that.  No harm done in my testing, but we should
   watch out for trouble.

I also made the control flow between the ARRAY_REF, COMPONENT_REF,
BIT_FIELD_REF, and ARRAY_RANGE_REF cases a bit more explicit, and got
rid of some unnecessary checks of the form of the RTL returned by
output_constant_def.

Bootstrapped i686-linux.

zw

        * expr.c (expand_expr <COMPLEX_CST, STRING_CST>): Always call
        output_constant_def, use its result instead of TREE_CST_RTL (exp).
        Can assume it has the form (mem (symbol_ref ".LCxxx")).
        (expand_expr <COMPONENT_REF>): Can always just extract the
        relevant field of a CONSTRUCTOR.
        (expand_expr <ARRAY_REF, COMPONENT_REF, BIT_FIELD_REF,
        ARRAY_RANGE_REF>): Make control flow explicit.
        * varasm.c (output_constant_def): Can look at TREE_CST_RTL of
        an INTEGER_CST.

===================================================================
Index: expr.c
--- expr.c	26 Apr 2003 11:16:44 -0000	1.527
+++ expr.c	28 Apr 2003 04:03:46 -0000
@@ -6872,22 +6872,19 @@ expand_expr (exp, target, tmode, modifie
 
     case COMPLEX_CST:
     case STRING_CST:
-      if (! TREE_CST_RTL (exp))
-	output_constant_def (exp, 1);
+      temp = output_constant_def (exp, 1);
 
-      /* TREE_CST_RTL probably contains a constant address.
+      /* temp contains a constant address.
 	 On RISC machines where a constant address isn't valid,
 	 make some insns to get that address into a register.  */
-      if (GET_CODE (TREE_CST_RTL (exp)) == MEM
-	  && modifier != EXPAND_CONST_ADDRESS
+      if (modifier != EXPAND_CONST_ADDRESS
 	  && modifier != EXPAND_INITIALIZER
 	  && modifier != EXPAND_SUM
-	  && (! memory_address_p (mode, XEXP (TREE_CST_RTL (exp), 0))
-	      || (flag_force_addr
-		  && GET_CODE (XEXP (TREE_CST_RTL (exp), 0)) != REG)))
-	return replace_equiv_address (TREE_CST_RTL (exp),
-				      copy_rtx (XEXP (TREE_CST_RTL (exp), 0)));
-      return TREE_CST_RTL (exp);
+	  && (! memory_address_p (mode, XEXP (temp, 0))
+	      || flag_force_addr))
+	return replace_equiv_address (temp,
+				      copy_rtx (XEXP (temp, 0)));
+      return temp;
 
     case EXPR_WITH_FILE_LOCATION:
       {
@@ -7300,18 +7297,12 @@ expand_expr (exp, target, tmode, modifie
 	      }
 	  }
       }
-      /* Fall through.  */
+      goto normal_inner_ref;
 
     case COMPONENT_REF:
-    case BIT_FIELD_REF:
-    case ARRAY_RANGE_REF:
       /* If the operand is a CONSTRUCTOR, we can just extract the
-	 appropriate field if it is present.  Don't do this if we have
-	 already written the data since we want to refer to that copy
-	 and varasm.c assumes that's what we'll do.  */
-      if (code == COMPONENT_REF
-	  && TREE_CODE (TREE_OPERAND (exp, 0)) == CONSTRUCTOR
-	  && TREE_CST_RTL (TREE_OPERAND (exp, 0)) == 0)
+	 appropriate field if it is present.  */
+      if (TREE_CODE (TREE_OPERAND (exp, 0)) == CONSTRUCTOR)
 	{
 	  tree elt;
 
@@ -7363,7 +7354,11 @@ expand_expr (exp, target, tmode, modifie
 		return op0;
 	      }
 	}
+      goto normal_inner_ref;
 
+    case BIT_FIELD_REF:
+    case ARRAY_RANGE_REF:
+    normal_inner_ref:
       {
 	enum machine_mode mode1;
 	HOST_WIDE_INT bitsize, bitpos;
===================================================================
Index: varasm.c
--- varasm.c	27 Apr 2003 18:57:50 -0000	1.344
+++ varasm.c	28 Apr 2003 04:03:49 -0000
@@ -2567,7 +2567,7 @@ output_constant_def (exp, defer)
 
   /* We can't just use the saved RTL if this is a deferred string constant
      and we are not to defer anymore.  */
-  if (TREE_CODE (exp) != INTEGER_CST && TREE_CST_RTL (exp)
+  if (TREE_CST_RTL (exp)
       && (defer || !STRING_POOL_ADDRESS_P (XEXP (TREE_CST_RTL (exp), 0))))
     return TREE_CST_RTL (exp);
 


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