]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR tree-optimization/18219 (bloats code by 31%)
authorZdenek Dvorak <dvorakz@suse.cz>
Sun, 6 Feb 2005 18:47:12 +0000 (19:47 +0100)
committerZdenek Dvorak <rakdver@gcc.gnu.org>
Sun, 6 Feb 2005 18:47:12 +0000 (18:47 +0000)
PR tree-optimization/18219
* tree-ssa-loop-ivopts.c (get_computation_at): Produce computations
in distributed form.

From-SVN: r94680

gcc/ChangeLog
gcc/tree-ssa-loop-ivopts.c

index e02434e999df063381702a1a6fa559e5f31b3151..83c0ed5836e68c7254dd51ee51e7a7e0ff202ade 100644 (file)
@@ -1,3 +1,9 @@
+2005-02-06  Zdenek Dvorak  <dvorakz@suse.cz>
+
+       PR tree-optimization/18219
+       * tree-ssa-loop-ivopts.c (get_computation_at): Produce computations
+       in distributed form.
+
 2005-02-06  Richard Sandiford  <rsandifo@redhat.com>
 
        * expmed.c (store_bit_field): Make the SUBREG code adjust bitnum.
index 3288080ac52873f096cbe953d832394dcffd097e..05f4a8da7bbdb32f5e6aeef942b6b0182f60e9e7 100644 (file)
@@ -2376,10 +2376,13 @@ get_computation_at (struct loop *loop,
   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.  */
+  /* 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)
     {
@@ -2391,7 +2394,7 @@ get_computation_at (struct loop *loop,
       delta = fold (build2 (PLUS_EXPR, uutype, ubase, cbase));
       expr = fold (build2 (MINUS_EXPR, uutype, delta, expr));
     }
-  else if (TREE_CODE (cbase) == INTEGER_CST)
+  else
     {
       ratio = build_int_cst_type (uutype, ratioi);
       delta = fold (build2 (MULT_EXPR, uutype, ratio, cbase));
@@ -2399,13 +2402,6 @@ get_computation_at (struct loop *loop,
       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);
 }