From e951472536aab778c6bd5c605fc908439cd64cff Mon Sep 17 00:00:00 2001
From: Georg-Johann Lay <avr@gjlay.de>
Date: Thu, 21 Jul 2011 15:46:28 +0000
Subject: [PATCH] avr.c (final_prescan_insn): Fix printing of rtx_costs.

	* config/avr/avr.c (final_prescan_insn): Fix printing of rtx_costs.

From-SVN: r176575
---
 gcc/ChangeLog        |  4 ++++
 gcc/config/avr/avr.c | 12 +++++++++---
 2 files changed, 13 insertions(+), 3 deletions(-)

diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index ccfcfeeb1fce..b9d95fa5b6e9 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,7 @@
+2011-07-21  Georg-Johann Lay  <avr@gjlay.de>
+	
+	* config/avr/avr.c (final_prescan_insn): Fix printing of rtx_costs.
+
 2011-07-21  Jason Merrill  <jason@redhat.com>
 
 	* system.h (HAVE_DESIGNATED_UNION_INITIALIZERS): New.
diff --git a/gcc/config/avr/avr.c b/gcc/config/avr/avr.c
index a1d0c885bd86..4951f56e092d 100644
--- a/gcc/config/avr/avr.c
+++ b/gcc/config/avr/avr.c
@@ -1629,12 +1629,18 @@ byte_immediate_operand (rtx op, enum machine_mode mode ATTRIBUTE_UNUSED)
 
 void
 final_prescan_insn (rtx insn, rtx *operand ATTRIBUTE_UNUSED,
-		    int num_operands ATTRIBUTE_UNUSED)
+                    int num_operands ATTRIBUTE_UNUSED)
 {
   if (TARGET_ALL_DEBUG)
     {
-      fprintf (asm_out_file, "/* DEBUG: cost = %d.  */\n",
-	       rtx_cost (PATTERN (insn), INSN, !optimize_size));
+      rtx set = single_set (insn);
+
+      if (set)
+        fprintf (asm_out_file, "/* DEBUG: cost = %d.  */\n",
+                 rtx_cost (SET_SRC (set), SET, optimize_insn_for_speed_p()));
+      else
+        fprintf (asm_out_file, "/* DEBUG: pattern-cost = %d.  */\n",
+                 rtx_cost (PATTERN (insn), INSN, optimize_insn_for_speed_p()));
     }
 }
 
-- 
GitLab