* [PATCH] simplify-rtx: Fix up last argument to simplify_gen_unary [PR113656]
@ 2024-01-31 8:44 Jakub Jelinek
2024-01-31 9:04 ` Richard Biener
0 siblings, 1 reply; 2+ messages in thread
From: Jakub Jelinek @ 2024-01-31 8:44 UTC (permalink / raw)
To: Richard Biener, Eric Botcazou, Segher Boessenkool, Jeff Law; +Cc: gcc-patches
Hi!
When simplifying e.g. (float_truncate:SF (float_truncate:DF (reg:XF))
or (float_truncate:SF (float_extend:XF (reg:DF)) etc. into
(float_truncate:SF (reg:XF)) or (float_truncate:SF (reg:DF)) we call
simplify_gen_unary with incorrect op_mode argument, it should be
the argument's mode, but we call it with the outer mode instead.
As these are all floating point operations, the argument always
has non-VOIDmode and so we can just use that mode (as done in similar
simplifications a few lines later), but neither FLOAT_TRUNCATE nor
FLOAT_EXTEND are operations that should have the same modes of operand
and result. This bug hasn't been a problem for years because normally
op_mode is used only if the mode of op is VOIDmode, otherwise it is
redundant, but r10-2139 added an assertion in some spots that op_mode
is right even in such cases.
Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk?
2024-01-31 Jakub Jelinek <jakub@redhat.com>
PR rtl-optimization/113656
* simplify-rtx.cc (simplify_context::simplify_unary_operation_1)
<case FLOAT_TRUNCATE>: Fix up last argument to simplify_gen_unary.
* gcc.target/i386/pr113656.c: New test.
--- gcc/simplify-rtx.cc.jj 2024-01-03 11:51:32.828713189 +0100
+++ gcc/simplify-rtx.cc 2024-01-30 19:34:30.516934480 +0100
@@ -1305,7 +1305,7 @@ simplify_context::simplify_unary_operati
> GET_MODE_UNIT_SIZE (mode)
? FLOAT_TRUNCATE : FLOAT_EXTEND,
mode,
- XEXP (op, 0), mode);
+ XEXP (op, 0), GET_MODE (XEXP (op, 0)));
/* (float_truncate (float x)) is (float x) */
if ((GET_CODE (op) == FLOAT || GET_CODE (op) == UNSIGNED_FLOAT)
--- gcc/testsuite/gcc.target/i386/pr113656.c.jj 2024-01-30 19:38:29.029608721 +0100
+++ gcc/testsuite/gcc.target/i386/pr113656.c 2024-01-30 19:37:10.519703443 +0100
@@ -0,0 +1,12 @@
+/* PR rtl-optimization/113656 */
+/* { dg-do compile } */
+/* { dg-options "-O3 -frounding-math -funsafe-math-optimizations -mavx512fp16 -mavx512vl" } */
+
+_Float16 a[8];
+
+void
+foo ()
+{
+ for (int i = 0; i < 8; i++)
+ a[i] = i - 8.4;
+}
Jakub
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] simplify-rtx: Fix up last argument to simplify_gen_unary [PR113656]
2024-01-31 8:44 [PATCH] simplify-rtx: Fix up last argument to simplify_gen_unary [PR113656] Jakub Jelinek
@ 2024-01-31 9:04 ` Richard Biener
0 siblings, 0 replies; 2+ messages in thread
From: Richard Biener @ 2024-01-31 9:04 UTC (permalink / raw)
To: Jakub Jelinek; +Cc: Eric Botcazou, Segher Boessenkool, Jeff Law, gcc-patches
On Wed, 31 Jan 2024, Jakub Jelinek wrote:
> Hi!
>
> When simplifying e.g. (float_truncate:SF (float_truncate:DF (reg:XF))
> or (float_truncate:SF (float_extend:XF (reg:DF)) etc. into
> (float_truncate:SF (reg:XF)) or (float_truncate:SF (reg:DF)) we call
> simplify_gen_unary with incorrect op_mode argument, it should be
> the argument's mode, but we call it with the outer mode instead.
> As these are all floating point operations, the argument always
> has non-VOIDmode and so we can just use that mode (as done in similar
> simplifications a few lines later), but neither FLOAT_TRUNCATE nor
> FLOAT_EXTEND are operations that should have the same modes of operand
> and result. This bug hasn't been a problem for years because normally
> op_mode is used only if the mode of op is VOIDmode, otherwise it is
> redundant, but r10-2139 added an assertion in some spots that op_mode
> is right even in such cases.
>
> Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk?
OK.
> 2024-01-31 Jakub Jelinek <jakub@redhat.com>
>
> PR rtl-optimization/113656
> * simplify-rtx.cc (simplify_context::simplify_unary_operation_1)
> <case FLOAT_TRUNCATE>: Fix up last argument to simplify_gen_unary.
>
> * gcc.target/i386/pr113656.c: New test.
>
> --- gcc/simplify-rtx.cc.jj 2024-01-03 11:51:32.828713189 +0100
> +++ gcc/simplify-rtx.cc 2024-01-30 19:34:30.516934480 +0100
> @@ -1305,7 +1305,7 @@ simplify_context::simplify_unary_operati
> > GET_MODE_UNIT_SIZE (mode)
> ? FLOAT_TRUNCATE : FLOAT_EXTEND,
> mode,
> - XEXP (op, 0), mode);
> + XEXP (op, 0), GET_MODE (XEXP (op, 0)));
>
> /* (float_truncate (float x)) is (float x) */
> if ((GET_CODE (op) == FLOAT || GET_CODE (op) == UNSIGNED_FLOAT)
> --- gcc/testsuite/gcc.target/i386/pr113656.c.jj 2024-01-30 19:38:29.029608721 +0100
> +++ gcc/testsuite/gcc.target/i386/pr113656.c 2024-01-30 19:37:10.519703443 +0100
> @@ -0,0 +1,12 @@
> +/* PR rtl-optimization/113656 */
> +/* { dg-do compile } */
> +/* { dg-options "-O3 -frounding-math -funsafe-math-optimizations -mavx512fp16 -mavx512vl" } */
> +
> +_Float16 a[8];
> +
> +void
> +foo ()
> +{
> + for (int i = 0; i < 8; i++)
> + a[i] = i - 8.4;
> +}
>
> Jakub
>
>
--
Richard Biener <rguenther@suse.de>
SUSE Software Solutions Germany GmbH,
Frankenstrasse 146, 90461 Nuernberg, Germany;
GF: Ivo Totev, Andrew McDonald, Werner Knoblich; (HRB 36809, AG Nuernberg)
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2024-01-31 9:09 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-01-31 8:44 [PATCH] simplify-rtx: Fix up last argument to simplify_gen_unary [PR113656] Jakub Jelinek
2024-01-31 9:04 ` Richard Biener
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).