summaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorrguenth <rguenth@138bc75d-0d04-0410-961f-82ee72b054a4>2006-11-30 14:30:00 +0000
committerrguenth <rguenth@138bc75d-0d04-0410-961f-82ee72b054a4>2006-11-30 14:30:00 +0000
commit4957645dcb9d4a3b980a487c3b33f93cb378a326 (patch)
treeaf44eced0f1123048c473eb4dc1a457dd2088947 /gcc
parent8a355d81c3be6ea2e6f9cfae2d5b5ff1a28349b2 (diff)
downloadgcc-4957645dcb9d4a3b980a487c3b33f93cb378a326.tar.gz
2006-11-30 Richard Guenther <rguenther@suse.de>
* tree-vectorizer.h (vectorizable_function): Export. * tree-vect-transform.c (vectorizable_function): Likewise. * tree-vect-patterns.c (vect_recog_pow_pattern): Set type_in to scalar type in recognition of squaring. Make sure the target can vectorize sqrt in recognition of sqrt, set type_in to vector type in this case. * gcc.dg/vect/vect-pow-1.c: Rename ... * gcc.dg/vect/fast-math-vect-pow-1.c: ... to this. Use floats instead of doubles, check successful vectorization. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@119362 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ChangeLog9
-rw-r--r--gcc/testsuite/ChangeLog6
-rw-r--r--gcc/testsuite/gcc.dg/vect/fast-math-vect-pow-1.c14
-rw-r--r--gcc/testsuite/gcc.dg/vect/vect-pow-1.c14
-rw-r--r--gcc/tree-vect-patterns.c14
-rw-r--r--gcc/tree-vect-transform.c2
-rw-r--r--gcc/tree-vectorizer.h1
7 files changed, 42 insertions, 18 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index e12b3ff77b1..a73f82a496b 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,12 @@
+2006-11-30 Richard Guenther <rguenther@suse.de>
+
+ * tree-vectorizer.h (vectorizable_function): Export.
+ * tree-vect-transform.c (vectorizable_function): Likewise.
+ * tree-vect-patterns.c (vect_recog_pow_pattern): Set
+ type_in to scalar type in recognition of squaring.
+ Make sure the target can vectorize sqrt in recognition
+ of sqrt, set type_in to vector type in this case.
+
2006-11-30 Uros Bizjak <ubizjak@gmail.com>
* config/i386/i386.md (R10_REG): New constant.
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 0de57600ab9..dc05938ab5d 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,9 @@
+2006-11-30 Richard Guenther <rguenther@suse.de>
+
+ * gcc.dg/vect/vect-pow-1.c: Rename ...
+ * gcc.dg/vect/fast-math-vect-pow-1.c: ... to this. Use
+ floats instead of doubles, check successful vectorization.
+
2006-11-29 Andrew Pinski <andrew_pinski@playstation.sony.com>
PR target/29945
diff --git a/gcc/testsuite/gcc.dg/vect/fast-math-vect-pow-1.c b/gcc/testsuite/gcc.dg/vect/fast-math-vect-pow-1.c
new file mode 100644
index 00000000000..4d000f192f1
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/vect/fast-math-vect-pow-1.c
@@ -0,0 +1,14 @@
+/* { dg-do compile } */
+/* { dg-require-effective-target vect_float } */
+
+float x[256];
+
+void foo(void)
+{
+ int i;
+ for (i=0; i<256; ++i)
+ x[i] = x[i] * x[i];
+}
+
+/* { dg-final { scan-tree-dump "vectorized 1 loops" "vect" } } */
+/* { dg-final { cleanup-tree-dump "vect" } } */
diff --git a/gcc/testsuite/gcc.dg/vect/vect-pow-1.c b/gcc/testsuite/gcc.dg/vect/vect-pow-1.c
deleted file mode 100644
index 2c29cbaf6de..00000000000
--- a/gcc/testsuite/gcc.dg/vect/vect-pow-1.c
+++ /dev/null
@@ -1,14 +0,0 @@
-/* { dg-do compile } */
-/* { dg-options "-O2 -ftree-vectorize -ffast-math -fdump-tree-vect-details" } */
-
-double x[256];
-
-void foo(void)
-{
- int i;
- for (i=0; i<256; ++i)
- x[i] = x[i] * x[i];
-}
-
-/* { dg-final { scan-tree-dump "pattern recognized" "vect" } } */
-/* { dg-final { cleanup-tree-dump "vect" } } */
diff --git a/gcc/tree-vect-patterns.c b/gcc/tree-vect-patterns.c
index 3e40fc79b5a..6d5d3dcf35c 100644
--- a/gcc/tree-vect-patterns.c
+++ b/gcc/tree-vect-patterns.c
@@ -466,7 +466,6 @@ vect_recog_pow_pattern (tree last_stmt, tree *type_in, tree *type_out)
/* We now have a pow or powi builtin function call with a constant
exponent. */
- *type_in = get_vectype_for_scalar_type (TREE_TYPE (base));
*type_out = NULL_TREE;
/* Catch squaring. */
@@ -474,7 +473,10 @@ vect_recog_pow_pattern (tree last_stmt, tree *type_in, tree *type_out)
&& tree_low_cst (exp, 0) == 2)
|| (TREE_CODE (exp) == REAL_CST
&& REAL_VALUES_EQUAL (TREE_REAL_CST (exp), dconst2)))
- return build2 (MULT_EXPR, TREE_TYPE (base), base, base);
+ {
+ *type_in = TREE_TYPE (base);
+ return build2 (MULT_EXPR, TREE_TYPE (base), base, base);
+ }
/* Catch square root. */
if (TREE_CODE (exp) == REAL_CST
@@ -482,7 +484,13 @@ vect_recog_pow_pattern (tree last_stmt, tree *type_in, tree *type_out)
{
tree newfn = mathfn_built_in (TREE_TYPE (base), BUILT_IN_SQRT);
tree newarglist = build_tree_list (NULL_TREE, base);
- return build_function_call_expr (newfn, newarglist);
+ *type_in = get_vectype_for_scalar_type (TREE_TYPE (base));
+ if (*type_in)
+ {
+ newfn = build_function_call_expr (newfn, newarglist);
+ if (vectorizable_function (newfn, *type_in))
+ return newfn;
+ }
}
return NULL_TREE;
diff --git a/gcc/tree-vect-transform.c b/gcc/tree-vect-transform.c
index 84ae19facfd..769b4af10b0 100644
--- a/gcc/tree-vect-transform.c
+++ b/gcc/tree-vect-transform.c
@@ -1570,7 +1570,7 @@ vectorizable_reduction (tree stmt, block_stmt_iterator *bsi, tree *vec_stmt)
true if the target has a vectorized version of the function,
or false if the function cannot be vectorized. */
-static bool
+bool
vectorizable_function (tree call, tree vectype)
{
tree fndecl = get_callee_fndecl (call);
diff --git a/gcc/tree-vectorizer.h b/gcc/tree-vectorizer.h
index 6af68a319f8..0c026b14d0c 100644
--- a/gcc/tree-vectorizer.h
+++ b/gcc/tree-vectorizer.h
@@ -398,6 +398,7 @@ extern bool vectorizable_operation (tree, block_stmt_iterator *, tree *);
extern bool vectorizable_type_promotion (tree, block_stmt_iterator *, tree *);
extern bool vectorizable_type_demotion (tree, block_stmt_iterator *, tree *);
extern bool vectorizable_assignment (tree, block_stmt_iterator *, tree *);
+extern bool vectorizable_function (tree, tree);
extern bool vectorizable_call (tree, block_stmt_iterator *, tree *);
extern bool vectorizable_condition (tree, block_stmt_iterator *, tree *);
extern bool vectorizable_live_operation (tree, block_stmt_iterator *, tree *);