public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "jamborm at gcc dot gnu dot org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug middle-end/37861] [4.3 Regression] Bogus array bounds warning
Date: Mon, 10 Nov 2008 10:07:00 -0000	[thread overview]
Message-ID: <20081110100633.11784.qmail@sourceware.org> (raw)
In-Reply-To: <bug-37861-10053@http.gcc.gnu.org/bugzilla/>



------- Comment #8 from jamborm at gcc dot gnu dot org  2008-11-10 10:06 -------
The previous patch resulted into a regression on m32c-unknown-elf and
thus I prepared a less intrusive one below.  See also:

* http://gcc.gnu.org/ml/gcc/2008-11/msg00058.html and
* http://gcc.gnu.org/ml/gcc-patches/2008-11/msg00353.html

The patch is pending approval in the mailing list.

2008-11-07  Martin Jambor  <mjambor@suse.cz>

        * tree-ssa-forwprop.c (forward_propagate_addr_expr_1): Do not check
        for INDIRECT_REFs.
        (forward_propagate_addr_into_variable_array_index): Check that the
        offset is not computed from a MULT_EXPR, use is_gimple_assign rather
        than the gimple code directly.


Index: gcc/tree-ssa-forwprop.c
===================================================================
--- gcc/tree-ssa-forwprop.c     (revision 141673)
+++ gcc/tree-ssa-forwprop.c     (working copy)
@@ -613,19 +613,27 @@ forward_propagate_addr_into_variable_arr
   tree index;
   gimple offset_def, use_stmt = gsi_stmt (*use_stmt_gsi);

-  /* Try to find an expression for a proper index.  This is either
-     a multiplication expression by the element size or just the
-     ssa name we came along in case the element size is one.  */
+  /* Get the offset's defining statement.  */
+  offset_def = SSA_NAME_DEF_STMT (offset);
+
+  /* Try to find an expression for a proper index.  This is either a
+     multiplication expression by the element size or just the ssa name we
came
+     along in case the element size is one. In that case, however, we do not
+     allow multiplications because they can be computing index to a higher
+     level dimension (PR 37861). */
   if (integer_onep (TYPE_SIZE_UNIT (TREE_TYPE (TREE_TYPE (def_rhs)))))
-    index = offset;
-  else
     {
-      /* Get the offset's defining statement.  */
-      offset_def = SSA_NAME_DEF_STMT (offset);
+      if (is_gimple_assign (offset_def)
+         && gimple_assign_rhs_code (offset_def) == MULT_EXPR)
+       return false;

+      index = offset;
+    }
+  else
+    {
       /* The statement which defines OFFSET before type conversion
          must be a simple GIMPLE_ASSIGN.  */
-      if (gimple_code (offset_def) != GIMPLE_ASSIGN)
+      if (!is_gimple_assign (offset_def))
        return false;

       /* The RHS of the statement which defines OFFSET must be a
@@ -802,9 +810,6 @@ forward_propagate_addr_expr_1 (tree name
   array_ref = TREE_OPERAND (def_rhs, 0);
   if (TREE_CODE (array_ref) != ARRAY_REF
       || TREE_CODE (TREE_TYPE (TREE_OPERAND (array_ref, 0))) != ARRAY_TYPE
-      /* Avoid accessing hidden multidimensional arrays in this way or VRP
-        might give out bogus warnings (see PR 37861) */
-      || TREE_CODE (TREE_OPERAND (array_ref, 0)) == INDIRECT_REF
       || !integer_zerop (TREE_OPERAND (array_ref, 1)))
     return false;



-- 


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


  parent reply	other threads:[~2008-11-10 10:07 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-10-17  8:27 [Bug middle-end/37861] New: " rguenth at gcc dot gnu dot org
2008-10-30 17:46 ` [Bug middle-end/37861] " jamborm at gcc dot gnu dot org
2008-10-30 18:45 ` manu at gcc dot gnu dot org
2008-10-31 17:54 ` jamborm at gcc dot gnu dot org
2008-10-31 18:02 ` jamborm at gcc dot gnu dot org
2008-11-04 15:52 ` jamborm at gcc dot gnu dot org
2008-11-05  9:56 ` [Bug middle-end/37861] [4.3/4.4 Regression] " rguenth at gcc dot gnu dot org
2008-11-05 16:09 ` jamborm at gcc dot gnu dot org
2008-11-05 20:51 ` [Bug middle-end/37861] [4.3 " jakub at gcc dot gnu dot org
2008-11-10 10:07 ` jamborm at gcc dot gnu dot org [this message]
2008-11-10 18:41 ` jamborm at gcc dot gnu dot org
2008-11-15  0:01 ` pinskia at gcc dot gnu dot org
2008-11-30 23:02 ` rguenth at gcc dot gnu dot org
2008-12-02 14:34 ` jamborm at gcc dot gnu dot org
2009-01-24 10:26 ` rguenth at gcc dot gnu dot org
2009-02-28  0:31 ` jamborm at gcc dot gnu dot org
2009-02-28 18:33 ` jamborm at gcc dot gnu dot org
2009-02-28 22:46 ` jamborm at gcc dot gnu dot 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=20081110100633.11784.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).