re PR tree-optimization/53693 (ICE in vect_get_vec_def_for_stmt_copy, at tree-vect...
authorRichard Guenther <rguenther@suse.de>
Mon, 18 Jun 2012 14:05:27 +0000 (14:05 +0000)
committerRichard Biener <rguenth@gcc.gnu.org>
Mon, 18 Jun 2012 14:05:27 +0000 (14:05 +0000)
2012-06-18  Richard Guenther  <rguenther@suse.de>

PR tree-optimization/53693
* tree-vect-patterns.c (vect_operation_fits_smaller_type):
Reject operands with more than one use.

* g++.dg/torture/pr53693.C: New testcase.

From-SVN: r188733

gcc/ChangeLog
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/torture/pr53693.C [new file with mode: 0644]
gcc/tree-vect-patterns.c

index 194601dc714cbc796fa73c1c64522f5a0a5381f7..8355d02452b8ed1f29794d6fa9a0c88085a392d1 100644 (file)
@@ -1,3 +1,9 @@
+2012-06-18  Richard Guenther  <rguenther@suse.de>
+
+       PR tree-optimization/53693
+       * tree-vect-patterns.c (vect_operation_fits_smaller_type):
+       Reject operands with more than one use.
+
 2012-06-18  Bill Schmidt  <wschmidt@linux.ibm.com>
 
        PR tree-optimization/53703
index 933dca32d824eed26afc6f04a02de5ac98f7236e..392e603df88b4b5ea2baa2fe59e8a1336689e8d7 100644 (file)
@@ -1,3 +1,8 @@
+2012-06-18  Richard Guenther  <rguenther@suse.de>
+
+       PR tree-optimization/53693
+       * g++.dg/torture/pr53693.C: New testcase.
+
 2012-06-18  Bill Schmidt  <wschmidt@linux.ibm.com>
 
        PR tree-optimization/53703
diff --git a/gcc/testsuite/g++.dg/torture/pr53693.C b/gcc/testsuite/g++.dg/torture/pr53693.C
new file mode 100644 (file)
index 0000000..b67a484
--- /dev/null
@@ -0,0 +1,21 @@
+// { dg-do compile }
+
+void
+filter_scanlines (void *src_buffer, void *dst_buffer, int dst_pitch, int width)
+{
+  int x;
+  unsigned short *src, *dst_a, *dst_b;
+
+  src = (unsigned short *) src_buffer;
+  dst_a = (unsigned short *) dst_buffer;
+  dst_b = ((unsigned short *) dst_buffer) + (dst_pitch >> 1);
+
+  for (x = 0; x < width; x++)
+    {
+      unsigned char gs, gh;
+      gs = src[x];
+      gh = gs + (gs >> 1);
+      dst_a[x] = (gh << 5) | (gh);
+      dst_b[x] = ((gs  - gh) << 5)  | (gs  - gh);
+    }
+}
index 4138d41c11d9a45c575ffe0c641ce149d9e203f9..11a5019985c1d7f882c5c900c1ba4d5b804b03c4 100644 (file)
@@ -991,6 +991,11 @@ vect_operation_fits_smaller_type (gimple stmt, tree def, tree *new_type,
       || TREE_CODE (const_oprnd) != INTEGER_CST)
     return false;
 
+  /* If oprnd has other uses besides that in stmt we cannot mark it
+     as being part of a pattern only.  */
+  if (!has_single_use (oprnd))
+    return false;
+
   /* If we are in the middle of a sequence, we use DEF from a previous
      statement.  Otherwise, OPRND has to be a result of type promotion.  */
   if (*new_type)