* [PATCH] Fix SIGN/ZERO_EXTEND confusion in expand_debug_expr (PR debug/45003)
@ 2010-07-20 12:38 Jakub Jelinek
2010-07-20 12:42 ` Richard Guenther
0 siblings, 1 reply; 2+ messages in thread
From: Jakub Jelinek @ 2010-07-20 12:38 UTC (permalink / raw)
To: Richard Guenther; +Cc: gcc-patches
Hi!
As the attached testcase shows, expand_debug_expr was generating wrong
extension (based on TYPE_UNSIGNED of the result rather than operand,
so for unsigned short x; DEBUG y => (int) x was SIGN_EXTEND instead of
ZERO_EXTEND and vice versa).
Fixed thusly, bootstrapped/regtested on x86_64-linux and i686-linux. Ok for
trunk?
2010-07-20 Jakub Jelinek <jakub@redhat.com>
PR debug/45003
* cfgexpand.c (expand_debug_expr) <case NOP_EXPR>: Use ZERO_EXTEND
or SIGN_EXTEND depending on TYPE_UNSIGNED of the operand's type
instead of the result's type.
* gcc.dg/guality/pr45003-1.c: New test.
--- gcc/cfgexpand.c.jj 2010-06-20 17:13:36.000000000 +0200
+++ gcc/cfgexpand.c 2010-07-20 11:21:17.000000000 +0200
@@ -2164,7 +2164,7 @@ expand_debug_expr (tree exp)
op0 = simplify_gen_subreg (mode, op0, inner_mode,
subreg_lowpart_offset (mode,
inner_mode));
- else if (unsignedp)
+ else if (TYPE_UNSIGNED (TREE_TYPE (TREE_OPERAND (exp, 0))))
op0 = gen_rtx_ZERO_EXTEND (mode, op0);
else
op0 = gen_rtx_SIGN_EXTEND (mode, op0);
--- gcc/testsuite/gcc.dg/guality/pr45003-1.c.jj 2010-07-20 13:56:34.000000000 +0200
+++ gcc/testsuite/gcc.dg/guality/pr45003-1.c 2010-07-20 13:58:38.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");
+ asm volatile ("nop" : : "D" (a)); /* { dg-final { gdb-test 10 "a" "0x8078" } } */
+ return 0;
+}
+
+int __attribute__((noinline))
+bar (short *p)
+{
+ unsigned int a = *p;
+ asm volatile ("nop");
+ asm volatile ("nop" : : "D" (a)); /* { dg-final { gdb-test 19 "a" "0xffff8078" } } */
+ return 0;
+}
+
+int
+main ()
+{
+ unsigned short us = 0x8078;
+ foo (&us);
+ short s = -32648;
+ bar (&s);
+ return 0;
+}
Jakub
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] Fix SIGN/ZERO_EXTEND confusion in expand_debug_expr (PR debug/45003)
2010-07-20 12:38 [PATCH] Fix SIGN/ZERO_EXTEND confusion in expand_debug_expr (PR debug/45003) Jakub Jelinek
@ 2010-07-20 12:42 ` Richard Guenther
0 siblings, 0 replies; 2+ messages in thread
From: Richard Guenther @ 2010-07-20 12:42 UTC (permalink / raw)
To: Jakub Jelinek; +Cc: gcc-patches
On Tue, 20 Jul 2010, Jakub Jelinek wrote:
> Hi!
>
> As the attached testcase shows, expand_debug_expr was generating wrong
> extension (based on TYPE_UNSIGNED of the result rather than operand,
> so for unsigned short x; DEBUG y => (int) x was SIGN_EXTEND instead of
> ZERO_EXTEND and vice versa).
>
> Fixed thusly, 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
> * cfgexpand.c (expand_debug_expr) <case NOP_EXPR>: Use ZERO_EXTEND
> or SIGN_EXTEND depending on TYPE_UNSIGNED of the operand's type
> instead of the result's type.
>
> * gcc.dg/guality/pr45003-1.c: New test.
>
> --- gcc/cfgexpand.c.jj 2010-06-20 17:13:36.000000000 +0200
> +++ gcc/cfgexpand.c 2010-07-20 11:21:17.000000000 +0200
> @@ -2164,7 +2164,7 @@ expand_debug_expr (tree exp)
> op0 = simplify_gen_subreg (mode, op0, inner_mode,
> subreg_lowpart_offset (mode,
> inner_mode));
> - else if (unsignedp)
> + else if (TYPE_UNSIGNED (TREE_TYPE (TREE_OPERAND (exp, 0))))
> op0 = gen_rtx_ZERO_EXTEND (mode, op0);
> else
> op0 = gen_rtx_SIGN_EXTEND (mode, op0);
> --- gcc/testsuite/gcc.dg/guality/pr45003-1.c.jj 2010-07-20 13:56:34.000000000 +0200
> +++ gcc/testsuite/gcc.dg/guality/pr45003-1.c 2010-07-20 13:58:38.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");
> + asm volatile ("nop" : : "D" (a)); /* { dg-final { gdb-test 10 "a" "0x8078" } } */
> + return 0;
> +}
> +
> +int __attribute__((noinline))
> +bar (short *p)
> +{
> + unsigned int a = *p;
> + asm volatile ("nop");
> + asm volatile ("nop" : : "D" (a)); /* { dg-final { gdb-test 19 "a" "0xffff8078" } } */
> + 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
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2010-07-20 12:42 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-07-20 12:38 [PATCH] Fix SIGN/ZERO_EXTEND confusion in expand_debug_expr (PR debug/45003) Jakub Jelinek
2010-07-20 12:42 ` 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).