Patchwork Fix a -fcompare-debug bug in the vectorizer (PR debug/49496)

login
register
mail settings
Submitter Jakub Jelinek
Date June 22, 2011, 5:02 p.m.
Message ID <20110622170249.GN16443@tyan-ft48-01.lab.bos.redhat.com>
Download mbox | patch
Permalink /patch/101515/
State New
Headers show

Comments

Jakub Jelinek - June 22, 2011, 5:02 p.m.
Hi!

This bug has been introduced recently, we shouldn't take debug uses into
account when deciding whether to optimize.

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

2011-06-22  Jakub Jelinek  <jakub@redhat.com>

	PR debug/49496
	* tree-vect-patterns.c (vect_recog_widen_mult_pattern): Ignore debug
	uses.

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


	Jakub
Richard Guenther - June 22, 2011, 5:57 p.m.
On Wed, Jun 22, 2011 at 7:02 PM, Jakub Jelinek <jakub@redhat.com> wrote:
> Hi!
>
> This bug has been introduced recently, we shouldn't take debug uses into
> account when deciding whether to optimize.
>
> Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk?

Ok.

Thanks,
Richard.

> 2011-06-22  Jakub Jelinek  <jakub@redhat.com>
>
>        PR debug/49496
>        * tree-vect-patterns.c (vect_recog_widen_mult_pattern): Ignore debug
>        uses.
>
>        * gcc.dg/pr49496.c: New test.
>
> --- gcc/tree-vect-patterns.c.jj 2011-06-17 11:02:19.000000000 +0200
> +++ gcc/tree-vect-patterns.c    2011-06-22 11:23:08.000000000 +0200
> @@ -557,6 +557,8 @@ vect_recog_widen_mult_pattern (VEC (gimp
>
>       FOR_EACH_IMM_USE_FAST (use_p, imm_iter, lhs)
>         {
> +         if (is_gimple_debug (USE_STMT (use_p)))
> +           continue;
>           use_stmt = USE_STMT (use_p);
>           nuses++;
>         }
> --- gcc/testsuite/gcc.dg/pr49496.c.jj   2011-06-22 11:24:30.000000000 +0200
> +++ gcc/testsuite/gcc.dg/pr49496.c      2011-06-22 11:28:33.000000000 +0200
> @@ -0,0 +1,20 @@
> +/* PR debug/49496 */
> +/* { dg-do compile } */
> +/* { dg-options "-O3 -fcompare-debug" } */
> +
> +unsigned short u[8], s1[8], s2[8];
> +
> +void bar (unsigned short *);
> +
> +void
> +foo (void)
> +{
> +  unsigned short e[8];
> +  int i;
> +  for (i = 0; i < 8; i++)
> +    {
> +      int tmp = s1[i] * s2[i];
> +      e[i] = (tmp & 0xffff0000) >> 16;
> +    }
> +  bar (e);
> +}
>
>        Jakub
>

Patch

--- gcc/tree-vect-patterns.c.jj	2011-06-17 11:02:19.000000000 +0200
+++ gcc/tree-vect-patterns.c	2011-06-22 11:23:08.000000000 +0200
@@ -557,6 +557,8 @@  vect_recog_widen_mult_pattern (VEC (gimp
 
       FOR_EACH_IMM_USE_FAST (use_p, imm_iter, lhs)
         {
+	  if (is_gimple_debug (USE_STMT (use_p)))
+	    continue;
           use_stmt = USE_STMT (use_p);
           nuses++;
         }
--- gcc/testsuite/gcc.dg/pr49496.c.jj	2011-06-22 11:24:30.000000000 +0200
+++ gcc/testsuite/gcc.dg/pr49496.c	2011-06-22 11:28:33.000000000 +0200
@@ -0,0 +1,20 @@ 
+/* PR debug/49496 */
+/* { dg-do compile } */
+/* { dg-options "-O3 -fcompare-debug" } */
+
+unsigned short u[8], s1[8], s2[8];
+
+void bar (unsigned short *);
+
+void
+foo (void)
+{
+  unsigned short e[8];
+  int i;
+  for (i = 0; i < 8; i++)
+    {
+      int tmp = s1[i] * s2[i];
+      e[i] = (tmp & 0xffff0000) >> 16;
+    }
+  bar (e);
+}