From: Richard Biener <richard.guenther@gmail.com>
To: Andrew Pinski <apinski@marvell.com>
Cc: gcc-patches@gcc.gnu.org
Subject: Re: [PATCH] Fix PR 110386: backprop vs ABSU_EXPR
Date: Mon, 25 Sep 2023 06:44:34 +0100 [thread overview]
Message-ID: <F7DC06CE-F7C7-489E-8F3A-75536ABC4746@gmail.com> (raw)
In-Reply-To: <20230924162409.2151727-1-apinski@marvell.com>
> Am 24.09.2023 um 17:24 schrieb Andrew Pinski <apinski@marvell.com>:
>
> The issue here is that when backprop tries to go
> and strip sign ops, it skips over ABSU_EXPR but
> ABSU_EXPR not only does an ABS, it also changes the
> type to unsigned.
> Since strip_sign_op_1 is only supposed to strip off
> sign changing operands and not ones that change types,
> removing ABSU_EXPR here is correct. We don't handle
> nop conversions so this does cause any missed optimizations either.
>
> OK? Bootstrapped and tested on x86_64-linux-gnu with no regressions.
Ok
Richard
> PR tree-optimization/110386
>
> gcc/ChangeLog:
>
> * gimple-ssa-backprop.cc (strip_sign_op_1): Remove ABSU_EXPR.
>
> gcc/testsuite/ChangeLog:
>
> * gcc.c-torture/compile/pr110386-1.c: New test.
> * gcc.c-torture/compile/pr110386-2.c: New test.
> ---
> gcc/gimple-ssa-backprop.cc | 1 -
> gcc/testsuite/gcc.c-torture/compile/pr110386-1.c | 9 +++++++++
> gcc/testsuite/gcc.c-torture/compile/pr110386-2.c | 11 +++++++++++
> 3 files changed, 20 insertions(+), 1 deletion(-)
> create mode 100644 gcc/testsuite/gcc.c-torture/compile/pr110386-1.c
> create mode 100644 gcc/testsuite/gcc.c-torture/compile/pr110386-2.c
>
> diff --git a/gcc/gimple-ssa-backprop.cc b/gcc/gimple-ssa-backprop.cc
> index 65a65590017..dcb15ed4f61 100644
> --- a/gcc/gimple-ssa-backprop.cc
> +++ b/gcc/gimple-ssa-backprop.cc
> @@ -694,7 +694,6 @@ strip_sign_op_1 (tree rhs)
> switch (gimple_assign_rhs_code (assign))
> {
> case ABS_EXPR:
> - case ABSU_EXPR:
> case NEGATE_EXPR:
> return gimple_assign_rhs1 (assign);
>
> diff --git a/gcc/testsuite/gcc.c-torture/compile/pr110386-1.c b/gcc/testsuite/gcc.c-torture/compile/pr110386-1.c
> new file mode 100644
> index 00000000000..4fcc977ad16
> --- /dev/null
> +++ b/gcc/testsuite/gcc.c-torture/compile/pr110386-1.c
> @@ -0,0 +1,9 @@
> +
> +int f(int a)
> +{
> + int c = c < 0 ? c : -c;
> + c = -c;
> + unsigned b = c;
> + unsigned t = b*a;
> + return t*t;
> +}
> diff --git a/gcc/testsuite/gcc.c-torture/compile/pr110386-2.c b/gcc/testsuite/gcc.c-torture/compile/pr110386-2.c
> new file mode 100644
> index 00000000000..c60e1b6994b
> --- /dev/null
> +++ b/gcc/testsuite/gcc.c-torture/compile/pr110386-2.c
> @@ -0,0 +1,11 @@
> +/* { dg-do compile { target i?86-*-* x86_64-*-* } } */
> +/* { dg-options "-mavx" } */
> +
> +#include <immintrin.h>
> +
> +__m128i do_stuff(__m128i XMM0) {
> + __m128i ABS0 = _mm_abs_epi32(XMM0);
> + __m128i MUL0 = _mm_mullo_epi32(ABS0, XMM0);
> + __m128i MUL1 = _mm_mullo_epi32(MUL0, MUL0);
> + return MUL1;
> +}
> --
> 2.31.1
>
prev parent reply other threads:[~2023-09-25 5:44 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-09-24 16:24 Andrew Pinski
2023-09-25 5:44 ` Richard Biener [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=F7DC06CE-F7C7-489E-8F3A-75536ABC4746@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).