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] Miscelaneous ivopts improvements (2 of 3)


Hello,

the second patch is the ivopts part of a partially reviewed patch
for PR 18219.  See
http://gcc.gnu.org/ml/gcc-patches/2004-11/msg00025.html for details.

Bootstrapped & regtested on i686.

Zdenek

	* tree-ssa-loop-ivopts.c (get_computation_at): Produce computations
	in distributed form.

Index: tree-ssa-loop-ivopts.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/tree-ssa-loop-ivopts.c,v
retrieving revision 2.35
diff -c -3 -p -r2.35 tree-ssa-loop-ivopts.c
*** tree-ssa-loop-ivopts.c	7 Dec 2004 21:23:04 -0000	2.35
--- tree-ssa-loop-ivopts.c	15 Dec 2004 01:01:15 -0000
*************** get_computation_at (struct loop *loop,
*** 2307,2316 ****
    if (stmt_after_increment (loop, cand, at))
      cbase = fold (build2 (PLUS_EXPR, uutype, cbase, cstep));
  
!   /* use = ubase + ratio * (var - cbase).  If either cbase is a constant
!      or |ratio| == 1, it is better to handle this like
!      
!      ubase - ratio * cbase + ratio * var.  */
  
    if (ratioi == 1)
      {
--- 2404,2416 ----
    if (stmt_after_increment (loop, cand, at))
      cbase = fold (build2 (PLUS_EXPR, uutype, cbase, cstep));
  
!   /* use = ubase - ratio * cbase + ratio * var.
! 
!      In general case ubase + ratio * (var - cbase) could be better (one less
!      multiplication), but often it is possible to eliminate redundant parts
!      of computations from (ubase - ratio * cbase) term, and if it does not
!      happen, fold is able to apply the distributive law to obtain this form
!      anyway.  */
  
    if (ratioi == 1)
      {
*************** get_computation_at (struct loop *loop,
*** 2322,2328 ****
        delta = fold (build2 (PLUS_EXPR, uutype, ubase, cbase));
        expr = fold (build2 (MINUS_EXPR, uutype, delta, expr));
      }
!   else if (TREE_CODE (cbase) == INTEGER_CST)
      {
        ratio = build_int_cst_type (uutype, ratioi);
        delta = fold (build2 (MULT_EXPR, uutype, ratio, cbase));
--- 2422,2428 ----
        delta = fold (build2 (PLUS_EXPR, uutype, ubase, cbase));
        expr = fold (build2 (MINUS_EXPR, uutype, delta, expr));
      }
!   else
      {
        ratio = build_int_cst_type (uutype, ratioi);
        delta = fold (build2 (MULT_EXPR, uutype, ratio, cbase));
*************** get_computation_at (struct loop *loop,
*** 2330,2342 ****
        expr = fold (build2 (MULT_EXPR, uutype, ratio, expr));
        expr = fold (build2 (PLUS_EXPR, uutype, delta, expr));
      }
-   else
-     {
-       expr = fold (build2 (MINUS_EXPR, uutype, expr, cbase));
-       ratio = build_int_cst_type (uutype, ratioi);
-       expr = fold (build2 (MULT_EXPR, uutype, ratio, expr));
-       expr = fold (build2 (PLUS_EXPR, uutype, ubase, expr));
-     }
  
    return fold_convert (utype, expr);
  }
--- 2430,2435 ----


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