public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "pinskia at gcc dot gnu dot org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug middle-end/36143] [4.4 Regression]: FAIL: g++.dg/tree-ssa/pr19637.C
Date: Wed, 07 May 2008 17:21:00 -0000	[thread overview]
Message-ID: <20080507172110.31191.qmail@sourceware.org> (raw)
In-Reply-To: <bug-36143-682@http.gcc.gnu.org/bugzilla/>



------- Comment #8 from pinskia at gcc dot gnu dot org  2008-05-07 17:21 -------
Fix it:
[andrew-pinskis-computer:local/gcc/gcc] apinski% svn diff
Index: tree-ssa-forwprop.c
===================================================================
--- tree-ssa-forwprop.c (revision 135021)
+++ tree-ssa-forwprop.c (working copy)
@@ -132,6 +132,16 @@ along with GCC; see the file COPYING3.  
      res = VIEW_CONVERT_EXPR<type1>(type2var)

    Or
+     ptr = (type1*)&type2var;
+     *ptr = res
+
+   Will get turned into (if type1 and type2 are the same size
+   and neither have volatile on them and is not a scalar):
+    VIEW_CONVERT_EXPR<type1>(type2var) = res
+  FIXME: The last constraint is not needed if DECL_GIMPLE_REG_P is expended
+  to all types
+
+   Or

      ptr = &x[0];
      ptr2 = ptr + <constant>;
