public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Richard Biener <richard.guenther@gmail.com>
To: Andrew Pinski <apinski@marvell.com>
Cc: gcc-patches@gcc.gnu.org
Subject: Re: [PATCH] When simplifing BFR of an insert, require a mode precision integral type (PR108688)
Date: Thu, 9 Feb 2023 09:16:17 +0100	[thread overview]
Message-ID: <CAFiYyc05DwNtJxg04khamJtSMNAvwEDMe7uSERmVFqFWKWJkyw@mail.gmail.com> (raw)
In-Reply-To: <20230208211419.1583473-1-apinski@marvell.com>

On Wed, Feb 8, 2023 at 10:15 PM Andrew Pinski via Gcc-patches
<gcc-patches@gcc.gnu.org> wrote:
>
> The same problem as PR 88739 has crept in but
> this time in match.pd when simplifying bit_field_ref of
> an bit_insert. That is we are generating a BIT_FIELD_REF
> of a non-mode-precision integral type.
>
> OK? Bootstrapped and tested on x86_64-linux-gnu with no regressions.

Hmm.  Can we handle the case of the extraction exactly covering the
insertion separately then and simplify to plain @1?

Thanks,
Richard.

>         PR tree-optimization/108688
>
> gcc/ChangeLog:
>
>         * match.pd (bit_field_ref [bit_insert]):
>         Avoid generating BIT_FIELD_REFs of non-mode-precision
>         integral operands
>
> gcc/testsuite/ChangeLog:
>
>         * gcc.c-torture/compile/pr108688-1.c: New test.
> ---
>  gcc/match.pd                                     |  4 +++-
>  gcc/testsuite/gcc.c-torture/compile/pr108688-1.c | 15 +++++++++++++++
>  2 files changed, 18 insertions(+), 1 deletion(-)
>  create mode 100644 gcc/testsuite/gcc.c-torture/compile/pr108688-1.c
>
> diff --git a/gcc/match.pd b/gcc/match.pd
> index c9e8bebede2..d8353072822 100644
> --- a/gcc/match.pd
> +++ b/gcc/match.pd
> @@ -7487,7 +7487,9 @@ DEFINE_INT_AND_FLOAT_ROUND_FN (RINT)
>        isize = tree_to_uhwi (TYPE_SIZE (TREE_TYPE (@1)));
>    }
>    (switch
> -   (if (wi::leu_p (wi::to_wide (@ipos), wi::to_wide (@rpos))
> +   (if ((!INTEGRAL_TYPE_P (TREE_TYPE (@1))
> +         || type_has_mode_precision_p (TREE_TYPE (@1)))
> +        && wi::leu_p (wi::to_wide (@ipos), wi::to_wide (@rpos))
>         && wi::leu_p (wi::to_wide (@rpos) + wi::to_wide (@rsize),
>                       wi::to_wide (@ipos) + isize))
>      (BIT_FIELD_REF @1 @rsize { wide_int_to_tree (bitsizetype,
> diff --git a/gcc/testsuite/gcc.c-torture/compile/pr108688-1.c b/gcc/testsuite/gcc.c-torture/compile/pr108688-1.c
> new file mode 100644
> index 00000000000..43d782d62bd
> --- /dev/null
> +++ b/gcc/testsuite/gcc.c-torture/compile/pr108688-1.c
> @@ -0,0 +1,15 @@
> +
> +
> +union U { signed int d : 7; signed int e : 2; } u;
> +int a, b;
> +
> +void
> +foo (void)
> +{
> +  for (int i = 0; i < 64; i++)
> +    {
> +      u.d = a;
> +      u.e ^= b;
> +    }
> +}
> +
> --
> 2.17.1
>

  reply	other threads:[~2023-02-09  8:16 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-02-08 21:14 Andrew Pinski
2023-02-09  8:16 ` Richard Biener [this message]
2023-02-09  9:57   ` Jakub Jelinek
2023-02-09 14:12     ` 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=CAFiYyc05DwNtJxg04khamJtSMNAvwEDMe7uSERmVFqFWKWJkyw@mail.gmail.com \
    --to=richard.guenther@gmail.com \
    --cc=apinski@marvell.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).