public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* Fix PR/46200 -- ivopt bug in test condition cost computation
@ 2010-10-29 23:10 Xinliang David Li
  2010-10-31  9:22 ` Zdenek Dvorak
  2010-11-05 20:40 ` H.J. Lu
  0 siblings, 2 replies; 11+ messages in thread
From: Xinliang David Li @ 2010-10-29 23:10 UTC (permalink / raw)
  To: GCC Patches; +Cc: Zdenek Dvorak

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

Hi, please review the patch attached. Regression and some performance
test is under going.

Thanks,

David


2010-10-29  Xinliang David Li  <davidxl@google.com>

	PR target/46200
	* tree-ssa-loop-ivopts.c (get_computation_cost_at):
	Adjust cbase if the use stmt is after iv update.

[-- Attachment #2: ivopt_46200.p --]
[-- Type: text/x-pascal, Size: 1702 bytes --]

Index: gcc/tree-ssa-loop-ivopts.c
===================================================================
--- gcc/tree-ssa-loop-ivopts.c	(revision 166032)
+++ gcc/tree-ssa-loop-ivopts.c	(working copy)
@@ -4027,6 +4027,8 @@ get_computation_cost_at (struct ivopts_d
   STRIP_NOPS (cbase);
   ctype = TREE_TYPE (cbase);
 
+  stmt_is_after_inc = stmt_after_increment (data->current_loop, cand, at);
+
   /* use = ubase + ratio * (var - cbase).  If either cbase is a constant
      or ratio == 1, it is better to handle this like
 
@@ -4045,8 +4047,24 @@ get_computation_cost_at (struct ivopts_d
     }
   else if (ratio == 1)
     {
+      tree real_cbase = cbase;
+
+      /* Check to see if any adjustment is needed.  */
+      if (cstepi == 0 && stmt_is_after_inc)
+        {
+          aff_tree real_cbase_aff;
+          aff_tree cstep_aff;
+
+          tree_to_aff_combination (cbase, TREE_TYPE (real_cbase),
+                                   &real_cbase_aff);
+          tree_to_aff_combination (cstep, TREE_TYPE (cstep), &cstep_aff);
+
+          aff_combination_add (&real_cbase_aff, &cstep_aff);
+          real_cbase = aff_combination_to_tree (&real_cbase_aff);
+        }
+
       cost = difference_cost (data,
-			      ubase, cbase,
+			      ubase, real_cbase,
 			      &symbol_present, &var_present, &offset,
 			      depends_on);
       cost.cost /= avg_loop_niter (data->current_loop);
@@ -4088,7 +4106,6 @@ get_computation_cost_at (struct ivopts_d
 
   /* If we are after the increment, the value of the candidate is higher by
      one iteration.  */
-  stmt_is_after_inc = stmt_after_increment (data->current_loop, cand, at);
   if (stmt_is_after_inc)
     offset -= ratio * cstepi;
 

^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2010-11-07 21:08 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-10-29 23:10 Fix PR/46200 -- ivopt bug in test condition cost computation Xinliang David Li
2010-10-31  9:22 ` Zdenek Dvorak
2010-11-01  6:59   ` Xinliang David Li
2010-11-02 17:15     ` Xinliang David Li
2010-11-03 10:28     ` Zdenek Dvorak
2010-11-03 23:10       ` Xinliang David Li
2010-11-05 20:40 ` H.J. Lu
2010-11-05 20:42   ` H.J. Lu
2010-11-05 21:00     ` H.J. Lu
2010-11-06 11:08   ` Xinliang David Li
2010-11-07 21:29   ` Xinliang David Li

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