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]

[patch,commited] Enable versioning and unrolling outer loops


Hello,

this patch makes the gimple loop unrolling and versioning functions work
for non-innermost loops -- actually, except for removing the check in
loop_version, only minor fix to loop exit updating was needed.  The
chnages in tree-ssa-loop-niter.c and tree-ssa-loop-manip.c fix
pointer_plus bugs I found while testing this change.

Bootstrapped & regtested on ia64.  Commited.

Zdenek

Index: ChangeLog
===================================================================
*** ChangeLog	(revision 126795)
--- ChangeLog	(working copy)
***************
*** 1,3 ****
--- 1,12 ----
+ 2007-07-20  Zdenek Dvorak  <dvorakz@suse.cz>
+ 
+ 	* tree-ssa-loop-niter.c (assert_loop_rolls_lt): Convert the operands
+ 	of compare to the same type.
+ 	* cfgloopmanip.c (add_loop): Update information about loop exits.
+ 	(loop_version): Remove the innermost loop requirement.
+ 	* tree-ssa-loop-manip.c (determine_exit_conditions): Convert bounds
+ 	to sizetype for pointers.
+ 
  2007-07-18  H.J. Lu  <hongjiu.lu@intel.com>
  
  	* Makefile.in (D32PBIT_FUNCS): Add _sd_to_tf and _tf_to_sd.
Index: tree-ssa-loop-niter.c
===================================================================
*** tree-ssa-loop-niter.c	(revision 126795)
--- tree-ssa-loop-niter.c	(working copy)
*************** assert_loop_rolls_lt (tree type, affine_
*** 918,925 ****
  
        /* And then we can compute iv0->base - diff, and compare it with
  	 iv1->base.  */      
!       mbzl = fold_build2 (MINUS_EXPR, type1, iv0->base, diff);
!       mbzr = iv1->base;
      }
    else
      {
--- 918,926 ----
  
        /* And then we can compute iv0->base - diff, and compare it with
  	 iv1->base.  */      
!       mbzl = fold_build2 (MINUS_EXPR, type1, 
! 			  fold_convert (type1, iv0->base), diff);
!       mbzr = fold_convert (type1, iv1->base);
      }
    else
      {
*************** assert_loop_rolls_lt (tree type, affine_
*** 934,941 ****
  				    iv1->base, bound);
  	}
  
!       mbzl = iv0->base;
!       mbzr = fold_build2 (MINUS_EXPR, type1, iv1->base, diff);
      }
  
    if (!integer_nonzerop (assumption))
--- 935,943 ----
  				    iv1->base, bound);
  	}
  
!       mbzl = fold_convert (type1, iv0->base);
!       mbzr = fold_build2 (MINUS_EXPR, type1,
! 			  fold_convert (type1, iv1->base), diff);
      }
  
    if (!integer_nonzerop (assumption))
Index: cfgloopmanip.c
===================================================================
*** cfgloopmanip.c	(revision 126795)
--- cfgloopmanip.c	(working copy)
*************** add_loop (struct loop *loop, struct loop
*** 411,416 ****
--- 411,418 ----
    basic_block *bbs;
    int i, n;
    struct loop *subloop;
+   edge e;
+   edge_iterator ei;
  
    /* Add it to loop structure.  */
    place_new_loop (loop);
*************** add_loop (struct loop *loop, struct loop
*** 441,446 ****
--- 443,457 ----
  	}
      }
  
+   /* Update the information about loop exit edges.  */
+   for (i = 0; i < n; i++)
+     {
+       FOR_EACH_EDGE (e, ei, bbs[i]->succs)
+ 	{
+ 	  rescan_loop_exit (e, false, false);
+ 	}
+     }
+ 
    free (bbs);
  }
  
*************** loop_version (struct loop *loop,
*** 1283,1292 ****
    struct loop *nloop;
    basic_block cond_bb;
  
-   /* CHECKME: Loop versioning does not handle nested loop at this point.  */
-   if (loop->inner)
-     return NULL;
- 
    /* Record entry and latch edges for the loop */
    entry = loop_preheader_edge (loop);
    irred_flag = entry->flags & EDGE_IRREDUCIBLE_LOOP;
--- 1294,1299 ----
Index: tree-ssa-loop-manip.c
===================================================================
*** tree-ssa-loop-manip.c	(revision 126795)
--- tree-ssa-loop-manip.c	(working copy)
*************** determine_exit_conditions (struct loop *
*** 670,682 ****
    tree base = desc->control.base;
    tree step = desc->control.step;
    tree bound = desc->bound;
!   tree type = TREE_TYPE (base);
    tree bigstep, delta;
    tree min = lower_bound_in_type (type, type);
    tree max = upper_bound_in_type (type, type);
    enum tree_code cmp = desc->cmp;
    tree cond = boolean_true_node, assum;
  
    *enter_cond = boolean_false_node;
    *exit_base = NULL_TREE;
    *exit_step = NULL_TREE;
--- 670,686 ----
    tree base = desc->control.base;
    tree step = desc->control.step;
    tree bound = desc->bound;
!   tree type = TREE_TYPE (step);
    tree bigstep, delta;
    tree min = lower_bound_in_type (type, type);
    tree max = upper_bound_in_type (type, type);
    enum tree_code cmp = desc->cmp;
    tree cond = boolean_true_node, assum;
  
+   /* For pointers, do the arithmetics in the type of step (sizetype).  */
+   base = fold_convert (type, base);
+   bound = fold_convert (type, bound);
+ 
    *enter_cond = boolean_false_node;
    *exit_base = NULL_TREE;
    *exit_step = NULL_TREE;


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