public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r14-8450] tree-optimization/113602 - datarefs of non-addressables
@ 2024-01-26 10:25 Richard Biener
  0 siblings, 0 replies; only message in thread
From: Richard Biener @ 2024-01-26 10:25 UTC (permalink / raw)
  To: gcc-cvs

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)
     {

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2024-01-26 10:25 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-01-26 10:25 [gcc r14-8450] tree-optimization/113602 - datarefs of non-addressables Richard Biener

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).