Patchwork Fix PR tree-optimization/46049 and tree-optimization/46052

login
register
mail settings
Submitter Ira Rosen
Date Oct. 17, 2010, 10:06 a.m.
Message ID <OF41B2FFFA.8B61AFE4-ONC22577BF.00368EC9-C22577BF.00378A32@il.ibm.com>
Download mbox | patch
Permalink /patch/68073/
State New
Headers show

Comments

Ira Rosen - Oct. 17, 2010, 10:06 a.m.
Hi,

With this patch we choose operands' type as the type of the vector created
for them in case when the operands are invariant variables.
In these PRs we have two different operations, so it doesn't seem
appropriate to choose the type according to operation.

OK for trunk after bootstrap and testing complete on x86_64-suse-linux?

Thanks,
Ira

ChangeLog:

	PR tree-optimization/46049
	PR tree-optimization/46052
	* tree-vect-slp.c (vect_get_constant_vectors): Use operands'
	type in case of invariant variables.

testsuite/ChangeLog:

	PR tree-optimization/46049
	PR tree-optimization/46052
	* gcc.dg/vect/pr46052.c: New test.
	* gcc.dg/vect/pr46049.c: New test.


     vector_type = get_vectype_for_scalar_type (TREE_TYPE (op));
   else
     vector_type = STMT_VINFO_VECTYPE (stmt_vinfo);

Patch

Index: testsuite/gcc.dg/vect/pr46052.c
===================================================================
--- testsuite/gcc.dg/vect/pr46052.c     (revision 0)
+++ testsuite/gcc.dg/vect/pr46052.c     (revision 0)
@@ -0,0 +1,33 @@ 
+/* { dg-do compile } */
+
+int i;
+int a[2];
+
+static inline char bar (void)
+{
+  return i ? i : 1;
+}
+
+void foo (int n)
+{
+  while (n--)
+    {
+      a[0] ^= bar ();
+      a[1] ^= bar ();
+    }
+}
+
+static inline char bar1 (void)
+{
+}
+
+void foo1 (int n)
+{
+  while (n--)
+    {
+      a[0] ^= bar1 ();
+      a[1] ^= bar1 ();
+    }
+}
+
+/* { dg-final { cleanup-tree-dump "vect" } } */
Index: testsuite/gcc.dg/vect/pr46049.c
===================================================================
--- testsuite/gcc.dg/vect/pr46049.c     (revision 0)
+++ testsuite/gcc.dg/vect/pr46049.c     (revision 0)
@@ -0,0 +1,21 @@ 
+/* { dg-do compile } */
+
+typedef __INT16_TYPE__ int16_t;
+typedef __INT32_TYPE__ int32_t;
+
+static inline int32_t bar (int16_t x, int16_t y)
+{
+  return x * y;
+}
+
+void foo (int16_t i, int16_t *p, int16_t x)
+{
+  while (i--)
+    {
+      *p = bar (*p, x) >> 15;
+      p++;
+      *p = bar (*p, x) >> 15;
+      p++;
+    }
+}
+/* { dg-final { cleanup-tree-dump "vect" } } */
Index: tree-vect-slp.c
===================================================================
--- tree-vect-slp.c     (revision 165574)
+++ tree-vect-slp.c     (working copy)
@@ -1902,8 +1902,8 @@  vect_get_constant_vectors (slp_tree slp_
   /* For POINTER_PLUS_EXPR we use the type of the constant/invariant
itself.
      If OP is the first operand of POINTER_PLUS_EXPR, its type is the type
of
      the statement, so it's OK to use OP's type for both first and second
-     operands.  */
-  if (code == POINTER_PLUS_EXPR)
+     operands.  We also use the type of OP if it's an invariant variable.
*/
+  if (code == POINTER_PLUS_EXPR || !constant_p)