* [PATCH] Fix simplify_const_unary_operation (PR debug/48204)
@ 2011-03-23 20:11 Jakub Jelinek
2011-03-24 10:02 ` Richard Guenther
0 siblings, 1 reply; 2+ messages in thread
From: Jakub Jelinek @ 2011-03-23 20:11 UTC (permalink / raw)
To: gcc-patches
Hi!
simplify_const_unary_operation assumes it doesn't have to change anything
in REAL_VALUE_TYPE for FLOAT_EXTEND, which is wrong when FLOAT_EXTENDing
e.g. from SFmode to DDmode or SDmode to DFmode, where the number
needs to be converted from binary to decimal or vice versa.
Fixed thusly, bootstrapped/regtested on x86_64-linux and i686-linux,
ok for trunk/4.6.1?
2011-03-23 Jakub Jelinek <jakub@redhat.com>
PR debug/48204
* simplify-rtx.c (simplify_const_unary_operation): Call
real_convert when changing mode class with FLOAT_EXTEND.
* gcc.dg/dfp/pr48204.c: New test.
--- gcc/simplify-rtx.c.jj 2011-03-21 13:00:09.000000000 +0100
+++ gcc/simplify-rtx.c 2011-03-23 16:39:13.000000000 +0100
@@ -1526,7 +1526,8 @@ simplify_const_unary_operation (enum rtx
}
else if (GET_CODE (op) == CONST_DOUBLE
- && SCALAR_FLOAT_MODE_P (mode))
+ && SCALAR_FLOAT_MODE_P (mode)
+ && SCALAR_FLOAT_MODE_P (GET_MODE (op)))
{
REAL_VALUE_TYPE d, t;
REAL_VALUE_FROM_CONST_DOUBLE (d, op);
@@ -1549,7 +1550,10 @@ simplify_const_unary_operation (enum rtx
d = real_value_truncate (mode, d);
break;
case FLOAT_EXTEND:
- /* All this does is change the mode. */
+ /* All this does is change the mode, unless changing
+ mode class. */
+ if (GET_MODE_CLASS (mode) != GET_MODE_CLASS (GET_MODE (op)))
+ real_convert (&d, mode, &d);
break;
case FIX:
real_arithmetic (&d, FIX_TRUNC_EXPR, &d, NULL);
--- gcc/testsuite/gcc.dg/dfp/pr48204.c.jj 2011-03-23 16:44:09.000000000 +0100
+++ gcc/testsuite/gcc.dg/dfp/pr48204.c 2011-03-23 16:43:35.000000000 +0100
@@ -0,0 +1,10 @@
+/* PR debug/48204 */
+/* { dg-do compile } */
+/* { dg-options "-O -fno-tree-ccp -fno-tree-dominator-opts -fno-tree-fre -g" } */
+
+void
+foo (void)
+{
+ float cf = 3.0f;
+ _Decimal64 d64 = cf;
+}
Jakub
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] Fix simplify_const_unary_operation (PR debug/48204)
2011-03-23 20:11 [PATCH] Fix simplify_const_unary_operation (PR debug/48204) Jakub Jelinek
@ 2011-03-24 10:02 ` Richard Guenther
0 siblings, 0 replies; 2+ messages in thread
From: Richard Guenther @ 2011-03-24 10:02 UTC (permalink / raw)
To: Jakub Jelinek; +Cc: gcc-patches
On Wed, Mar 23, 2011 at 9:11 PM, Jakub Jelinek <jakub@redhat.com> wrote:
> Hi!
>
> simplify_const_unary_operation assumes it doesn't have to change anything
> in REAL_VALUE_TYPE for FLOAT_EXTEND, which is wrong when FLOAT_EXTENDing
> e.g. from SFmode to DDmode or SDmode to DFmode, where the number
> needs to be converted from binary to decimal or vice versa.
>
> Fixed thusly, bootstrapped/regtested on x86_64-linux and i686-linux,
> ok for trunk/4.6.1?
Ok.
Thanks,
Richard.
> 2011-03-23 Jakub Jelinek <jakub@redhat.com>
>
> PR debug/48204
> * simplify-rtx.c (simplify_const_unary_operation): Call
> real_convert when changing mode class with FLOAT_EXTEND.
>
> * gcc.dg/dfp/pr48204.c: New test.
>
> --- gcc/simplify-rtx.c.jj 2011-03-21 13:00:09.000000000 +0100
> +++ gcc/simplify-rtx.c 2011-03-23 16:39:13.000000000 +0100
> @@ -1526,7 +1526,8 @@ simplify_const_unary_operation (enum rtx
> }
>
> else if (GET_CODE (op) == CONST_DOUBLE
> - && SCALAR_FLOAT_MODE_P (mode))
> + && SCALAR_FLOAT_MODE_P (mode)
> + && SCALAR_FLOAT_MODE_P (GET_MODE (op)))
> {
> REAL_VALUE_TYPE d, t;
> REAL_VALUE_FROM_CONST_DOUBLE (d, op);
> @@ -1549,7 +1550,10 @@ simplify_const_unary_operation (enum rtx
> d = real_value_truncate (mode, d);
> break;
> case FLOAT_EXTEND:
> - /* All this does is change the mode. */
> + /* All this does is change the mode, unless changing
> + mode class. */
> + if (GET_MODE_CLASS (mode) != GET_MODE_CLASS (GET_MODE (op)))
> + real_convert (&d, mode, &d);
> break;
> case FIX:
> real_arithmetic (&d, FIX_TRUNC_EXPR, &d, NULL);
> --- gcc/testsuite/gcc.dg/dfp/pr48204.c.jj 2011-03-23 16:44:09.000000000 +0100
> +++ gcc/testsuite/gcc.dg/dfp/pr48204.c 2011-03-23 16:43:35.000000000 +0100
> @@ -0,0 +1,10 @@
> +/* PR debug/48204 */
> +/* { dg-do compile } */
> +/* { dg-options "-O -fno-tree-ccp -fno-tree-dominator-opts -fno-tree-fre -g" } */
> +
> +void
> +foo (void)
> +{
> + float cf = 3.0f;
> + _Decimal64 d64 = cf;
> +}
>
> Jakub
>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2011-03-24 10:02 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-03-23 20:11 [PATCH] Fix simplify_const_unary_operation (PR debug/48204) Jakub Jelinek
2011-03-24 10:02 ` Richard Guenther
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).