public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [patch] Minor tweaks
@ 2012-03-19 12:21 Eric Botcazou
  2012-03-19 12:33 ` Richard Guenther
  0 siblings, 1 reply; 4+ messages in thread
From: Eric Botcazou @ 2012-03-19 12:21 UTC (permalink / raw)
  To: gcc-patches

[-- Attachment #1: Type: text/plain, Size: 1127 bytes --]

Hi,

around line 380, we have in tree.def:

/* References to storage.  */

/* The ordering of the following codes is optimized for the classification
   in handled_component_p.  Keep them in a consecutive group.  */

The hitch is that VIEW_CONVERT_EXPR is far apart from the others, so the patch 
puts them together (and orders them consistently).  It also tweaks a couple of 
places where callers of get_inner_reference initializes unsignedp:

	    int unsignedp = 0, volatilep = 0;

 
 	    decl = get_inner_reference (decl, &bitsize, &bitpos, &toffset,
 					&mode, &unsignedp, &volatilep, false);

This is useless since unsignedp is always set (unlike volatilep).

Tested on i586-suse-linux, OK for the mainline?


2012-03-19  Eric Botcazou  <ebotcazou@adacore.com>

	* tree.def (REALPART_EXPR, IMAGPART_EXPR, VIEW_CONVERT_EXPR): Move.
	* tree.h (handled_component_p): Reorder cases.
	* dwarf2out.c (loc_list_for_address_of_addr_expr_of_indirect_ref): Do
	not initialize unsignedp.
	(loc_list_from_tree): Likewise.
	(fortran_common): Likewise.
	* simplify-rtx.c (delegitimize_mem_from_attrs): Likewise.


-- 
Eric Botcazou

[-- Attachment #2: p.diff --]
[-- Type: text/x-diff, Size: 5639 bytes --]

Index: dwarf2out.c
===================================================================
--- dwarf2out.c	(revision 185395)
+++ dwarf2out.c	(working copy)
@@ -13328,8 +13328,8 @@ cst_pool_loc_descr (tree loc)
 }
 
 /* Return dw_loc_list representing address of addr_expr LOC
-   by looking for innder INDIRECT_REF expression and turing it
-   into simple arithmetics.  */
+   by looking for inner INDIRECT_REF expression and turning
+   it into simple arithmetics.  */
 
 static dw_loc_list_ref
 loc_list_for_address_of_addr_expr_of_indirect_ref (tree loc, bool toplev)
@@ -13337,8 +13337,7 @@ loc_list_for_address_of_addr_expr_of_ind
   tree obj, offset;
   HOST_WIDE_INT bitsize, bitpos, bytepos;
   enum machine_mode mode;
-  int volatilep;
-  int unsignedp = TYPE_UNSIGNED (TREE_TYPE (loc));
+  int unsignedp, volatilep = 0;
   dw_loc_list_ref list_ret = NULL, list_ret1 = NULL;
 
   obj = get_inner_reference (TREE_OPERAND (loc, 0),
@@ -13628,8 +13627,7 @@ loc_list_from_tree (tree loc, int want_a
 	tree obj, offset;
 	HOST_WIDE_INT bitsize, bitpos, bytepos;
 	enum machine_mode mode;
-	int volatilep;
-	int unsignedp = TYPE_UNSIGNED (TREE_TYPE (loc));
+	int unsignedp, volatilep = 0;
 
 	obj = get_inner_reference (loc, &bitsize, &bitpos, &offset, &mode,
 				   &unsignedp, &volatilep, false);
@@ -14927,7 +14925,7 @@ fortran_common (tree decl, HOST_WIDE_INT
   enum machine_mode mode;
   HOST_WIDE_INT bitsize, bitpos;
   tree offset;
-  int volatilep = 0, unsignedp = 0;
+  int unsignedp, volatilep = 0;
 
   /* If the decl isn't a VAR_DECL, or if it isn't static, or if
      it does not have a value (the offset into the common area), or if it
Index: simplify-rtx.c
===================================================================
--- simplify-rtx.c	(revision 185395)
+++ simplify-rtx.c	(working copy)
@@ -293,7 +293,7 @@ delegitimize_mem_from_attrs (rtx x)
 	  {
 	    HOST_WIDE_INT bitsize, bitpos;
 	    tree toffset;
-	    int unsignedp = 0, volatilep = 0;
+	    int unsignedp, volatilep = 0;
 
 	    decl = get_inner_reference (decl, &bitsize, &bitpos, &toffset,
 					&mode, &unsignedp, &volatilep, false);
Index: tree.def
===================================================================
--- tree.def	(revision 185395)
+++ tree.def	(working copy)
@@ -400,11 +400,6 @@ DEFTREECODE (COMPONENT_REF, "component_r
    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.
@@ -417,6 +412,23 @@ DEFTREECODE (ARRAY_REF, "array_ref", tcc
    of the range is taken from the type of the expression.  */
 DEFTREECODE (ARRAY_RANGE_REF, "array_range_ref", tcc_reference, 4)
 
+/* 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)
+
+/* Represents viewing something of one type as being of a second type.
+   This corresponds to an "Unchecked Conversion" in Ada and roughly to
+   the idiom *(type2 *)&X in C.  The only operand is the value to be
+   viewed as being of another type.  It is undefined if the type of the
+   input and of the expression have different sizes.
+
+   This code may also be used within the LHS of a MODIFY_EXPR, in which
+   case no actual data motion may occur.  TREE_ADDRESSABLE will be set in
+   this case and GCC must abort if it could not do the operation without
+   generating insns.  */
+DEFTREECODE (VIEW_CONVERT_EXPR, "view_convert_expr", tcc_reference, 1)
+
 /* C unary `*' or Pascal `^'.  One operand, an expression for a pointer.  */
 DEFTREECODE (INDIRECT_REF, "indirect_ref", tcc_reference, 1)
 
