public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Andrew MacLeod <amacleod@redhat.com>
To: gcc-patches <gcc-patches@gcc.gnu.org>
Subject: [COMMITTED] PR tree-optimization/103003 - Don't register nonsensical relations.
Date: Mon, 1 Nov 2021 09:31:36 -0400	[thread overview]
Message-ID: <fc32ce14-f679-6a6e-b825-00eaa8b05670@redhat.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 552 bytes --]

The testcase in question has a stmt of the form:
    _10 = _4 <= _4;

We know this resolves to true, but when proce3ssing outgoing edges on 
the following branch, we try to register the relations

_4 <= _4  and _4 > _4 on the 2 outgoing edges...  which is nonsense of 
course.

this patch simply changes the registry to bai is the 2 ssa_anames are 
the same.

If the relation is ==, then equality is already implied, and any other 
relation just doesn't make much sense.

Bootstrapped on x86_64-pc-linux-gnu with no regressions.  Pushed.

Andrew


[-- Attachment #2: 003.diff --]
[-- Type: text/x-patch, Size: 1701 bytes --]

commit 0187c03be31a58ba561d535687dc00c94f0ff1aa
Author: Andrew MacLeod <amacleod@redhat.com>
Date:   Sat Oct 30 11:00:49 2021 -0400

    Don't register nonsensical relations.
    
            gcc/
            PR tree-optimization/103003
            * value-relation.cc (dom_oracle::register_relation): If the 2
            ssa names are the same, don't register any relation.
    
            gcc/testsuite/
            * gcc.dg/pr103003.c: New.

diff --git a/gcc/testsuite/gcc.dg/pr103003.c b/gcc/testsuite/gcc.dg/pr103003.c
new file mode 100644
index 00000000000..d3d65f8b6a6
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/pr103003.c
@@ -0,0 +1,12 @@
+/* { dg-do compile } */
+/* { dg-options "-O2" } */
+typedef char int8_t;
+int8_t c_4, uli_5;
+unsigned short us_6;
+void func_1() {
+  int uli_9;
+  short ptr_16ptr_11 = &uli_9; /* { dg-warning "initialization of*" } */
+  for (; us_6 <= 6;)
+    if ((us_6 *= uli_9) < (uli_5 || 0) ?: ((c_4 = us_6) >= us_6) - uli_5)
+      uli_9 = 9;
+}
diff --git a/gcc/value-relation.cc b/gcc/value-relation.cc
index f572bcd4dc2..f1e46d38de1 100644
--- a/gcc/value-relation.cc
+++ b/gcc/value-relation.cc
@@ -877,7 +877,13 @@ relation_oracle::register_edge (edge e, relation_kind k, tree op1, tree op2)
 void
 dom_oracle::register_relation (basic_block bb, relation_kind k, tree op1,
 			       tree op2)
-{  // Equivalencies are handled by the equivalence oracle.
+{
+  // If the 2 ssa_names are the same, do nothing.  An equivalence is implied,
+  // and no other relation makes sense.
+  if (op1 == op2)
+    return;
+
+  // Equivalencies are handled by the equivalence oracle.
   if (k == EQ_EXPR)
     equiv_oracle::register_relation (bb, k, op1, op2);
   else

                 reply	other threads:[~2021-11-01 13:31 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=fc32ce14-f679-6a6e-b825-00eaa8b05670@redhat.com \
    --to=amacleod@redhat.com \
    --cc=gcc-patches@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).