public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] Fix expand_debug_expr with VCE (PR debug/46893)
@ 2010-12-15 18:33 Jakub Jelinek
  2010-12-16 12:17 ` Richard Guenther
  0 siblings, 1 reply; 2+ messages in thread
From: Jakub Jelinek @ 2010-12-15 18:33 UTC (permalink / raw)
  To: gcc-patches

Hi!

mode set by get_inner_reference is the outermost mode only (documented).
WHen expand_debug_expr wants to know the op0's mode and it has VOIDmode
(CONST_INT), then we shouldn't be using that outermost mode (in this case
DFmode, same as mode), but tem type's mode (DImode here).
Only then simplify_subreg correctly changes the CONST_INT into CONST_DOUBLE.

Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk?

2010-12-15  Jakub Jelinek  <jakub@redhat.com>

	PR debug/46893
	* cfgexpand.c (expand_debug_expr): If GET_MODE (op0) is VOIDmode,
	use TYPE_MODE (TREE_TYPE (tem)) instead of mode1.

	* gcc.dg/pr46893.c: New test.

--- gcc/cfgexpand.c.jj	2010-12-07 17:32:49.000000000 +0100
+++ gcc/cfgexpand.c	2010-12-15 10:51:14.000000000 +0100
@@ -2703,7 +2703,7 @@ expand_debug_expr (tree exp)
 	    enum machine_mode opmode = GET_MODE (op0);
 
 	    if (opmode == VOIDmode)
-	      opmode = mode1;
+	      opmode = TYPE_MODE (TREE_TYPE (tem));
 
 	    /* This condition may hold if we're expanding the address
 	       right past the end of an array that turned out not to
@@ -2724,7 +2724,8 @@ expand_debug_expr (tree exp)
 				     ? SIGN_EXTRACT
 				     : ZERO_EXTRACT, mode,
 				     GET_MODE (op0) != VOIDmode
-				     ? GET_MODE (op0) : mode1,
+				     ? GET_MODE (op0)
+				     : TYPE_MODE (TREE_TYPE (tem)),
 				     op0, GEN_INT (bitsize), GEN_INT (bitpos));
       }
 
--- gcc/testsuite/gcc.dg/pr46893.c.jj	2010-12-15 10:53:28.000000000 +0100
+++ gcc/testsuite/gcc.dg/pr46893.c	2010-12-15 10:53:05.000000000 +0100
@@ -0,0 +1,12 @@
+/* PR debug/46893 */
+/* { dg-options "-O -g" } */
+
+void
+foo (void)
+{
+  union { unsigned long long l; double d; } u = { 0x7ff0000000000000ULL };
+  double v = 0, w = -u.d;
+
+  if (w)
+    w = v;
+}

	Jakub

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] Fix expand_debug_expr with VCE (PR debug/46893)
  2010-12-15 18:33 [PATCH] Fix expand_debug_expr with VCE (PR debug/46893) Jakub Jelinek
@ 2010-12-16 12:17 ` Richard Guenther
  0 siblings, 0 replies; 2+ messages in thread
From: Richard Guenther @ 2010-12-16 12:17 UTC (permalink / raw)
  To: Jakub Jelinek; +Cc: gcc-patches

On Wed, Dec 15, 2010 at 7:02 PM, Jakub Jelinek <jakub@redhat.com> wrote:
> Hi!
>
> mode set by get_inner_reference is the outermost mode only (documented).
> WHen expand_debug_expr wants to know the op0's mode and it has VOIDmode
> (CONST_INT), then we shouldn't be using that outermost mode (in this case
> DFmode, same as mode), but tem type's mode (DImode here).
> Only then simplify_subreg correctly changes the CONST_INT into CONST_DOUBLE.
>
> Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk?

Ok.

Thanks,
Richard.

> 2010-12-15  Jakub Jelinek  <jakub@redhat.com>
>
>        PR debug/46893
>        * cfgexpand.c (expand_debug_expr): If GET_MODE (op0) is VOIDmode,
>        use TYPE_MODE (TREE_TYPE (tem)) instead of mode1.
>
>        * gcc.dg/pr46893.c: New test.
>
> --- gcc/cfgexpand.c.jj  2010-12-07 17:32:49.000000000 +0100
> +++ gcc/cfgexpand.c     2010-12-15 10:51:14.000000000 +0100
> @@ -2703,7 +2703,7 @@ expand_debug_expr (tree exp)
>            enum machine_mode opmode = GET_MODE (op0);
>
>            if (opmode == VOIDmode)
> -             opmode = mode1;
> +             opmode = TYPE_MODE (TREE_TYPE (tem));
>
>            /* This condition may hold if we're expanding the address
>               right past the end of an array that turned out not to
> @@ -2724,7 +2724,8 @@ expand_debug_expr (tree exp)
>                                     ? SIGN_EXTRACT
>                                     : ZERO_EXTRACT, mode,
>                                     GET_MODE (op0) != VOIDmode
> -                                    ? GET_MODE (op0) : mode1,
> +                                    ? GET_MODE (op0)
> +                                    : TYPE_MODE (TREE_TYPE (tem)),
>                                     op0, GEN_INT (bitsize), GEN_INT (bitpos));
>       }
>
> --- gcc/testsuite/gcc.dg/pr46893.c.jj   2010-12-15 10:53:28.000000000 +0100
> +++ gcc/testsuite/gcc.dg/pr46893.c      2010-12-15 10:53:05.000000000 +0100
> @@ -0,0 +1,12 @@
> +/* PR debug/46893 */
> +/* { dg-options "-O -g" } */
> +
> +void
> +foo (void)
> +{
> +  union { unsigned long long l; double d; } u = { 0x7ff0000000000000ULL };
> +  double v = 0, w = -u.d;
> +
> +  if (w)
> +    w = v;
> +}
>
>        Jakub
>

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2010-12-16 11:38 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-12-15 18:33 [PATCH] Fix expand_debug_expr with VCE (PR debug/46893) Jakub Jelinek
2010-12-16 12:17 ` 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).