@@ -769,18 +781,6 @@ DEFTREECODE (NOP_EXPR, "nop_expr", tcc_u
 /* Value is same as argument, but guaranteed not an lvalue.  */
 DEFTREECODE (NON_LVALUE_EXPR, "non_lvalue_expr", tcc_unary, 1)
 
-/* Represents viewing something of one type as being of a second type.
-   This corresponds to an "Unchecked Conversion" in Ada and roughly to
-   the idiom *(type2 *)&X in C.  The only operand is the value to be
-   viewed as being of another type.  It is undefined if the type of the
-   input and of the expression have different sizes.
-
-   This code may also be used within the LHS of a MODIFY_EXPR, in which
-   case no actual data motion may occur.  TREE_ADDRESSABLE will be set in
-   this case and GCC must abort if it could not do the operation without
-   generating insns.  */
-DEFTREECODE (VIEW_CONVERT_EXPR, "view_convert_expr", tcc_reference, 1)
-
 /* A COMPOUND_LITERAL_EXPR represents a literal that is placed in a DECL.  The
    COMPOUND_LITERAL_EXPR_DECL_EXPR is the a DECL_EXPR containing the decl
    for the anonymous object represented by the COMPOUND_LITERAL;
Index: tree.h
===================================================================
--- tree.h	(revision 185395)
+++ tree.h	(working copy)
@@ -5026,13 +5026,13 @@ handled_component_p (const_tree t)
 {
   switch (TREE_CODE (t))
     {
-    case BIT_FIELD_REF:
     case COMPONENT_REF:
+    case BIT_FIELD_REF:
     case ARRAY_REF:
     case ARRAY_RANGE_REF:
-    case VIEW_CONVERT_EXPR:
     case REALPART_EXPR:
     case IMAGPART_EXPR:
+    case VIEW_CONVERT_EXPR:
       return true;
 
     default:

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [patch] Minor tweaks
  2012-03-19 12:21 [patch] Minor tweaks Eric Botcazou
@ 2012-03-19 12:33 ` Richard Guenther
  2012-03-19 15:32   ` Eric Botcazou
  0 siblings, 1 reply; 4+ messages in thread
From: Richard Guenther @ 2012-03-19 12:33 UTC (permalink / raw)
  To: Eric Botcazou; +Cc: gcc-patches

On Mon, Mar 19, 2012 at 1:21 PM, Eric Botcazou <ebotcazou@adacore.com> wrote:
> Hi,
>
> around line 380, we have in tree.def:
>
> /* References to storage.  */
>
> /* The ordering of the following codes is optimized for the classification
>   in handled_component_p.  Keep them in a consecutive group.  */
>
> The hitch is that VIEW_CONVERT_EXPR is far apart from the others, so the patch
> puts them together (and orders them consistently).  It also tweaks a couple of
> places where callers of get_inner_reference initializes unsignedp:
>
>            int unsignedp = 0, volatilep = 0;
>
>
>            decl = get_inner_reference (decl, &bitsize, &bitpos, &toffset,
>                                        &mode, &unsignedp, &volatilep, false);
>
> This is useless since unsignedp is always set (unlike volatilep).
>
> Tested on i586-suse-linux, OK for the mainline?

Ok.  I think volatilep should be always set as well.

Thanks,
Richard.

>
> 2012-03-19  Eric Botcazou  <ebotcazou@adacore.com>
>
>        * tree.def (REALPART_EXPR, IMAGPART_EXPR, VIEW_CONVERT_EXPR): Move.
>        * tree.h (handled_component_p): Reorder cases.
>        * dwarf2out.c (loc_list_for_address_of_addr_expr_of_indirect_ref): Do
>        not initialize unsignedp.
>        (loc_list_from_tree): Likewise.
>        (fortran_common): Likewise.
>        * simplify-rtx.c (delegitimize_mem_from_attrs): Likewise.
>
>
> --
> Eric Botcazou

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [patch] Minor tweaks
  2012-03-19 12:33 ` Richard Guenther
@ 2012-03-19 15:32   ` Eric Botcazou
  0 siblings, 0 replies; 4+ messages in thread
From: Eric Botcazou @ 2012-03-19 15:32 UTC (permalink / raw)
  To: Richard Guenther; +Cc: gcc-patches

> Ok.  I think volatilep should be always set as well.

Thanks.  No strong opinion, but at least one caller (fold_truthop through 
decode_field_reference) calls the function 4 times in a row and only checks 
volatilep at the end to disable the transformation.

-- 
Eric Botcazou

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH] Minor tweaks
@ 2009-04-17 12:41 Richard Guenther
  0 siblings, 0 replies; 4+ messages in thread
