public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Aldy Hernandez <aldyh@redhat.com>
To: GCC patches <gcc-patches@gcc.gnu.org>
Cc: Andrew MacLeod <amacleod@redhat.com>, Aldy Hernandez <aldyh@redhat.com>
Subject: [COMMITTED] [PR106936] Remove assert from get_value_range.
Date: Wed, 14 Sep 2022 14:49:35 +0200	[thread overview]
Message-ID: <20220914124935.1221658-1-aldyh@redhat.com> (raw)

This assert was put here to make sure that the legacy
get_value_range() wasn't being called on stuff that legacy couldn't
handle (floats, etc), because the result would ultimately be copied
into a value_range_equiv.

In this case, simplify_casted_cond() is calling it on an offset_type
which is neither an integer nor a pointer.  However, range_of_expr
happily punted on it, and then the fallthru code set the range to
VARYING.  As value_range_equiv can store VARYING types of anything
(including types it can't handle), this is fine.

The easiest thing to do is remove the assert.  If someone from the non
legacy world tries to get a non integer/pointer range here, it's going
to blow up anyhow because the temporary in get_value_range is
int_range_max.

	PR tree-optimization/106936

gcc/ChangeLog:

	* value-query.cc (range_query::get_value_range): Remove assert.

gcc/testsuite/ChangeLog:

	* g++.dg/tree-ssa/pr106936.C: New test.
---
 gcc/testsuite/g++.dg/tree-ssa/pr106936.C | 14 ++++++++++++++
 gcc/value-query.cc                       |  1 -
 2 files changed, 14 insertions(+), 1 deletion(-)
 create mode 100644 gcc/testsuite/g++.dg/tree-ssa/pr106936.C

diff --git a/gcc/testsuite/g++.dg/tree-ssa/pr106936.C b/gcc/testsuite/g++.dg/tree-ssa/pr106936.C
new file mode 100644
index 00000000000..c3096e0dd20
--- /dev/null
+++ b/gcc/testsuite/g++.dg/tree-ssa/pr106936.C
@@ -0,0 +1,14 @@
+// { dg-do compile } */
+// { dg-options "-O2 -fno-tree-ccp -fno-tree-forwprop -fno-tree-fre" }
+
+namespace testPointerToMemberMiscCasts2 {
+struct B {
+  int f;
+};
+struct L : public B { };
+struct R : public B { };
+struct D : public L, R { };
+  int B::* pb = &B::f;
+  int R::* pr = pb;
+  int D::* pdr = pr;
+}
diff --git a/gcc/value-query.cc b/gcc/value-query.cc
index 201f679a36e..ad80db780c2 100644
--- a/gcc/value-query.cc
+++ b/gcc/value-query.cc
@@ -167,7 +167,6 @@ range_query::free_value_range_equiv (value_range_equiv *v)
 const class value_range_equiv *
 range_query::get_value_range (const_tree expr, gimple *stmt)
 {
-  gcc_checking_assert (value_range_equiv::supports_p (TREE_TYPE (expr)));
   int_range_max r;
   if (range_of_expr (r, const_cast<tree> (expr), stmt))
     return new (equiv_alloc->allocate ()) value_range_equiv (r);
-- 
2.37.1


                 reply	other threads:[~2022-09-14 12:49 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=20220914124935.1221658-1-aldyh@redhat.com \
    --to=aldyh@redhat.com \
    --cc=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).