This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [patch] Cleanup code generation in lambda-code


Hi,

Here is another patch with which it is now possible to vectorize the code
generated by lambda.  The patch eliminates the old induction variables
once we rewrote everything in function of the new ivs.  Bootstrapped and
tested on i686-linux.  Okay for trunk?

Sebastian
2007-06-06  Jan Sjodin  <jan.sjodin@amd.com>
	    Sebastian Pop  <sebpop@gmail.com>

	* lambda-code.c (remove_iv): New.
	(lambda_loopnest_to_gcc_loopnest): Use remove_iv.

Index: lambda-code.c
===================================================================
*** lambda-code.c	(revision 125355)
--- lambda-code.c	(working copy)
*************** lle_to_gcc_expression (lambda_linear_exp
*** 1616,1621 ****
--- 1616,1660 ----
    return force_gimple_operand (fold (expr), stmts_to_insert, true, resvar);
  }
  
+ /* Remove the induction variable defined at IV_STMT.  */
+ 
+ static void
+ remove_iv (tree iv_stmt)
+ {
+   if (TREE_CODE (iv_stmt) == PHI_NODE)
+     {
+       int i;
+ 
+       for (i = 0; i < PHI_NUM_ARGS (iv_stmt); i++)
+ 	{
+ 	  tree stmt;
+ 	  imm_use_iterator imm_iter;
+ 	  tree arg = PHI_ARG_DEF (iv_stmt, i);
+ 	  bool used = false;
+ 
+ 	  if (TREE_CODE (arg) != SSA_NAME)
+ 	    continue;
+ 
+ 	  FOR_EACH_IMM_USE_STMT (stmt, imm_iter, arg)
+ 	    if (stmt != iv_stmt)
+ 	      used = true;
+ 
+ 	  if (!used)
+ 	    remove_iv (SSA_NAME_DEF_STMT (arg));
+ 	}
+ 
+       remove_phi_node (iv_stmt, NULL_TREE, true);
+     }
+   else
+     {
+       block_stmt_iterator bsi = bsi_for_stmt (iv_stmt);
+ 
+       bsi_remove (&bsi, true);
+       release_defs (iv_stmt); 
+     }
+ }
+ 
+ 
  /* Transform a lambda loopnest NEW_LOOPNEST, which had TRANSFORM applied to
     it, back into gcc code.  This changes the
     loops, their induction variables, and their bodies, so that they
*************** lambda_loopnest_to_gcc_loopnest (struct 
*** 1797,1802 ****
--- 1836,1844 ----
  	    propagate_value (use_p, newiv);
  	  update_stmt (stmt);
  	}
+ 
+       /* Remove the now unused induction variable.  */
+       remove_iv (oldiv_stmt);
      }
    VEC_free (tree, heap, new_ivs);
  }

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]