diff mbox

combine: Correct cost calculation and display for split I2

Message ID dba5dba57e5da928f248fa97446f2e60b7ec01f0.1419439887.git.segher@kernel.crashing.org
State New
Headers show

Commit Message

Segher Boessenkool Dec. 24, 2014, 5:04 p.m. UTC
If we have split a parallel I2 to two insns, we will count its RTL cost
twice.  This currently does not matter since the cost is 0 always (it is
not a single set insn), but let's fix it anyway.

Also do not display the fake I1 in the cost calculation in the dump file.

Tested on powerpc64-linux.  Okay for mainline?


Segher


2014-12-24  Segher Boessenkool  <segher@kernel.crashing.org>

gcc/
	* combine.c (combine_validate_cost): Do not count the cost of a
	split I2 twice.  Do not display it twice in the dump, either.

---
 gcc/combine.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

Comments

Jeff Law Jan. 5, 2015, 8:28 p.m. UTC | #1
On 12/24/14 10:04, Segher Boessenkool wrote:
> If we have split a parallel I2 to two insns, we will count its RTL cost
> twice.  This currently does not matter since the cost is 0 always (it is
> not a single set insn), but let's fix it anyway.
>
> Also do not display the fake I1 in the cost calculation in the dump file.
>
> Tested on powerpc64-linux.  Okay for mainline?
>
>
> Segher
>
>
> 2014-12-24  Segher Boessenkool  <segher@kernel.crashing.org>
>
> gcc/
> 	* combine.c (combine_validate_cost): Do not count the cost of a
> 	split I2 twice.  Do not display it twice in the dump, either.
OK.
Jeff
diff mbox

Patch

diff --git a/gcc/combine.c b/gcc/combine.c
index ed247bd..56ac34c 100644
--- a/gcc/combine.c
+++ b/gcc/combine.c
@@ -909,6 +909,12 @@  combine_validate_cost (rtx_insn *i0, rtx_insn *i1, rtx_insn *i2, rtx_insn *i3,
       i1_cost = i0_cost = 0;
     }
 
+  /* If we have split a PARALLEL I2 to I1,I2, we have counted its cost twice;
+     correct that.  */
+  if (old_cost && i1 && INSN_UID (i1) == INSN_UID (i2))
+    old_cost -= i1_cost;
+
+
   /* Calculate the replacement insn_rtx_costs.  */
   new_i3_cost = insn_rtx_cost (newpat, optimize_this_for_speed_p);
   if (newi2pat)
@@ -948,14 +954,14 @@  combine_validate_cost (rtx_insn *i0, rtx_insn *i1, rtx_insn *i2, rtx_insn *i3,
 	       reject ? "rejecting" : "allowing");
       if (i0)
 	fprintf (dump_file, "%d, ", INSN_UID (i0));
-      if (i1)
+      if (i1 && INSN_UID (i1) != INSN_UID (i2))
 	fprintf (dump_file, "%d, ", INSN_UID (i1));
       fprintf (dump_file, "%d and %d\n", INSN_UID (i2), INSN_UID (i3));
 
       fprintf (dump_file, "original costs ");
       if (i0)
 	fprintf (dump_file, "%d + ", i0_cost);
-      if (i1)
+      if (i1 && INSN_UID (i1) != INSN_UID (i2))
 	fprintf (dump_file, "%d + ", i1_cost);
       fprintf (dump_file, "%d + %d = %d\n", i2_cost, i3_cost, old_cost);