From: Aldy Hernandez <aldyh@redhat.com>
To: GCC patches <gcc-patches@gcc.gnu.org>
Subject: [COMMITTED] Minor fixes to vr_values to not die on non integral types.
Date: Sun, 24 Jul 2022 17:04:31 +0200 [thread overview]
Message-ID: <20220724150431.2010479-4-aldyh@redhat.com> (raw)
In-Reply-To: <20220724150431.2010479-1-aldyh@redhat.com>
The legacy code in vr_values mostly works on integral types (with few
exceptions such as some conversions from float). This patch makes
vr_values::range_of_expr not die when asked for a range of an
unsupported type. It also keeps the min/max simplification code from
being called on non integrals, similarly to what many of the other
assignment code is doing.
This is all a nop on the current code, but will keep us from
misbehaving when VRP starts working on non-integrals.
Tested on x86-64 Linux.
gcc/ChangeLog:
* value-query.cc (range_query::get_value_range): Add assert.
* vr-values.cc (vr_values::range_of_expr): Make sure we don't ICE
on unsupported types in vr_values.
(simplify_using_ranges::simplify): Same.
---
gcc/value-query.cc | 1 +
gcc/vr-values.cc | 15 ++++++++++++++-
2 files changed, 15 insertions(+), 1 deletion(-)
diff --git a/gcc/value-query.cc b/gcc/value-query.cc
index 3560d19f1ae..decf5aae1fe 100644
--- a/gcc/value-query.cc
+++ b/gcc/value-query.cc
@@ -167,6 +167,7 @@ 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);
diff --git a/gcc/vr-values.cc b/gcc/vr-values.cc
index 6b9c630fed3..626a9189472 100644
--- a/gcc/vr-values.cc
+++ b/gcc/vr-values.cc
@@ -188,6 +188,17 @@ vr_values::range_of_expr (vrange &r, tree expr, gimple *stmt)
r = *vr;
else
{
+ if (!vr->supports_type_p (TREE_TYPE (expr)))
+ {
+ // vr_values::extract_range_basic() use of ranger's
+ // fold_range() can create a situation where we are
+ // asked for the range of an unsupported legacy type.
+ // Since get_value_range() above will return varying for
+ // such types, avoid copying incompatible range types.
+ gcc_checking_assert (vr->varying_p ());
+ r.set_varying (TREE_TYPE (expr));
+ return true;
+ }
value_range tmp = *vr;
tmp.normalize_symbolics ();
r = tmp;
@@ -4375,7 +4386,9 @@ simplify_using_ranges::simplify (gimple_stmt_iterator *gsi)
case MIN_EXPR:
case MAX_EXPR:
- return simplify_min_or_max_using_ranges (gsi, stmt);
+ if (INTEGRAL_TYPE_P (TREE_TYPE (rhs1)))
+ return simplify_min_or_max_using_ranges (gsi, stmt);
+ break;
case RSHIFT_EXPR:
{
--
2.36.1
prev parent reply other threads:[~2022-07-24 15:04 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-07-24 15:04 [COMMITTED] Convert some uses in ranger_cache and DOM to vrange Aldy Hernandez
2022-07-24 15:04 ` [COMMITTED] Allow registering same SSA name relations in oracle Aldy Hernandez
2022-07-24 15:04 ` [COMMITTED] Tweaks to global ranges Aldy Hernandez
2022-07-24 15:04 ` Aldy Hernandez [this message]
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=20220724150431.2010479-4-aldyh@redhat.com \
--to=aldyh@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).