OSDN Git Service

2010-11-04 Richard Guenther <rguenther@suse.de>
authorrguenth <rguenth@138bc75d-0d04-0410-961f-82ee72b054a4>
Thu, 4 Nov 2010 12:42:57 +0000 (12:42 +0000)
committerrguenth <rguenth@138bc75d-0d04-0410-961f-82ee72b054a4>
Thu, 4 Nov 2010 12:42:57 +0000 (12:42 +0000)
PR tree-optimization/45733
* tree-vect-stmts.c (reverse_vec_elements): Honor the
permute builtins function return type.

* gcc.dg/pr45733.c: New testcase.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@166308 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/ChangeLog
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/pr45733.c [new file with mode: 0644]
gcc/tree-vect-stmts.c

index 213846d..a2e1cc8 100644 (file)
@@ -1,3 +1,9 @@
+2010-11-04  Richard Guenther  <rguenther@suse.de>
+
+       PR tree-optimization/45733
+       * tree-vect-stmts.c (reverse_vec_elements): Honor the
+       permute builtins function return type.
+
 2010-10-04  Joern Rennecke  <amylaar@spamcop.net>
 
        PR middle-end/44765
index 66fb730..d4bfc69 100644 (file)
@@ -1,3 +1,8 @@
+2010-11-04  Richard Guenther  <rguenther@suse.de>
+
+       PR tree-optimization/45733
+       * gcc.dg/pr45733.c: New testcase.
+
 2010-11-04  Ira Rosen  <irar@il.ibm.com>
 
        PR tree-optimization/46213
diff --git a/gcc/testsuite/gcc.dg/pr45733.c b/gcc/testsuite/gcc.dg/pr45733.c
new file mode 100644 (file)
index 0000000..5c83cd4
--- /dev/null
@@ -0,0 +1,13 @@
+/* { dg-do compile } */
+/* { dg-options "-O -fstrict-overflow -ftree-vectorize" } */
+
+typedef __INTPTR_TYPE__ intptr_t;
+
+intptr_t
+foo (void **p, int i)
+{
+  intptr_t x = 0;
+  while (i--)
+    x ^= (intptr_t) p[i];
+  return x;
+}
index 2dbc035..3d18dfe 100644 (file)
@@ -3742,8 +3742,19 @@ reverse_vec_elements (tree x, gimple stmt, gimple_stmt_iterator *gsi)
 
   /* Generate the permute statement.  */
   perm_stmt = gimple_build_call (builtin_decl, 3, x, x, mask_vec);
+  if (!useless_type_conversion_p (vectype,
+                                 TREE_TYPE (TREE_TYPE (builtin_decl))))
+    {
+      tree tem = create_tmp_reg (TREE_TYPE (TREE_TYPE (builtin_decl)), NULL);
+      tem = make_ssa_name (tem, perm_stmt);
+      gimple_call_set_lhs (perm_stmt, tem);
+      vect_finish_stmt_generation (stmt, perm_stmt, gsi);
+      perm_stmt = gimple_build_assign (NULL_TREE,
+                                      build1 (VIEW_CONVERT_EXPR,
+                                              vectype, tem));
+    }
   data_ref = make_ssa_name (perm_dest, perm_stmt);
-  gimple_call_set_lhs (perm_stmt, data_ref);
+  gimple_set_lhs (perm_stmt, data_ref);
   vect_finish_stmt_generation (stmt, perm_stmt, gsi);
 
   return data_ref;