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 r14-8450] tree-optimization/113602 - datarefs of non-addressables
Date: Fri, 26 Jan 2024 10:25:36 +0000 (GMT)	[thread overview]
Message-ID: <20240126102536.3EC283858291@sourceware.org> (raw)

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

commit r14-8450-gf9b143d239db775318a29e9ff63f232b9501a22a
Author: Richard Biener <rguenther@suse.de>
Date:   Fri Jan 26 09:29:22 2024 +0100

    tree-optimization/113602 - datarefs of non-addressables
    
    We can end up creating ADDR_EXPRs of non-addressable entities during
    for example vectorization.  The following plugs this in data-ref
    analysis when that would create such invalid ADDR_EXPR as part of
    analyzing the ref structure.
    
            PR tree-optimization/113602
            * tree-data-ref.cc (dr_analyze_innermost): Fail when
            the base object isn't addressable.
    
            * gcc.dg/pr113602.c: New testcase.

Diff:
---
 gcc/testsuite/gcc.dg/pr113602.c | 10 ++++++++++
 gcc/tree-data-ref.cc            |  7 ++++++-
 2 files changed, 16 insertions(+), 1 deletion(-)

diff --git a/gcc/testsuite/gcc.dg/pr113602.c b/gcc/testsuite/gcc.dg/pr113602.c
new file mode 100644
index 000000000000..94bfbc91b5f4
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/pr113602.c
@@ -0,0 +1,10 @@
+/* { dg-do compile } */
+/* { dg-require-effective-target bitint575 } */
+/* { dg-options "-O2 -fno-tree-loop-optimize" } */
+
+_BitInt(503)
+f(void)
+{
+  register _BitInt(503) r asm(""); /* { dg-error "invalid" } */
+  return r;
+}
diff --git a/gcc/tree-data-ref.cc b/gcc/tree-data-ref.cc
index ae55bf6aa481..f37734b53409 100644
--- a/gcc/tree-data-ref.cc
+++ b/gcc/tree-data-ref.cc
@@ -1182,7 +1182,12 @@ dr_analyze_innermost (innermost_loop_behavior *drb, tree ref,
       base = TREE_OPERAND (base, 0);
     }
   else
-    base = build_fold_addr_expr (base);
+    {
+      if (may_be_nonaddressable_p (base))
+	return opt_result::failure_at (stmt,
+				       "failed: base not addressable.\n");
+      base = build_fold_addr_expr (base);
+    }
 
   if (in_loop)
     {

                 reply	other threads:[~2024-01-26 10:25 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=20240126102536.3EC283858291@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).