public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
From: Richard Biener <rguenth@gcc.gnu.org>
To: gcc-cvs@gcc.gnu.org
Subject: [gcc r12-9481] tree-optimization/108791 - checking ICE with sloppy ADDR_EXPR
Date: Thu, 27 Apr 2023 13:19:05 +0000 (GMT)	[thread overview]
Message-ID: <20230427131905.AEF26385773B@sourceware.org> (raw)

https://gcc.gnu.org/g:fcf27816635186acce77dd9b6d756d5c93fd92ef

commit r12-9481-gfcf27816635186acce77dd9b6d756d5c93fd92ef
Author: Richard Biener <rguenther@suse.de>
Date:   Wed Feb 15 14:00:21 2023 +0100

    tree-optimization/108791 - checking ICE with sloppy ADDR_EXPR
    
    The following fixes a checking ICE by choosing a more appropriate
    type for an ADDR_EXPR built by forwprop.
    
            PR tree-optimization/108791
            * tree-ssa-forwprop.cc (optimize_vector_load): Build
            the ADDR_EXPR of a TARGET_MEM_REF using a more meaningful
            type.
    
            * gcc.dg/torture/pr108791.c: New testcase.
    
    (cherry picked from commit 441c466fd4d8b9afd99f585f7c4bfade911c4652)

Diff:
---
 gcc/testsuite/gcc.dg/torture/pr108791.c | 9 +++++++++
 gcc/tree-ssa-forwprop.cc                | 3 ++-
 2 files changed, 11 insertions(+), 1 deletion(-)

diff --git a/gcc/testsuite/gcc.dg/torture/pr108791.c b/gcc/testsuite/gcc.dg/torture/pr108791.c
new file mode 100644
index 00000000000..c1c1cb22aad
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/pr108791.c
@@ -0,0 +1,9 @@
+/* { dg-do compile } */
+
+int f (int *a(), int *b, int *c, int *d)
+{
+  int s = 0;
+  for (int *i = (int *)a; i < b; ++i, ++c)
+    s += *c * d[*i];
+  return s;
+}
diff --git a/gcc/tree-ssa-forwprop.cc b/gcc/tree-ssa-forwprop.cc
index 9290d1558e5..062f5667f14 100644
--- a/gcc/tree-ssa-forwprop.cc
+++ b/gcc/tree-ssa-forwprop.cc
@@ -3255,7 +3255,8 @@ optimize_vector_load (gimple_stmt_iterator *gsi)
     {
       if (TREE_CODE (TREE_OPERAND (load_rhs, 0)) == ADDR_EXPR)
 	mark_addressable (TREE_OPERAND (TREE_OPERAND (load_rhs, 0), 0));
-      tree tem = make_ssa_name (TREE_TYPE (TREE_OPERAND (load_rhs, 0)));
+      tree ptrtype = build_pointer_type (TREE_TYPE (load_rhs));
+      tree tem = make_ssa_name (ptrtype);
       gimple *new_stmt
 	= gimple_build_assign (tem, build1 (ADDR_EXPR, TREE_TYPE (tem),
 					    unshare_expr (load_rhs)));

                 reply	other threads:[~2023-04-27 13:19 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20230427131905.AEF26385773B@sourceware.org \
    --to=rguenth@gcc.gnu.org \
    --cc=gcc-cvs@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).