This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[PATCH] Fix PR53693
- From: Richard Guenther <rguenther at suse dot de>
- To: gcc-patches at gcc dot gnu dot org
- Date: Mon, 18 Jun 2012 14:36:57 +0200 (CEST)
- Subject: [PATCH] Fix PR53693
When the vectorizer detects a widening shift pattern it has to
make sure the widening operation is used only once as it will
make it part of the recognized pattern.
Bootstrapped and tested on x86_64-unknown-linux-gnu, applied to trunk.
Richard.
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.
Index: gcc/tree-vect-patterns.c
===================================================================
*** gcc/tree-vect-patterns.c (revision 188725)
--- gcc/tree-vect-patterns.c (working copy)
*************** vect_operation_fits_smaller_type (gimple
*** 991,996 ****
--- 991,1001 ----
|| 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)
Index: gcc/testsuite/g++.dg/torture/pr53693.C
===================================================================
*** gcc/testsuite/g++.dg/torture/pr53693.C (revision 0)
--- gcc/testsuite/g++.dg/torture/pr53693.C (revision 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);
+ }
+ }