public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
From: Andrew Pinski <pinskia@gmail.com>
To: Aldy Hernandez <aldyh@redhat.com>,
	Andrew MacLeod <amacleod@redhat.com>,
	 GCC Mailing List <gcc@gcc.gnu.org>
Subject: get_range_query vs NULL argument
Date: Wed, 15 Feb 2023 11:50:02 -0800	[thread overview]
Message-ID: <CA+=Sn1ks16FXLch-tSqkZgKp6Tw-pckg1Hk2gRt+6cZyXiKdig@mail.gmail.com> (raw)

Hi,
  While fixing PR 108354, I came across that
ssa_name_has_boolean_range calls get_range_query with cfun as the
argument but sometimes while in IPA passes cfun is currently nullptr.
The question should we check the argument before calling
get_range_query or is it a valid thing to call it with a nullptr (and
have it return global_ranges in that case)?

I committed the patch (for PR 108354) with the workaround around the
issue via having the match.pd pattern which was calling
ssa_name_has_boolean_range only be invoked from the gimple
simplifiers.

Below is the patch which undones the workaround:
```
diff --git a/gcc/match.pd b/gcc/match.pd
index e7b700349a6..e352bd422f5 100644
--- a/gcc/match.pd
+++ b/gcc/match.pd
@@ -1732,7 +1732,6 @@ DEFINE_INT_AND_FLOAT_ROUND_FN (RINT)
  (if (!FIXED_POINT_TYPE_P (type))
  (plus @0 (negate @1))))

-#if GIMPLE
 /* 1 - a is a ^ 1 if a had a bool range. */
 /* This is only enabled for gimple as sometimes
    cfun is not set for the function which contains
@@ -1743,7 +1742,6 @@ DEFINE_INT_AND_FLOAT_ROUND_FN (RINT)
   (if (INTEGRAL_TYPE_P (type)
        && ssa_name_has_boolean_range (@1))
    (bit_xor @1 @0)))
-#endif

 /* Other simplifications of negation (c.f. fold_negate_expr_1).  */
 (simplify
```
Note I can only so far reproduce the call to
ssa_name_has_boolean_range that causes an issue while building Ada
tools (while bootstrapping) because the code that needs to hit this is
related to variable sized type accesses.

Thanks,
Andrew Pinski

             reply	other threads:[~2023-02-15 19:50 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-02-15 19:50 Andrew Pinski [this message]
2023-02-15 22:30 ` Andrew MacLeod
2023-02-16  7:57   ` Richard Biener
2023-02-16  8:10     ` Aldy Hernandez
2023-02-17 17:13   ` Andrew Pinski

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='CA+=Sn1ks16FXLch-tSqkZgKp6Tw-pckg1Hk2gRt+6cZyXiKdig@mail.gmail.com' \
    --to=pinskia@gmail.com \
    --cc=aldyh@redhat.com \
    --cc=amacleod@redhat.com \
    --cc=gcc@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).