[PATCH] Fix PR45733

Richard Guenther rguenther@suse.de
Thu Nov 4 12:48:00 GMT 2010


This fixes PR45733, we have to assume that target builtins may not
exactly match the types we need.  As we verify return types insert
conversions appropriately here.

Bootstrapped and tested on x86_64-unknown-linxu-gnu, applied.

Richard.

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.

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

Index: gcc/tree-vect-stmts.c
===================================================================
*** gcc/tree-vect-stmts.c	(revision 166304)
--- gcc/tree-vect-stmts.c	(working copy)
*************** reverse_vec_elements (tree x, gimple stm
*** 3742,3749 ****
  
    /* Generate the permute statement.  */
    perm_stmt = gimple_build_call (builtin_decl, 3, x, x, mask_vec);
    data_ref = make_ssa_name (perm_dest, perm_stmt);
!   gimple_call_set_lhs (perm_stmt, data_ref);
    vect_finish_stmt_generation (stmt, perm_stmt, gsi);
  
    return data_ref;
--- 3742,3760 ----
  
    /* 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_set_lhs (perm_stmt, data_ref);
    vect_finish_stmt_generation (stmt, perm_stmt, gsi);
  
    return data_ref;
Index: gcc/testsuite/gcc.dg/pr45733.c
===================================================================
*** gcc/testsuite/gcc.dg/pr45733.c	(revision 0)
--- gcc/testsuite/gcc.dg/pr45733.c	(revision 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;
+ }



More information about the Gcc-patches mailing list