public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] Fix PR56366
@ 2013-02-18 12:00 Richard Biener
  0 siblings, 0 replies; only message in thread
From: Richard Biener @ 2013-02-18 12:00 UTC (permalink / raw)
  To: gcc-patches


This fixes another case where missed sign-conversions during vectorization
need to be handled (outer-loop vectorization induction).

Bootstrap and regtest pending on x86_64-unknown-linux-gnu.

Richard.

2013-02-18  Richard Biener  <rguenther@suse.de>

	PR tree-optimization/56366
	* tree-vect-loop.c (get_initial_def_for_induction): Properly
	handle sign-conversion of outer-loop initial induction value.

	* gcc.dg/torture/pr56366.c: New testcase.

Index: gcc/tree-vect-loop.c
===================================================================
*** gcc/tree-vect-loop.c	(revision 196115)
--- gcc/tree-vect-loop.c	(working copy)
*************** get_initial_def_for_induction (gimple iv
*** 3203,3208 ****
--- 3203,3223 ----
        tree iv_def = PHI_ARG_DEF_FROM_EDGE (iv_phi,
                                             loop_preheader_edge (iv_loop));
        vec_init = vect_get_vec_def_for_operand (iv_def, iv_phi, NULL);
+       /* If the initial value is not of proper type, convert it.  */
+       if (!useless_type_conversion_p (vectype, TREE_TYPE (vec_init)))
+ 	{
+ 	  new_stmt = gimple_build_assign_with_ops
+ 	      (VIEW_CONVERT_EXPR,
+ 	       vect_get_new_vect_var (vectype, vect_simple_var, "vec_iv_"),
+ 	       build1 (VIEW_CONVERT_EXPR, vectype, vec_init), NULL_TREE);
+ 	  vec_init = make_ssa_name (gimple_assign_lhs (new_stmt), new_stmt);
+ 	  gimple_assign_set_lhs (new_stmt, vec_init);
+ 	  new_bb = gsi_insert_on_edge_immediate (loop_preheader_edge (iv_loop),
+ 						 new_stmt);
+ 	  gcc_assert (!new_bb);
+ 	  set_vinfo_for_stmt (new_stmt,
+ 			      new_stmt_vec_info (new_stmt, loop_vinfo, NULL));
+ 	}
      }
    else
      {
Index: gcc/testsuite/gcc.dg/torture/pr56366.c
===================================================================
*** gcc/testsuite/gcc.dg/torture/pr56366.c	(revision 0)
--- gcc/testsuite/gcc.dg/torture/pr56366.c	(working copy)
***************
*** 0 ****
--- 1,17 ----
+ /* { dg-do compile } */
+ 
+ int a, *c, d;
+ unsigned short b;
+ short e;
+ 
+ void f(void)
+ {
+   for(;; d++)
+     {
+       for(a = -9; a < 63; a++)
+ 	for(d = 0; d < 9; d++)
+ 	  b -= --e;
+ 
+       a = b & *c;
+     }
+ }

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2013-02-18 12:00 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-02-18 12:00 [PATCH] Fix PR56366 Richard Biener

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).