public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] Add sparc Niagara4 scheduling description and tweaks.
@ 2012-04-26  8:30 David Miller
  2012-08-26 21:35 ` Gerald Pfeifer
  0 siblings, 1 reply; 3+ messages in thread
From: David Miller @ 2012-04-26  8:30 UTC (permalink / raw)
  To: gcc-patches


Niagara4 is a dual issue processor, but with a twist.  The dual issue
pipeline is shared amongst a set of cpu threads.

So in the case that there is only one thread active, then up to two
instructions from that cpu thread can execute at a time.  If multiple
threads are active, we can instead end up issuing one instruction
from one thread and one instruction from another thread into the
dual-issue pipeline.

The long and short of this is that perfectly scheduled code won't
necessarily dual issue all the time.

Commited to trunk.

gcc/

	* config/sparc/niagara4.md: New file.
	* config/sparc/sparc.md: Include it.
	* config/sparc/sparc.c (niagara4_costs): New processor costs.
	(sparc_option_override): Use it.
	(sparc_use_sched_lookahead): Return 2 for niagara4.
	(sparc_issue_rate): Likewise.
---
 gcc/ChangeLog                |    7 ++++
 gcc/config/sparc/niagara4.md |   83 ++++++++++++++++++++++++++++++++++++++++++
 gcc/config/sparc/sparc.c     |   35 ++++++++++++++++--
 gcc/config/sparc/sparc.md    |    1 +
 4 files changed, 122 insertions(+), 4 deletions(-)
 create mode 100644 gcc/config/sparc/niagara4.md

diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index d8d08da..1ce7771 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,5 +1,12 @@
 2012-04-26  David S. Miller  <davem@davemloft.net>
 
+	* config/sparc/niagara4.md: New file.
+	* config/sparc/sparc.md: Include it.
+	* config/sparc/sparc.c (niagara4_costs): New processor costs.
+	(sparc_option_override): Use it.
+	(sparc_use_sched_lookahead): Return 2 for niagara4.
+	(sparc_issue_rate): Likewise.
+
 	* config/sparc/sparc.md (attr type): Delete 'fgm_cmp'.
 	(fpack16_vis, fpackfix_vis, fpack32_vis): Set type to fgm_pack.
 	(fmul8x16_vis, fmul8x16au_vis, fmul8x16al_vis, fmul8sux16_vis,
diff --git a/gcc/config/sparc/niagara4.md b/gcc/config/sparc/niagara4.md
new file mode 100644
index 0000000..f1f83b6
--- /dev/null
+++ b/gcc/config/sparc/niagara4.md
@@ -0,0 +1,83 @@
+;; Scheduling description for Niagara-4
+;;   Copyright (C) 2012 Free Software Foundation, Inc.
+;;
+;; This file is part of GCC.
+;;
+;; GCC is free software; you can redistribute it and/or modify
+;; it under the terms of the GNU General Public License as published by
+;; the Free Software Foundation; either version 3, or (at your option)
+;; any later version.
+;;
+;; GCC is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+;; GNU General Public License for more details.
+;;
+;; You should have received a copy of the GNU General Public License
+;; along with GCC; see the file COPYING3.  If not see
+;; <http://www.gnu.org/licenses/>.
+
+(define_automaton "niagara4_0")
+
+(define_cpu_unit "n4_slot0,n4_slot1" "niagara4_0")
+(define_reservation "n4_single_issue" "n4_slot0 + n4_slot1")
+
+(define_insn_reservation "n4_single" 1
+  (and (eq_attr "cpu" "niagara4")
+    (eq_attr "type" "multi,savew,flushw,iflush,trap,gsr"))
+  "n4_single_issue")
+
+(define_insn_reservation "n4_integer" 1
+  (and (eq_attr "cpu" "niagara4")
+    (eq_attr "type" "ialu,ialuX,shift,cmove,compare"))
+  "(n4_slot0 | n4_slot1)")
+
+(define_insn_reservation "n4_imul" 12
+  (and (eq_attr "cpu" "niagara4")
+    (eq_attr "type" "imul"))
+  "(n4_slot0 | n4_slot1), nothing*11")
+
+(define_insn_reservation "n4_idiv" 35
+  (and (eq_attr "cpu" "niagara4")
+    (eq_attr "type" "idiv"))
+  "(n4_slot0 | n4_slot1), nothing*34")
+
+(define_insn_reservation "n4_load" 5
+  (and (eq_attr "cpu" "niagara4")
+    (eq_attr "type" "load,fpload,sload"))
+  "n4_slot0, nothing*4")
+
+(define_insn_reservation "n4_store" 1
+  (and (eq_attr "cpu" "niagara4")
+    (eq_attr "type" "store,fpstore"))
+  "n4_slot0")
+
+(define_insn_reservation "n4_cti" 2
+  (and (eq_attr "cpu" "niagara4")
+    (eq_attr "type" "branch,call,sibcall,call_no_delay_slot,uncond_branch,return"))
+  "n4_slot1, nothing")
+
+(define_insn_reservation "n4_fp" 11
+  (and (eq_attr "cpu" "niagara4")
+    (eq_attr "type" "fpmove,fpcmove,fpcrmove,fp,fpcmp,fpmul"))
+  "n4_slot1, nothing*10")
+
+(define_insn_reservation "n4_array" 12
+  (and (eq_attr "cpu" "niagara4")
+    (eq_attr "type" "array,edge,edgen"))
+  "n4_slot1, nothing*11")
+
+(define_insn_reservation "n4_vis" 11
+  (and (eq_attr "cpu" "niagara4")
+    (eq_attr "type" "fga,fgm_pack,fgm_mul,fgm_pdist"))
+  "n4_slot1, nothing*10")
+
+(define_insn_reservation "n4_fpdivs" 24
+  (and (eq_attr "cpu" "niagara4")
+    (eq_attr "type" "fpdivs,fpsqrts"))
+  "n4_slot1, nothing*23")
+
+(define_insn_reservation "n4_fpdivd" 37
+  (and (eq_attr "cpu" "niagara4")
+    (eq_attr "type" "fpdivd,fpsqrtd"))
+  "n4_slot1, nothing*36")
diff --git a/gcc/config/sparc/sparc.c b/gcc/config/sparc/sparc.c
index 5c8e868..11bd1fe 100644
--- a/gcc/config/sparc/sparc.c
+++ b/gcc/config/sparc/sparc.c
@@ -374,6 +374,30 @@ struct processor_costs niagara3_costs = {
   0, /* shift penalty */
 };
 
+static const
+struct processor_costs niagara4_costs = {
+  COSTS_N_INSNS (5), /* int load */
+  COSTS_N_INSNS (5), /* int signed load */
+  COSTS_N_INSNS (5), /* int zeroed load */
+  COSTS_N_INSNS (5), /* float load */
+  COSTS_N_INSNS (11), /* fmov, fneg, fabs */
+  COSTS_N_INSNS (11), /* fadd, fsub */
+  COSTS_N_INSNS (11), /* fcmp */
+  COSTS_N_INSNS (11), /* fmov, fmovr */
+  COSTS_N_INSNS (11), /* fmul */
+  COSTS_N_INSNS (24), /* fdivs */
+  COSTS_N_INSNS (37), /* fdivd */
+  COSTS_N_INSNS (24), /* fsqrts */
+  COSTS_N_INSNS (37), /* fsqrtd */
+  COSTS_N_INSNS (12), /* imul */
+  COSTS_N_INSNS (12), /* imulX */
+  0, /* imul bit factor */
+  COSTS_N_INSNS (50), /* idiv, average of 41 - 60 cycle range */
+  COSTS_N_INSNS (35), /* idivX, average of 26 - 44 cycle range */
+  COSTS_N_INSNS (1), /* movcc/movr */
+  0, /* shift penalty */
+};
+
 static const struct processor_costs *sparc_costs = &cypress_costs;
 
 #ifdef HAVE_AS_RELAX_OPTION
@@ -1157,9 +1181,11 @@ sparc_option_override (void)
       sparc_costs = &niagara2_costs;
       break;
     case PROCESSOR_NIAGARA3:
-    case PROCESSOR_NIAGARA4:
       sparc_costs = &niagara3_costs;
       break;
+    case PROCESSOR_NIAGARA4:
+      sparc_costs = &niagara4_costs;
+      break;
     case PROCESSOR_NATIVE:
       gcc_unreachable ();
     };
@@ -8890,9 +8916,10 @@ sparc_use_sched_lookahead (void)
 {
   if (sparc_cpu == PROCESSOR_NIAGARA
       || sparc_cpu == PROCESSOR_NIAGARA2
-      || sparc_cpu == PROCESSOR_NIAGARA3
-      || sparc_cpu == PROCESSOR_NIAGARA4)
+      || sparc_cpu == PROCESSOR_NIAGARA3)
     return 0;
+  if (sparc_cpu == PROCESSOR_NIAGARA4)
+    return 2;
   if (sparc_cpu == PROCESSOR_ULTRASPARC
       || sparc_cpu == PROCESSOR_ULTRASPARC3)
     return 4;
@@ -8911,9 +8938,9 @@ sparc_issue_rate (void)
     case PROCESSOR_NIAGARA:
     case PROCESSOR_NIAGARA2:
     case PROCESSOR_NIAGARA3:
-    case PROCESSOR_NIAGARA4:
     default:
       return 1;
+    case PROCESSOR_NIAGARA4:
     case PROCESSOR_V9:
       /* Assume V9 processors are capable of at least dual-issue.  */
       return 2;
diff --git a/gcc/config/sparc/sparc.md b/gcc/config/sparc/sparc.md
index 08cc031..4c7a2b0 100644
--- a/gcc/config/sparc/sparc.md
+++ b/gcc/config/sparc/sparc.md
@@ -477,6 +477,7 @@
 (include "ultra3.md")
 (include "niagara.md")
 (include "niagara2.md")
+(include "niagara4.md")
 
 
 ;; Operand and operator predicates and constraints
-- 
1.7.9.5

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

* Re: [PATCH] Add sparc Niagara4 scheduling description and tweaks.
  2012-04-26  8:30 [PATCH] Add sparc Niagara4 scheduling description and tweaks David Miller
@ 2012-08-26 21:35 ` Gerald Pfeifer
  2012-08-26 21:45   ` David Miller
  0 siblings, 1 reply; 3+ messages in thread
From: Gerald Pfeifer @ 2012-08-26 21:35 UTC (permalink / raw)
  To: David Miller; +Cc: gcc-patches

Hi David,

On Thu, 26 Apr 2012, David Miller wrote:
> 	* config/sparc/niagara4.md: New file.
> 	* config/sparc/sparc.md: Include it.
> 	* config/sparc/sparc.c (niagara4_costs): New processor costs.
> 	(sparc_option_override): Use it.
> 	(sparc_use_sched_lookahead): Return 2 for niagara4.
> 	(sparc_issue_rate): Likewise.

how about something like the following for our release notes?

Gerald


Index: changes.html
===================================================================
RCS file: /cvs/gcc/wwwdocs/htdocs/gcc-4.8/changes.html,v
retrieving revision 1.22
diff -u -3 -p -r1.22 changes.html
--- changes.html	26 Aug 2012 16:00:45 -0000	1.22
+++ changes.html	26 Aug 2012 21:34:13 -0000
@@ -287,6 +287,12 @@ by this change.</p>
 
   </ul>
 
+<h3 id="sparc">SPARC</h3>
+
+  <ul>
+    <li>Added optimized instruction scheduling for Niagara4.</li>
+  </ul>
+
 <!--
 <h2>Documentation improvements</h2>
 -->

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

* Re: [PATCH] Add sparc Niagara4 scheduling description and tweaks.
  2012-08-26 21:35 ` Gerald Pfeifer
@ 2012-08-26 21:45   ` David Miller
  0 siblings, 0 replies; 3+ messages in thread
From: David Miller @ 2012-08-26 21:45 UTC (permalink / raw)
  To: gerald; +Cc: gcc-patches

From: Gerald Pfeifer <gerald@pfeifer.com>
Date: Sun, 26 Aug 2012 23:34:54 +0200 (CEST)

> Hi David,
> 
> On Thu, 26 Apr 2012, David Miller wrote:
>> 	* config/sparc/niagara4.md: New file.
>> 	* config/sparc/sparc.md: Include it.
>> 	* config/sparc/sparc.c (niagara4_costs): New processor costs.
>> 	(sparc_option_override): Use it.
>> 	(sparc_use_sched_lookahead): Return 2 for niagara4.
>> 	(sparc_issue_rate): Likewise.
> 
> how about something like the following for our release notes?

Looks fine to me.

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

end of thread, other threads:[~2012-08-26 21:45 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-04-26  8:30 [PATCH] Add sparc Niagara4 scheduling description and tweaks David Miller
2012-08-26 21:35 ` Gerald Pfeifer
2012-08-26 21:45   ` David Miller

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