From: "Ian Lance Taylor via gcc-patches" <gcc-patches@gcc.gnu.org>
To: Jakub Jelinek <jakub@redhat.com>
Cc: Richard Biener <rguenther@suse.de>,
gcc-patches <gcc-patches@gcc.gnu.org>
Subject: Re: [PATCH] Fix up go regressions caused by my recent switchconv changes (PR go/91617)
Date: Sat, 31 Aug 2019 17:12:00 -0000 [thread overview]
Message-ID: <CAKOQZ8xx-j0S01+4ipgNHBXyNtefUjFjcNWCCgLxzPjiTqVEkQ@mail.gmail.com> (raw)
In-Reply-To: <20190831131207.GF2120@tucnak>
On Sat, Aug 31, 2019 at 6:12 AM Jakub Jelinek <jakub@redhat.com> wrote:
>
> Hi!
>
> Apparently my recent tree-{cfg,switch-conversion}.c changes broke a bunch of
> go tests.
> The problem is that range_check_type actually doesn't guarantee an unsigned
> type; it forces integer type for enum/bool (that was what was really needed
> to fix the PR), and for integer types that don't wrap forces unsigned type
> (and then verifies the wrap-around). Seems go uses -fwrapv by default
> and we got thus signed types from it. That is fine if we emit the
> x >= low && x < high range tests as x - low >= 0 && x - low < high - low,
> but we actually don't emit the >= 0 check and so we do need an unsigned
> type. The other uses of range_check_type also eventually also call
> unsigned_type_for, e.g.
> etype = range_check_type (etype);
> if (etype == NULL_TREE)
> return NULL_TREE;
>
> if (POINTER_TYPE_P (etype))
> etype = unsigned_type_for (etype);
> and in the recursion then because low is 0:
> if (! TYPE_UNSIGNED (etype))
> {
> etype = unsigned_type_for (etype);
> high = fold_convert_loc (loc, etype, high);
> exp = fold_convert_loc (loc, etype, exp);
> }
> Similarly match.pd:
> tree etype = range_check_type (TREE_TYPE (@0));
> if (etype)
> {
> if (! TYPE_UNSIGNED (etype))
> etype = unsigned_type_for (etype);
> ...
> So, the following patch calls unsigned_type_for on the range_check_type
> result.
>
> Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk?
>
> 2019-08-31 Jakub Jelinek <jakub@redhat.com>
>
> PR go/91617
> * tree-cfg.c (generate_range_test): Call unsigned_type_for on
> the range_check_type result.
> * tree-switch-conversion.c (switch_conversion::build_one_array,
> bit_test_cluster::emit): Likewise.
>
> --- gcc/tree-cfg.c.jj 2019-08-31 12:09:09.135153318 +0200
> +++ gcc/tree-cfg.c 2019-08-31 12:48:06.259939680 +0200
> @@ -9222,6 +9222,7 @@ generate_range_test (basic_block bb, tre
> {
> tree type = TREE_TYPE (index);
> tree utype = range_check_type (type);
> + utype = unsigned_type_for (utype);
>
> low = fold_convert (utype, low);
> high = fold_convert (utype, high);
> --- gcc/tree-switch-conversion.c.jj 2019-08-31 12:09:09.129153406 +0200
> +++ gcc/tree-switch-conversion.c 2019-08-31 12:48:28.340617487 +0200
> @@ -616,6 +616,7 @@ switch_conversion::build_one_array (int
>
> /* We must use type of constructor values. */
> gimple_seq seq = NULL;
> + type = unsigned_type_for (type);
> tree tmp = gimple_convert (&seq, type, m_index_expr);
> tree tmp2 = gimple_build (&seq, MULT_EXPR, type,
> wide_int_to_tree (type, coeff_a), tmp);
> @@ -1486,6 +1487,7 @@ bit_test_cluster::emit (tree index_expr,
> unsigned int count;
>
> tree unsigned_index_type = range_check_type (index_type);
> + unsigned_index_type = unsigned_type_for (unsigned_index_type);
>
> gimple_stmt_iterator gsi;
> gassign *shift_stmt;
Thanks for looking into this.
Ian
next prev parent reply other threads:[~2019-08-31 15:42 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-08-31 15:59 Jakub Jelinek
2019-08-31 17:12 ` Ian Lance Taylor via gcc-patches [this message]
2019-08-31 17:41 ` Richard Biener
2019-08-31 19:17 ` Jakub Jelinek
2019-08-31 20:15 ` Richard Biener
2019-09-01 16:34 ` Jakub Jelinek
2019-09-01 16:44 ` Richard Biener
2019-09-02 8:14 ` Jakub Jelinek
2019-09-02 8:29 ` Andrew Pinski
2019-09-02 13:37 ` Jakub Jelinek
2019-09-02 8:31 ` Richard Biener
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=CAKOQZ8xx-j0S01+4ipgNHBXyNtefUjFjcNWCCgLxzPjiTqVEkQ@mail.gmail.com \
--to=gcc-patches@gcc.gnu.org \
--cc=iant@google.com \
--cc=jakub@redhat.com \
--cc=rguenther@suse.de \
/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).