From: Richard Guenther @ 2009-04-17 12:41 UTC (permalink / raw)
  To: gcc-patches


This fixes two minor issues I noticed when working on sanitizing
fold_stmt.  First we generate useless conversions when eliminating
to constants in FRE/PRE, second DOM contains some funny code that
never should trigger.

Fixed.

Bootstrapped and tested on x86_64-unknown-linux-gnu, applied to trunk.

Richard.

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

	* tree-ssa-dom.c (gimple_assign_unary_useless_conversion_p): Remove.
	(record_equivalences_from_stmt): Remove useless checks and
	simplifications.
	* tree-ssa-pre.c (eliminate): Avoid converting a constant if
	the type is already suitable.

Index: gcc/tree-ssa-dom.c
===================================================================
*** gcc/tree-ssa-dom.c	(revision 146239)
--- gcc/tree-ssa-dom.c	(working copy)
*************** eliminate_redundant_computations (gimple
*** 1915,1940 ****
    return retval;
  }
  
- /* Return true if statement GS is an assignment that peforms a useless
-    type conversion.  It is is intended to be a tuples analog of function
-    tree_ssa_useless_type_conversion.  */
- 
- static bool
- gimple_assign_unary_useless_conversion_p (gimple gs)
- {
-   if (is_gimple_assign (gs)
-       && (CONVERT_EXPR_CODE_P (gimple_assign_rhs_code (gs))
-           || gimple_assign_rhs_code (gs) == VIEW_CONVERT_EXPR
-           || gimple_assign_rhs_code (gs) == NON_LVALUE_EXPR))
-     {
-       tree lhs_type = TREE_TYPE (gimple_assign_lhs (gs));
-       tree rhs_type = TREE_TYPE (gimple_assign_rhs1 (gs));
-       return useless_type_conversion_p (lhs_type, rhs_type);
-     }
-   
-   return false;
- }
- 
  /* STMT, a GIMPLE_ASSIGN, may create certain equivalences, in either
     the available expressions table or the const_and_copies table.
     Detect and record those equivalences.  */
--- 1915,1920 ----
*************** record_equivalences_from_stmt (gimple st
*** 1953,1966 ****
    lhs_code = TREE_CODE (lhs);
  
    if (lhs_code == SSA_NAME
!       && (gimple_assign_single_p (stmt)
!           || gimple_assign_unary_useless_conversion_p (stmt)))
      {
        tree rhs = gimple_assign_rhs1 (stmt);
                 
-       /* Strip away any useless type conversions.  */
-       STRIP_USELESS_TYPE_CONVERSION (rhs);
- 
        /* If the RHS of the assignment is a constant or another variable that
  	 may be propagated, register it in the CONST_AND_COPIES table.  We
  	 do not need to record unwind data for this, since this is a true
--- 1933,1942 ----
    lhs_code = TREE_CODE (lhs);
  
    if (lhs_code == SSA_NAME
!       && gimple_assign_single_p (stmt))
      {
        tree rhs = gimple_assign_rhs1 (stmt);
                 
        /* If the RHS of the assignment is a constant or another variable that
  	 may be propagated, register it in the CONST_AND_COPIES table.  We
  	 do not need to record unwind data for this, since this is a true
Index: gcc/tree-ssa-pre.c
===================================================================
*** gcc/tree-ssa-pre.c	(revision 146239)
--- gcc/tree-ssa-pre.c	(working copy)
*************** eliminate (void)
*** 3981,3988 ****
  		 value is constant, use that constant.  */
  	      if (!sprime && is_gimple_min_invariant (VN_INFO (lhs)->valnum))
  		{
! 		  sprime = fold_convert (TREE_TYPE (lhs),
! 					 VN_INFO (lhs)->valnum);
  
  		  if (dump_file && (dump_flags & TDF_DETAILS))
  		    {
--- 3981,3990 ----
  		 value is constant, use that constant.  */
  	      if (!sprime && is_gimple_min_invariant (VN_INFO (lhs)->valnum))
  		{
! 		  sprime = VN_INFO (lhs)->valnum;
! 		  if (!useless_type_conversion_p (TREE_TYPE (lhs),
! 						  TREE_TYPE (sprime)))
! 		    sprime = fold_convert (TREE_TYPE (lhs), sprime);
  
  		  if (dump_file && (dump_flags & TDF_DETAILS))
  		    {

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2012-03-19 15:32 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-03-19 12:21 [patch] Minor tweaks Eric Botcazou
2012-03-19 12:33 ` Richard Guenther
2012-03-19 15:32   ` Eric Botcazou
  -- strict thread matches above, loose matches on Subject: below --
2009-04-17 12:41 [PATCH] " Richard Guenther

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).