Message ID | 20101215180208.GK27214@tyan-ft48-01.lab.bos.redhat.com |
---|---|
State | New |
Headers | show |
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 >
--- 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; +}