[PATCH] Fix a -fcompare-debug bug in the vectorizer (PR debug/49496)

Jakub Jelinek jakub@redhat.com
Wed Jun 22 17:19:00 GMT 2011


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.

--- 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



More information about the Gcc-patches mailing list