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-141] tree-optimization/100278 - handle mismatched code in TBAA adjust of PRE
Date: Tue, 27 Apr 2021 08:30:13 +0000 (GMT)	[thread overview]
Message-ID: <20210427083013.C38FD385802A@sourceware.org> (raw)

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

commit r12-141-gacfe5290406cc70485df8899d14982278a9371f8
Author: Richard Biener <rguenther@suse.de>
Date:   Tue Apr 27 09:41:38 2021 +0200

    tree-optimization/100278 - handle mismatched code in TBAA adjust of PRE
    
    PRE has code to adjust TBAA behavior for refs that expects the base
    operation code to match.  The testcase shows a case where we have
    a VAR_DECL vs. a MEM_REF so add code to give up in such cases.
    
    2021-04-27  Richard Biener  <rguenther@suse.de>
    
            PR tree-optimization/100278
            * tree-ssa-pre.c (compute_avail): Give up when we cannot
            adjust TBAA beacuse of mismatching bases.
    
            * gcc.dg/tree-ssa/pr100278.c: New testcase.

Diff:
---
 gcc/testsuite/gcc.dg/tree-ssa/pr100278.c | 17 +++++++++++++++++
 gcc/tree-ssa-pre.c                       | 10 ++++++++++
 2 files changed, 27 insertions(+)

diff --git a/gcc/testsuite/gcc.dg/tree-ssa/pr100278.c b/gcc/testsuite/gcc.dg/tree-ssa/pr100278.c
new file mode 100644
index 00000000000..8d702284c3a
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/tree-ssa/pr100278.c
@@ -0,0 +1,17 @@
+/* { dg-do compile } */
+/* { dg-options "-O2" } */
+
+void a()
+{
+#if defined __s390__
+  register int b asm("r5");
+#elif defined __x86_64__
+  register int b asm("eax");
+#else
+  volatile int b;
+#endif
+  if (b)
+    b = 1;
+  for (; b;)
+    ;
+}
diff --git a/gcc/tree-ssa-pre.c b/gcc/tree-ssa-pre.c
index 2803b58430e..2d22535af87 100644
--- a/gcc/tree-ssa-pre.c
+++ b/gcc/tree-ssa-pre.c
@@ -4151,6 +4151,16 @@ compute_avail (void)
 		      if (ref->set == set
 			  || alias_set_subset_of (set, ref->set))
 			;
+		      else if (ref1->opcode != ref2->opcode
+			       || (ref1->opcode != MEM_REF
+				   && ref1->opcode != TARGET_MEM_REF))
+			{
+			  /* With mismatching base opcodes or bases
+			     other than MEM_REF or TARGET_MEM_REF we
+			     can't do any easy TBAA adjustment.  */
+			  operands.release ();
+			  continue;
+			}
 		      else if (alias_set_subset_of (ref->set, set))
 			{
 			  ref->set = set;


                 reply	other threads:[~2021-04-27  8:30 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=20210427083013.C38FD385802A@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).