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]

[PATCH] Inline handled_component_p


This makes handled_component_p an inline function in tree.h and
re-orders the tree code it tests for into a single group so the
inline function should optimize to a single range test.
handled_component_p is excercised quite heavily with the alias
oracle now, though I do not expect this to make a measurable
difference in compile-time.

I'll bootstrap and test this and will commit it unless somebody
complains loudly.

Thanks,
Richard.

2009-04-16  Richard Guenther  <rguenther@suse.de>

	* expr.c (handled_component_p): Move ...
	* tree.h (handled_component_p): ... here.
	* tree.def: Re-order BIT_FIELD_REF, COMPONENT_REF,
	ARRAY_REF, ARRAY_RANGE_REF, VIEW_CONVERT_EXPR, IMAGPART_EXPR
	and REALPART_EXPR to be in one group.

Index: trunk/gcc/expr.c
===================================================================
*** trunk.orig/gcc/expr.c	2009-04-09 15:05:02.000000000 +0200
--- trunk/gcc/expr.c	2009-04-16 12:19:01.000000000 +0200
*************** component_ref_field_offset (tree exp)
*** 6199,6225 ****
    else
      return SUBSTITUTE_PLACEHOLDER_IN_EXPR (DECL_FIELD_OFFSET (field), exp);
  }
- 
- /* Return 1 if T is an expression that get_inner_reference handles.  */
- 
- int
- handled_component_p (const_tree t)
- {
-   switch (TREE_CODE (t))
-     {
-     case BIT_FIELD_REF:
-     case COMPONENT_REF:
-     case ARRAY_REF:
-     case ARRAY_RANGE_REF:
-     case VIEW_CONVERT_EXPR:
-     case REALPART_EXPR:
-     case IMAGPART_EXPR:
-       return 1;
- 
-     default:
-       return 0;
-     }
- }
  
  /* Given an rtx VALUE that may contain additions and multiplications, return
     an equivalent value that just refers to a register, memory, or constant.
--- 6199,6204 ----
Index: trunk/gcc/tree.def
===================================================================
*** trunk.orig/gcc/tree.def	2009-04-03 12:56:20.000000000 +0200
--- trunk/gcc/tree.def	2009-04-16 12:21:01.000000000 +0200
*************** DEFTREECODE (TRANSLATION_UNIT_DECL, "tra
*** 383,388 ****
--- 383,391 ----
  
  /* References to storage.  */
  
+ /* The ordering of the following codes is optimized for the classification
+    in handled_component_p.  Keep them in a consecutive group.  */
+ 
  /* Value is structure or union component.
     Operand 0 is the structure or union (an expression).
     Operand 1 is the field (a node of type FIELD_DECL).
*************** DEFTREECODE (COMPONENT_REF, "component_r
*** 400,405 ****
--- 403,425 ----
     to its mode width.  */
  DEFTREECODE (BIT_FIELD_REF, "bit_field_ref", tcc_reference, 3)
  
+ /* Used only on an operand of complex type, these return
+    a value of the corresponding component type.  */
+ DEFTREECODE (REALPART_EXPR, "realpart_expr", tcc_reference, 1)
+ DEFTREECODE (IMAGPART_EXPR, "imagpart_expr", tcc_reference, 1)
+ 
+ /* Array indexing.
+    Operand 0 is the array; operand 1 is a (single) array index.
+    Operand 2, if present, is a copy of TYPE_MIN_VALUE of the index.
+    Operand 3, if present, is the element size, measured in units of
+    the alignment of the element type.  */
+ DEFTREECODE (ARRAY_REF, "array_ref", tcc_reference, 4)
+ 
+ /* Likewise, except that the result is a range ("slice") of the array.  The
+    starting index of the resulting array is taken from operand 1 and the size
+    of the range is taken from the type of the expression.  */
+ DEFTREECODE (ARRAY_RANGE_REF, "array_range_ref", tcc_reference, 4)
+ 
  /* The ordering of the following codes is optimized for the checking
     macros in tree.h.  Changing the order will degrade the speed of the
     compiler.  INDIRECT_REF, ALIGN_INDIRECT_REF, MISALIGNED_INDIRECT_REF.  */
*************** DEFTREECODE (ALIGN_INDIRECT_REF, "align_
*** 418,435 ****
     or 0 if the alignment is unknown.  */
  DEFTREECODE (MISALIGNED_INDIRECT_REF, "misaligned_indirect_ref", tcc_reference, 2)
  
- /* Array indexing.
-    Operand 0 is the array; operand 1 is a (single) array index.
-    Operand 2, if present, is a copy of TYPE_MIN_VALUE of the index.
-    Operand 3, if present, is the element size, measured in units of
-    the alignment of the element type.  */
- DEFTREECODE (ARRAY_REF, "array_ref", tcc_reference, 4)
- 
- /* Likewise, except that the result is a range ("slice") of the array.  The
-    starting index of the resulting array is taken from operand 1 and the size
-    of the range is taken from the type of the expression.  */
- DEFTREECODE (ARRAY_RANGE_REF, "array_range_ref", tcc_reference, 4)
- 
  /* Used to represent lookup of runtime type dependent data.  Often this is
     a reference to a vtable, but it needn't be.  Operands are:
     OBJ_TYPE_REF_EXPR: An expression that evaluates the value to use.
--- 438,443 ----
*************** DEFTREECODE (COMPLEX_EXPR, "complex_expr
*** 806,816 ****
  /* Complex conjugate of operand.  Used only on complex types.  */
  DEFTREECODE (CONJ_EXPR, "conj_expr", tcc_unary, 1)
  
- /* Used only on an operand of complex type, these return
-    a value of the corresponding component type.  */
- DEFTREECODE (REALPART_EXPR, "realpart_expr", tcc_reference, 1)
- DEFTREECODE (IMAGPART_EXPR, "imagpart_expr", tcc_reference, 1)
- 
  /* Nodes for ++ and -- in C.
     The second arg is how much to increment or decrement by.
     For a pointer, it would be the size of the object pointed to.  */
--- 814,819 ----
Index: trunk/gcc/tree.h
===================================================================
*** trunk.orig/gcc/tree.h	2009-04-16 11:41:11.000000000 +0200
--- trunk/gcc/tree.h	2009-04-16 12:31:58.000000000 +0200
*************** extern tree get_narrower (tree, int *);
*** 4504,4510 ****
  
  /* Return true if T is an expression that get_inner_reference handles.  */
  
! extern int handled_component_p (const_tree);
  
  /* Given an expression EXP that is a handled_component_p,
     look for the ultimate containing object, which is returned and specify
--- 4504,4527 ----
  
  /* Return true if T is an expression that get_inner_reference handles.  */
  
! static inline bool
! handled_component_p (const_tree t)
! {
!   switch (TREE_CODE (t))
!     {
!     case BIT_FIELD_REF:
!     case COMPONENT_REF:
!     case ARRAY_REF:
!     case ARRAY_RANGE_REF:
!     case VIEW_CONVERT_EXPR:
!     case REALPART_EXPR:
!     case IMAGPART_EXPR:
!       return true;
! 
!     default:
!       return false;
!     }
! }
  
  /* Given an expression EXP that is a handled_component_p,
     look for the ultimate containing object, which is returned and specify


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