* [autovect, patch] Don't allow constants of different types in SLP group
@ 2007-08-12 11:38 Ira Rosen
0 siblings, 0 replies; only message in thread
From: Ira Rosen @ 2007-08-12 11:38 UTC (permalink / raw)
To: gcc-patches
[-- Attachment #1: Type: text/plain, Size: 662 bytes --]
Don't allow constants of different types in scalar statements packed into
the same SLP group.
For example,
for i
ptr->a = 0;
ptr->b = 1;
ptr->c = NULL;
ptr->d = NULL;
should not get SLPed. Otherwise, vector that contains constants of
different types is created: {0, 1, 0B, 0B} in the above example.
Bootstrapped and tested on ppc-linux and i386-linux.
Committed to autovect branch.
Ira
ChangeLog:
* tree-vect-analyze.c (vect_get_and_check_slp_defs): Add new
argument.
Check that constant operands are of the same type.
(vect_build_slp_tree): Update arguments of
vect_get_and_check_slp_defs.
(See attached file: consts.txt)
[-- Attachment #2: consts.txt --]
[-- Type: text/plain, Size: 4093 bytes --]
Index: testsuite/ChangeLog.autovect
===================================================================
--- testsuite/ChangeLog.autovect (revision 127371)
+++ testsuite/ChangeLog.autovect (working copy)
@@ -1,3 +1,7 @@
+2007-08-12 Ira Rosen <irar@il.ibm.com>
+
+ * gcc.dg/vect/slp-37.c: New.
+
2007-08-05 Ira Rosen <irar@il.ibm.com>
* gcc.dg/vect/slp-36.c: Add comments.
Index: testsuite/gcc.dg/vect/slp-37.c
===================================================================
--- testsuite/gcc.dg/vect/slp-37.c (revision 0)
+++ testsuite/gcc.dg/vect/slp-37.c (revision 0)
@@ -0,0 +1,67 @@
+/* { dg-require-effective-target vect_int } */
+
+#include <stdarg.h>
+#include <stdlib.h>
+#include "tree-vect.h"
+
+#define N 128
+
+typedef struct {
+ int a;
+ int b;
+ void *c;
+} s1;
+
+int
+foo1 (s1 *arr)
+{
+ int i;
+ s1 *ptr = arr;
+
+ /* Different constant types - not SLPable. The group size is not power of 2,
+ interleaving is not supported either. */
+ for (i = 0; i < N; i++)
+ {
+ ptr->a = 6;
+ ptr->b = 7;
+ ptr->c = NULL;
+ ptr++;
+ }
+
+ /* check results: */
+ for (i = 0; i < N; i++)
+ {
+ if (arr[i].a != 6
+ || arr[i].b != 7
+ || arr[i].c != NULL)
+ abort();
+ }
+}
+
+int main (void)
+{
+ int i;
+ s1 arr1[N];
+
+ check_vect ();
+
+ for (i = 0; i < N; i++)
+ {
+ arr1[i].a = i;
+ arr1[i].b = i * 2;
+ arr1[i].c = (void *)arr1;
+
+ if (arr1[i].a == 178)
+ abort();
+ }
+
+
+ foo1 (arr1);
+
+ return 0;
+}
+
+/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 0 "vect" } } */
+/* { dg-final { scan-tree-dump-times "vectorizing stmts using SLP" 0 "vect" } } */
+/* { dg-final { cleanup-tree-dump "vect" } } */
+
Index: tree-vect-analyze.c
===================================================================
--- tree-vect-analyze.c (revision 127371)
+++ tree-vect-analyze.c (working copy)
@@ -2205,6 +2205,7 @@ vect_get_and_check_slp_defs (loop_vec_in
enum vect_def_type *first_stmt_dt1,
tree *first_stmt_def0_type,
tree *first_stmt_def1_type,
+ tree *first_stmt_const_oprnd,
int ncopies_for_cost)
{
tree oprnd;
@@ -2246,6 +2247,8 @@ vect_get_and_check_slp_defs (loop_vec_in
*first_stmt_dt0 = dt[i];
if (def)
*first_stmt_def0_type = TREE_TYPE (def);
+ else
+ *first_stmt_const_oprnd = oprnd;
/* Analyze costs (for the first stmt of the group only). */
if (op_type)
@@ -2264,6 +2267,10 @@ vect_get_and_check_slp_defs (loop_vec_in
*first_stmt_dt1 = dt[i];
if (def)
*first_stmt_def1_type = TREE_TYPE (def);
+ else
+ /* We assume that the stmt constains only one constant
+ operand. */
+ *first_stmt_const_oprnd = oprnd;
}
else
{
@@ -2276,7 +2283,10 @@ vect_get_and_check_slp_defs (loop_vec_in
|| (i == 1
&& (*first_stmt_dt1 != dt[i]
|| (*first_stmt_def1_type && def
- && *first_stmt_def1_type != TREE_TYPE (def)))))
+ && *first_stmt_def1_type != TREE_TYPE (def))))
+ || (!def
+ && TREE_TYPE (*first_stmt_const_oprnd)
+ != TREE_TYPE (oprnd)))
{
if (vect_print_dump_info (REPORT_DETAILS))
fprintf (vect_dump, "Build SLP failed: different types ");
@@ -2345,6 +2355,7 @@ vect_build_slp_tree (loop_vec_info loop_
int icode;
enum machine_mode optab_op2_mode;
enum machine_mode vec_mode;
+ tree first_stmt_const_oprnd = NULL_TREE;
/* For every stmt in NODE find its def stmt/s. */
for (i = 0; VEC_iterate (tree, stmts, i, stmt); i++)
@@ -2449,6 +2460,7 @@ vect_build_slp_tree (loop_vec_info loop_
&first_stmt_dt1,
&first_stmt_def0_type,
&first_stmt_def1_type,
+ &first_stmt_const_oprnd,
ncopies_for_cost))
return false;
}
@@ -2533,6 +2545,7 @@ vect_build_slp_tree (loop_vec_info loop_
&first_stmt_dt1,
&first_stmt_def0_type,
&first_stmt_def1_type,
+ &first_stmt_const_oprnd,
ncopies_for_cost))
return false;
}
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2007-08-12 11:38 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-08-12 11:38 [autovect, patch] Don't allow constants of different types in SLP group Ira Rosen
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).