public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* Small tweak to combine_validate_cost
@ 2011-04-08 22:32 Eric Botcazou
  0 siblings, 0 replies; only message in thread
From: Eric Botcazou @ 2011-04-08 22:32 UTC (permalink / raw)
  To: gcc-patches

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

At the end of combine_validate_cost, when the combination is validated, the 
registered cost of I1 is zero-ed.  This should be done for I0 as well.

Bootstrapped/regtested on x86_64-suse-linux, applied on the mainline.


2011-04-08  Eric Botcazou  <ebotcazou@adacore.com>

	* combine.c (combine_validate_cost): Adjust comments.  Set registered
	cost of I0 to zero at the end, if any.


-- 
Eric Botcazou

[-- Attachment #2: p.diff --]
[-- Type: text/x-diff, Size: 2137 bytes --]

Index: combine.c
===================================================================
--- combine.c	(revision 172166)
+++ combine.c	(working copy)
@@ -789,14 +789,13 @@ do_SUBST_MODE (rtx *into, enum machine_m
 
 #define SUBST_MODE(INTO, NEWVAL)  do_SUBST_MODE(&(INTO), (NEWVAL))
 \f
-/* Subroutine of try_combine.  Determine whether the combine replacement
-   patterns NEWPAT, NEWI2PAT and NEWOTHERPAT are cheaper according to
-   insn_rtx_cost that the original instruction sequence I0, I1, I2, I3 and
-   undobuf.other_insn.  Note that I1 and/or NEWI2PAT may be NULL_RTX.
-   NEWOTHERPAT and undobuf.other_insn may also both be NULL_RTX.  This
-   function returns false, if the costs of all instructions can be
-   estimated, and the replacements are more expensive than the original
-   sequence.  */
+/* Subroutine of try_combine.  Determine whether the replacement patterns
+   NEWPAT, NEWI2PAT and NEWOTHERPAT are cheaper according to insn_rtx_cost
+   than the original sequence I0, I1, I2, I3 and undobuf.other_insn.  Note
+   that I0, I1 and/or NEWI2PAT may be NULL_RTX.  Similarly, NEWOTHERPAT and
+   undobuf.other_insn may also both be NULL_RTX.  Return false if the cost
+   of all the instructions can be estimated and the replacements are more
+   expensive than the original sequence.  */
 
 static bool
 combine_validate_cost (rtx i0, rtx i1, rtx i2, rtx i3, rtx newpat,
@@ -861,10 +860,9 @@ combine_validate_cost (rtx i0, rtx i1, r
 	old_cost = 0;
     }
 
-  /* Disallow this recombination if both new_cost and old_cost are
-     greater than zero, and new_cost is greater than old cost.  */
-  if (old_cost > 0
-      && new_cost > old_cost)
+  /* Disallow this combination if both new_cost and old_cost are greater than
+     zero, and new_cost is greater than old cost.  */
+  if (old_cost > 0 && new_cost > old_cost)
     {
       if (dump_file)
 	{
@@ -910,7 +908,11 @@ combine_validate_cost (rtx i0, rtx i1, r
   INSN_COST (i2) = new_i2_cost;
   INSN_COST (i3) = new_i3_cost;
   if (i1)
-    INSN_COST (i1) = 0;
+    {
+      INSN_COST (i1) = 0;
+      if (i0)
+	INSN_COST (i0) = 0;
+    }
 
   return true;
 }

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

only message in thread, other threads:[~2011-04-08 22:32 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-04-08 22:32 Small tweak to combine_validate_cost Eric Botcazou

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