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]

[tree-ssa] PATCH to mostly_copy_tree_r


I have been noticing a lot of 

if (foo)
  {
    ...
  }
else
  {
    (void)0;
  }

in tree dumps recently; the pretty-printer is supposed to recognize this
case and avoid printing an 'else' clause.  The cause turned out to be
unnecessary unsharing of the size_zero_node in empty statements, which
causes IS_EMPTY_STMT to return false.

The fix is to just not unshare constants; I don't know why I used to think
they should be unshared.

Hmm...now it occurs to me that we'll probably still end up with copies when
inlining, so IS_EMPTY_STMT should use integer_zerop.  And in most places we
should be using !TREE_SIDE_EFFECTS instead, anyway.

Booted and tested i686-pc-linux-gnu, applied to tree-ssa.

2003-05-20  Jason Merrill  <jason@redhat.com>

	* gimplify.c (mostly_copy_tree_r): Don't unshare constants.

*** gimplify.c.~1~	Tue May 13 15:44:24 2003
--- gimplify.c	Tue May 20 15:45:58 2003
*************** mostly_copy_tree_r (tp, walk_subtrees, d
*** 2406,2413 ****
       void *data;
  {
    enum tree_code code = TREE_CODE (*tp);
!   /* Don't unshare types and SAVE_EXPR nodes.  */
    if (TREE_CODE_CLASS (code) == 't'
        || code == SAVE_EXPR)
      *walk_subtrees = 0;
    else if (code == BIND_EXPR)
--- 2492,2500 ----
       void *data;
  {
    enum tree_code code = TREE_CODE (*tp);
!   /* Don't unshare types, constants and SAVE_EXPR nodes.  */
    if (TREE_CODE_CLASS (code) == 't'
+       || TREE_CODE_CLASS (code) == 'c'
        || code == SAVE_EXPR)
      *walk_subtrees = 0;
    else if (code == BIND_EXPR)

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