This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] Further sign_extend/zero_extend VTA fixes (PR debug/45003)


On Tue, 20 Jul 2010, Jakub Jelinek wrote:

> Hi!
> 
> This patch handles reg = sign_extend (mem) and
> reg = zero_extend (mem) as reversible like if the sign/zero extension
> operand is a reg, which cures the attached testcase.  The dwarf2out.c
> hunk removes wrong handling of SIGN_EXTEND/ZERO_EXTEND, we can't ignore
> them, as can be seen on the -3.c testcase.  mem_loc_descriptor from
> default: will handle it correctly.
> 
> Bootstrapped/regtested on x86_64-linux and i686-linux.  Ok for trunk?

Ok.

Thanks,
Richard.

> 2010-07-20  Jakub Jelinek  <jakub@redhat.com>
> 
> 	PR debug/45003
> 	* var-tracking.c (reverse_op): Also handle {SIGN,ZERO}_EXTEND of
> 	a MEM.
> 	* dwarf2out.c (loc_descriptor): Don't handle SIGN_EXTEND nor
> 	ZERO_EXTEND here.
> 
> 	* gcc.dg/guality/pr45003-2.c: New test.
> 	* gcc.dg/guality/pr45003-3.c: New test.
> 
> --- gcc/dwarf2out.c.jj	2010-07-16 17:55:08.000000000 +0200
> +++ gcc/dwarf2out.c	2010-07-20 15:43:37.000000000 +0200
> @@ -14254,11 +14254,6 @@ loc_descriptor (rtx rtl, enum machine_mo
>        loc_result = reg_loc_descriptor (rtl, initialized);
>        break;
>  
> -    case SIGN_EXTEND:
> -    case ZERO_EXTEND:
> -      loc_result = loc_descriptor (XEXP (rtl, 0), mode, initialized);
> -      break;
> -
>      case MEM:
>        loc_result = mem_loc_descriptor (XEXP (rtl, 0), GET_MODE (rtl),
>  				       initialized);
> --- gcc/var-tracking.c.jj	2010-07-16 17:55:08.000000000 +0200
> +++ gcc/var-tracking.c	2010-07-20 15:02:47.000000000 +0200
> @@ -5187,16 +5187,19 @@ reverse_op (rtx val, const_rtx expr)
>      case XOR:
>      case NOT:
>      case NEG:
> +      if (!REG_P (XEXP (src, 0)))
> +	return NULL_RTX;
> +      break;
>      case SIGN_EXTEND:
>      case ZERO_EXTEND:
> +      if (!REG_P (XEXP (src, 0)) && !MEM_P (XEXP (src, 0)))
> +	return NULL_RTX;
>        break;
>      default:
>        return NULL_RTX;
>      }
>  
> -  if (!REG_P (XEXP (src, 0))
> -      || !SCALAR_INT_MODE_P (GET_MODE (src))
> -      || XEXP (src, 0) == cfa_base_rtx)
> +  if (!SCALAR_INT_MODE_P (GET_MODE (src)) || XEXP (src, 0) == cfa_base_rtx)
>      return NULL_RTX;
>  
>    v = cselib_lookup (XEXP (src, 0), GET_MODE (XEXP (src, 0)), 0);
> --- gcc/testsuite/gcc.dg/guality/pr45003-2.c.jj	2010-07-20 15:07:21.000000000 +0200
> +++ gcc/testsuite/gcc.dg/guality/pr45003-2.c	2010-07-20 15:07:50.000000000 +0200
> @@ -0,0 +1,31 @@
> +/* PR debug/45003 */
> +/* { dg-do run { target { x86_64-*-* && lp64 } } } */
> +/* { dg-options "-g" } */
> +
> +int __attribute__((noinline))
> +foo (unsigned short *p)
> +{
> +  int a = *p;
> +  asm volatile ("nop" : : "D" ((int) *p));
> +  asm volatile ("nop" : : "D" ((int) *p));	/* { dg-final { gdb-test 10 "a" "0x8078" } } */
> +  return 0;
> +}
> +
> +int __attribute__((noinline))
> +bar (short *p)
> +{
> +  unsigned int a = *p;
> +  asm volatile ("nop" : : "D" ((unsigned int) *p));
> +  asm volatile ("nop" : : "D" ((unsigned int) *p));	/* { dg-final { gdb-test 19 "a" "0xffff8078" } } */
> +  return 0;
> +}
> +
> +int
> +main ()
> +{
> +  unsigned short us = 0x8078;
> +  foo (&us);
> +  short s = -32648;
> +  bar (&s);
> +  return 0;
> +}
> --- gcc/testsuite/gcc.dg/guality/pr45003-3.c.jj	2010-07-20 15:43:58.000000000 +0200
> +++ gcc/testsuite/gcc.dg/guality/pr45003-3.c	2010-07-20 15:45:39.000000000 +0200
> @@ -0,0 +1,31 @@
> +/* PR debug/45003 */
> +/* { dg-do run { target { x86_64-*-* && lp64 } } } */
> +/* { dg-options "-g" } */
> +
> +int __attribute__((noinline))
> +foo (unsigned short *p)
> +{
> +  int a = (short) *p;
> +  asm volatile ("nop" : : "D" ((int) *p));
> +  asm volatile ("nop" : : "D" ((int) *p));	/* { dg-final { gdb-test 10 "a" "-32648" } } */
> +  return 0;
> +}
> +
> +int __attribute__((noinline))
> +bar (short *p)
> +{
> +  unsigned int a = (unsigned short) *p;
> +  asm volatile ("nop" : : "D" ((unsigned int) *p));
> +  asm volatile ("nop" : : "D" ((unsigned int) *p));	/* { dg-final { gdb-test 19 "a" "0x8078" } } */
> +  return 0;
> +}
> +
> +int
> +main ()
> +{
> +  unsigned short us = 0x8078;
> +  foo (&us);
> +  short s = -32648;
> +  bar (&s);
> +  return 0;
> +}
> 
> 	Jakub
> 
> 

-- 
Richard Guenther <rguenther@suse.de>
Novell / SUSE Labs
SUSE LINUX Products GmbH - Nuernberg - AG Nuernberg - HRB 16746 - GF: Markus Rex


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]