public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH][Cilkplus] Did an induction variable optimization
@ 2012-06-06  1:18 Iyer, Balaji V
  0 siblings, 0 replies; only message in thread
From: Iyer, Balaji V @ 2012-06-06  1:18 UTC (permalink / raw)
  To: gcc-patches

[-- Attachment #1: Type: text/plain, Size: 240 bytes --]

 
Hello Everyone,
   This patch is for the Cilkplus branch affecting the C compiler. This patch will remove an unwanted conversion of the induction variable in the cilk_for function.

Thanking You,

Yours Sincerely,

Balaji V. Iyer.

[-- Attachment #2: patch_to_move_induction_variable.txt --]
[-- Type: text/plain, Size: 2707 bytes --]

Index: gcc/cilk-spawn.c
===================================================================
--- gcc/cilk-spawn.c	(revision 188251)
+++ gcc/cilk-spawn.c	(working copy)
@@ -2290,9 +2290,6 @@
   int incr_sign = cfd->incr_sign;
   enum tree_code add_op = incr_sign >= 0 ? PLUS_EXPR : MINUS_EXPR;
 
-  gcc_assert (TYPE_MAIN_VARIANT (TREE_TYPE (loop_var)) ==
-	      TYPE_MAIN_VARIANT (count_type));
-
   /* Compute an expression to be added or subtracted.
 
      We want to add or subtract LOOP_VAR * INCR.  INCR may be negative.
@@ -2374,8 +2371,8 @@
   tree body, block;
   tree lower_bound;
   tree loop_var;
-  tree count_type;
   tree tempx,tempy;
+
   declare_cilk_for_parms (cfd);
 
   cfd->wd.fntype = build_function_type (void_type_node, cfd->wd.argtypes);
@@ -2420,14 +2417,12 @@
       lower_bound = hack;
     }
   loop_var = build_decl (UNKNOWN_LOCATION, VAR_DECL, NULL_TREE,
-			 TREE_TYPE (cfd->min_parm));
+			 cfd->var_type);
   DECL_CONTEXT (loop_var) = fndecl;
-  add_stmt (build2 (INIT_EXPR, void_type_node, loop_var, cfd->min_parm));
+  add_stmt (build_modify_expr (UNKNOWN_LOCATION, loop_var, TREE_TYPE (loop_var),
+			       NOP_EXPR, UNKNOWN_LOCATION,
+			       cfd->min_parm, TREE_TYPE (cfd->min_parm)));
 
-  count_type = cfd->count_type;
-  gcc_assert (TYPE_MAIN_VARIANT (TREE_TYPE (loop_var)) ==
-	      TYPE_MAIN_VARIANT (count_type));
-
   /* The new loop body is
 
      var2 = (T)((control variable) * INCR + (lower bound));
@@ -2464,14 +2459,15 @@
     add_stmt (loop_body);
 
     tempx = build2 (MODIFY_EXPR, void_type_node, loop_var,
-		    build2 (PLUS_EXPR, count_type,
+		    build2 (PLUS_EXPR, TREE_TYPE (loop_var),
 			    loop_var,
-			    build_int_cst (count_type, 1)));
+			    build_int_cst (TREE_TYPE (loop_var), 1)));
     add_stmt(tempx);
     
     tempy = build3 (COND_EXPR, void_type_node,
 		    build2 (LT_EXPR, boolean_type_node, loop_var,
-			    cfd->max_parm),
+			    build_c_cast (UNKNOWN_LOCATION,
+					  TREE_TYPE (loop_var), cfd->max_parm)),
 		    build1 (GOTO_EXPR, void_type_node, lab),
 		    build_empty_stmt (UNKNOWN_LOCATION));
 
Index: gcc/ChangeLog.cilk
===================================================================
--- gcc/ChangeLog.cilk	(revision 188251)
+++ gcc/ChangeLog.cilk	(working copy)
@@ -1,3 +1,10 @@
+2012-06-05  Balaji V. Iyer  <balaji.v.iyer@intel.com>
+
+	* cilk-spawn.c (compute_loop_var): Removed an unwanted assert.
+	(build_cilk_for_body): Changed var type from min_parms's to the original
+	var_type. This change is propagated in several places with the
+	appropriate type conversions.
+
 2012-06-02  Balaji V. Iyer  <balaji.v.iyer@intel.com>
 
 	* tree-inline.c (remap_gimple_op_r): Added a check for NON-NULL

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

only message in thread, other threads:[~2012-06-06  1:00 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-06-06  1:18 [PATCH][Cilkplus] Did an induction variable optimization Iyer, Balaji V

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