]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
Don't register nonsensical relations.
authorAndrew MacLeod <amacleod@redhat.com>
Sat, 30 Oct 2021 15:00:49 +0000 (11:00 -0400)
committerAndrew MacLeod <amacleod@redhat.com>
Mon, 1 Nov 2021 13:14:42 +0000 (09:14 -0400)
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.

gcc/testsuite/gcc.dg/pr103003.c [new file with mode: 0644]
gcc/value-relation.cc

diff --git a/gcc/testsuite/gcc.dg/pr103003.c b/gcc/testsuite/gcc.dg/pr103003.c
new file mode 100644 (file)
index 0000000..d3d65f8
--- /dev/null
@@ -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;
+}
index f572bcd4dc2f9edf4ccbf3a08d1ab358daad562a..f1e46d38de1ab422c029e720211fd444e972d984 100644 (file)
@@ -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