@@ -573,6 +583,7 @@ forward_propagate_addr_expr_1 (tree name
 {
   tree lhs, rhs, array_ref;
   tree *rhsp, *lhsp;
+  bool in_reference_lhs = false;

   gcc_assert (TREE_CODE (def_rhs) == ADDR_EXPR);

@@ -602,7 +613,10 @@ forward_propagate_addr_expr_1 (tree name
      ADDR_EXPR will not appear on the LHS.  */
   lhsp = &GIMPLE_STMT_OPERAND (use_stmt, 0);
   while (handled_component_p (*lhsp))
-    lhsp = &TREE_OPERAND (*lhsp, 0);
+    {
+      lhsp = &TREE_OPERAND (*lhsp, 0);
+      in_reference_lhs = true;
+    }
   lhs = *lhsp;

   /* Now see if the LHS node is an INDIRECT_REF using NAME.  If so, 
@@ -617,6 +631,43 @@ forward_propagate_addr_expr_1 (tree name
                                    TREE_TYPE (TREE_OPERAND (def_rhs, 0))))
     {
       *lhsp = unshare_expr (TREE_OPERAND (def_rhs, 0));
+      lhs = *lhsp;
+      fold_stmt_inplace (use_stmt);
+      tidy_after_forward_propagate_addr (use_stmt);
+
+      /* Continue propagating into the RHS if this was not the only use.  */
+      if (single_use_p)
+       return true;
+    }
+    
+  /* Now see if the LHS node is an INDIRECT_REF using NAME.  If so, 
+     propagate the ADDR_EXPR into the use of NAME and try to
+     create a VCE for the result.  */
+  if (TREE_CODE (lhs) == INDIRECT_REF
+      && TREE_OPERAND (lhs, 0) == name
+      && TYPE_SIZE (TREE_TYPE (lhs))
+      && TYPE_SIZE (TREE_TYPE (TREE_OPERAND (def_rhs, 0)))
+      /* Function decls should not be used for VCE either as it could be
+         a function descriptor that we want and not the actual function code. 
*/
+      && TREE_CODE (TREE_OPERAND (def_rhs, 0)) != FUNCTION_DECL
+      /* We should not convert volatile loads to non volatile loads. */
+      && !TYPE_VOLATILE (TREE_TYPE (lhs))
+      && !TYPE_VOLATILE (TREE_TYPE (TREE_OPERAND (def_rhs, 0))) 
+      && operand_equal_p (TYPE_SIZE (TREE_TYPE (lhs)),
+                         TYPE_SIZE (TREE_TYPE (TREE_OPERAND (def_rhs, 0))), 0)
+      /* Check for aggregate types so we don't end up with a SSA_NAME inside
+         a VIEW_CONVERT_EXPR on the lhs. 
+        FIXME: this can go away when DECL_GIMPLE_REG_P is extended for all
+        scalar types.  */
+      && (AGGREGATE_TYPE_P (TREE_TYPE (TREE_OPERAND (def_rhs, 0)))
+         || TREE_CODE (TREE_TYPE (TREE_OPERAND (def_rhs, 0))) == VECTOR_TYPE
+         || TREE_CODE (TREE_TYPE (TREE_OPERAND (def_rhs, 0))) ==
COMPLEX_TYPE))
+    {
+      tree new_lhs = unshare_expr (TREE_OPERAND (def_rhs, 0));
+      /* Use build1 here as we not produce a right hand side so we need to
keep
+         around the VCE.  */
+      new_lhs = build1 (VIEW_CONVERT_EXPR, TREE_TYPE (lhs), new_lhs);
+      *lhsp = new_lhs;
       fold_stmt_inplace (use_stmt);
       tidy_after_forward_propagate_addr (use_stmt);

@@ -673,9 +724,10 @@ forward_propagate_addr_expr_1 (tree name
       if (TREE_CODE (new_rhs) != VIEW_CONVERT_EXPR)
        {
          block_stmt_iterator bsi = bsi_for_stmt (use_stmt);
-         new_rhs = force_gimple_operand_bsi (&bsi, new_rhs, true, NULL, true,
BSI_SAME_STMT);
-         /* As we change the deference to a SSA_NAME, we need to return false
to make sure that
-            the statement does not get removed.  */
+         new_rhs = force_gimple_operand_bsi (&bsi, new_rhs, true, NULL, true,
+                                             BSI_SAME_STMT);
+         /* As we change the deference to a SSA_NAME, we need to return false
+            to make sure that the statement does not get removed.  */
          res = false;
        }
       *rhsp = new_rhs;


-- 

pinskia at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         AssignedTo|unassigned at gcc dot gnu   |pinskia at gcc dot gnu dot
                   |dot org                     |org
             Status|NEW                         |ASSIGNED


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=36143


  parent reply	other threads:[~2008-05-07 17:21 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-05-05 21:29 [Bug middle-end/36143] New: " hjl dot tools at gmail dot com
2008-05-05 21:31 ` [Bug middle-end/36143] " pinskia at gcc dot gnu dot org
2008-05-06  1:06 ` hp at gcc dot gnu dot org
2008-05-06  3:56 ` pinskia at gcc dot gnu dot org
2008-05-06  4:10 ` pinskia at gcc dot gnu dot org
2008-05-06  4:15 ` pinskia at gcc dot gnu dot org
2008-05-06 10:23 ` rguenther at suse dot de
2008-05-07 17:09 ` hp at gcc dot gnu dot org
2008-05-07 17:21 ` pinskia at gcc dot gnu dot org [this message]
2008-05-16 19:38 ` rguenth at gcc dot gnu dot org
2008-05-21 11:15 ` hp at gcc dot gnu dot org
2008-05-25 18:14 ` ghazi at gcc dot gnu dot org
2008-07-21  2:39 ` hp at gcc dot gnu dot org
2008-12-03 15:21 ` jakub at gcc dot gnu dot org
2008-12-03 15:34 ` rguenth at gcc dot gnu dot org
2009-04-21 16:02 ` [Bug middle-end/36143] [4.4/4.5 " jakub at gcc dot gnu dot org
2009-07-22 10:30 ` jakub at gcc dot gnu dot org
2009-09-24 13:48 ` rguenth at gcc dot gnu dot org
2009-09-24 13:49 ` [Bug middle-end/36143] [4.4 " rguenth at gcc dot gnu dot org
2009-10-15 12:54 ` jakub at gcc dot gnu dot org
2010-01-21 13:19 ` jakub at gcc dot gnu dot org
2010-03-30 17:26 ` ghazi at gcc dot gnu dot org
2010-04-30  8:53 ` jakub at gcc dot gnu dot org
     [not found] <bug-36143-4@http.gcc.gnu.org/bugzilla/>
2010-10-01 11:54 ` jakub at gcc dot gnu.org
2011-04-16 10:13 ` jakub at gcc dot gnu.org
2011-11-29 23:19 ` pinskia at gcc dot gnu.org
2012-03-13 16:35 ` jakub at gcc dot gnu.org

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20080507172110.31191.qmail@sourceware.org \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).