* config/rs6000/40x.md (ppc403-compare): Remove "compare".
[official-gcc.git] / gcc / config / rs6000 / power8.md
bloba9b523d97426c8da64a80506ba5973f1b91c18b1
1 ;; Scheduling description for IBM POWER8 processor.
2 ;; Copyright (C) 2013-2014 Free Software Foundation, Inc.
3 ;;
4 ;; Contributed by Pat Haugen (pthaugen@us.ibm.com).
6 ;; This file is part of GCC.
7 ;;
8 ;; GCC is free software; you can redistribute it and/or modify it
9 ;; under the terms of the GNU General Public License as published
10 ;; by the Free Software Foundation; either version 3, or (at your
11 ;; option) any later version.
13 ;; GCC is distributed in the hope that it will be useful, but WITHOUT
14 ;; ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
15 ;; or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public
16 ;; License for more details.
18 ;; You should have received a copy of the GNU General Public License
19 ;; along with GCC; see the file COPYING3.  If not see
20 ;; <http://www.gnu.org/licenses/>.
22 (define_automaton "power8fxu,power8lsu,power8vsu,power8misc")
24 (define_cpu_unit "fxu0_power8,fxu1_power8" "power8fxu")
25 (define_cpu_unit "lu0_power8,lu1_power8" "power8lsu")
26 (define_cpu_unit "lsu0_power8,lsu1_power8" "power8lsu")
27 (define_cpu_unit "vsu0_power8,vsu1_power8" "power8vsu")
28 (define_cpu_unit "bpu_power8,cru_power8" "power8misc")
29 (define_cpu_unit "du0_power8,du1_power8,du2_power8,du3_power8,du4_power8,\
30                   du5_power8,du6_power8"  "power8misc")
33 ; Dispatch group reservations
34 (define_reservation "DU_any_power8"
35                     "du0_power8|du1_power8|du2_power8|du3_power8|du4_power8|\
36                      du5_power8")
38 ; 2-way Cracked instructions go in slots 0-1
39 ;   (can also have a second in slots 3-4 if insns are adjacent)
40 (define_reservation "DU_cracked_power8"
41                     "du0_power8+du1_power8")
43 ; Insns that are first in group
44 (define_reservation "DU_first_power8"
45                     "du0_power8")
47 ; Insns that are first and last in group
48 (define_reservation "DU_both_power8"
49                     "du0_power8+du1_power8+du2_power8+du3_power8+du4_power8+\
50                      du5_power8+du6_power8")
52 ; Dispatch slots are allocated in order conforming to program order.
53 (absence_set "du0_power8" "du1_power8,du2_power8,du3_power8,du4_power8,\
54               du5_power8,du6_power8")
55 (absence_set "du1_power8" "du2_power8,du3_power8,du4_power8,du5_power8,\
56               du6_power8")
57 (absence_set "du2_power8" "du3_power8,du4_power8,du5_power8,du6_power8")
58 (absence_set "du3_power8" "du4_power8,du5_power8,du6_power8")
59 (absence_set "du4_power8" "du5_power8,du6_power8")
60 (absence_set "du5_power8" "du6_power8")
63 ; Execution unit reservations
64 (define_reservation "FXU_power8"
65                     "fxu0_power8|fxu1_power8")
67 (define_reservation "LU_power8"
68                     "lu0_power8|lu1_power8")
70 (define_reservation "LSU_power8"
71                     "lsu0_power8|lsu1_power8")
73 (define_reservation "LU_or_LSU_power8"
74                     "lu0_power8|lu1_power8|lsu0_power8|lsu1_power8")
76 (define_reservation "VSU_power8"
77                     "vsu0_power8|vsu1_power8")
80 ; LS Unit
81 (define_insn_reservation "power8-load" 3
82   (and (eq_attr "type" "load")
83        (eq_attr "sign_extend" "no")
84        (eq_attr "update" "no")
85        (eq_attr "cpu" "power8"))
86   "DU_any_power8,LU_or_LSU_power8")
88 (define_insn_reservation "power8-load-update" 3
89   (and (eq_attr "type" "load")
90        (eq_attr "sign_extend" "no")
91        (eq_attr "update" "yes")
92        (eq_attr "cpu" "power8"))
93   "DU_cracked_power8,LU_or_LSU_power8+FXU_power8")
95 (define_insn_reservation "power8-load-ext" 3
96   (and (eq_attr "type" "load")
97        (eq_attr "sign_extend" "yes")
98        (eq_attr "update" "no")
99        (eq_attr "cpu" "power8"))
100   "DU_cracked_power8,LU_or_LSU_power8,FXU_power8")
102 (define_insn_reservation "power8-load-ext-update" 3
103   (and (eq_attr "type" "load")
104        (eq_attr "sign_extend" "yes")
105        (eq_attr "update" "yes")
106        (eq_attr "cpu" "power8"))
107   "DU_both_power8,LU_or_LSU_power8+FXU_power8,FXU_power8")
109 (define_insn_reservation "power8-fpload" 5
110   (and (ior (eq_attr "type" "vecload")
111             (and (eq_attr "type" "fpload")
112                  (eq_attr "update" "no")))
113        (eq_attr "cpu" "power8"))
114   "DU_any_power8,LU_power8")
116 (define_insn_reservation "power8-fpload-update" 5
117   (and (eq_attr "type" "fpload")
118        (eq_attr "update" "yes")
119        (eq_attr "cpu" "power8"))
120   "DU_cracked_power8,LU_power8+FXU_power8")
122 (define_insn_reservation "power8-store" 5 ; store-forwarding latency
123   (and (eq_attr "type" "store")
124        (not (and (eq_attr "update" "yes")
125                  (eq_attr "indexed" "yes")))
126        (eq_attr "cpu" "power8"))
127   "DU_any_power8,LSU_power8+LU_power8")
129 (define_insn_reservation "power8-store-update-indexed" 5
130   (and (eq_attr "type" "store")
131        (eq_attr "update" "yes")
132        (eq_attr "indexed" "yes")
133        (eq_attr "cpu" "power8"))
134   "DU_cracked_power8,LSU_power8+LU_power8")
136 (define_insn_reservation "power8-fpstore" 5
137   (and (eq_attr "type" "fpstore")
138        (eq_attr "update" "no")
139        (eq_attr "cpu" "power8"))
140   "DU_any_power8,LSU_power8+VSU_power8")
142 (define_insn_reservation "power8-fpstore-update" 5
143   (and (eq_attr "type" "fpstore")
144        (eq_attr "update" "yes")
145        (eq_attr "cpu" "power8"))
146   "DU_any_power8,LSU_power8+VSU_power8")
148 (define_insn_reservation "power8-vecstore" 5
149   (and (eq_attr "type" "vecstore")
150        (eq_attr "cpu" "power8"))
151   "DU_cracked_power8,LSU_power8+VSU_power8")
153 (define_insn_reservation "power8-larx" 3
154   (and (eq_attr "type" "load_l")
155        (eq_attr "cpu" "power8"))
156   "DU_both_power8,LU_or_LSU_power8")
158 (define_insn_reservation "power8-stcx" 10
159   (and (eq_attr "type" "store_c")
160        (eq_attr "cpu" "power8"))
161   "DU_both_power8,LSU_power8+LU_power8")
163 (define_insn_reservation "power8-sync" 1
164   (and (eq_attr "type" "sync,isync")
165        (eq_attr "cpu" "power8"))
166   "DU_both_power8,LSU_power8")
169 ; FX Unit
170 (define_insn_reservation "power8-1cyc" 1
171   (and (ior (eq_attr "type" "integer,insert,trap,isel")
172             (and (eq_attr "type" "add,logical,shift,exts")
173                  (eq_attr "dot" "no")))
174        (eq_attr "cpu" "power8"))
175   "DU_any_power8,FXU_power8")
177 ; Extra cycle to LU/LSU
178 (define_bypass 2 "power8-1cyc"
179                  "power8-load*,power8-fpload*,power8-store*,power8-fpstore*,\
180                   power8-vecstore,power8-larx,power8-stcx")
181 ;                "power8-load,power8-load-update,power8-load-ext,\
182 ;                 power8-load-ext-update,power8-fpload,power8-fpload-update,\
183 ;                 power8-store,power8-store-update,power8-store-update-indexed,\
184 ;                 power8-fpstore,power8-fpstore-update,power8-vecstore,\
185 ;                 power8-larx,power8-stcx")
187 (define_insn_reservation "power8-2cyc" 2
188   (and (eq_attr "type" "cntlz,popcnt")
189        (eq_attr "cpu" "power8"))
190   "DU_any_power8,FXU_power8")
192 (define_insn_reservation "power8-two" 2
193   (and (eq_attr "type" "two")
194        (eq_attr "cpu" "power8"))
195   "DU_any_power8+DU_any_power8,FXU_power8,FXU_power8")
197 (define_insn_reservation "power8-three" 3
198   (and (eq_attr "type" "three")
199        (eq_attr "cpu" "power8"))
200   "DU_any_power8+DU_any_power8+DU_any_power8,FXU_power8,FXU_power8,FXU_power8")
202 ; cmp - Normal compare insns
203 (define_insn_reservation "power8-cmp" 2
204   (and (eq_attr "type" "cmp")
205        (eq_attr "cpu" "power8"))
206   "DU_any_power8,FXU_power8")
208 ; add/logical with dot : add./and./nor./etc
209 (define_insn_reservation "power8-fast-compare" 2
210   (and (eq_attr "type" "add,logical")
211        (eq_attr "dot" "yes")
212        (eq_attr "cpu" "power8"))
213   "DU_any_power8,FXU_power8")
215 ; exts/shift with dot : rldicl./exts./rlwinm./slwi./rlwnm./slw./etc
216 (define_insn_reservation "power8-compare" 2
217   (and (eq_attr "type" "shift,exts")
218        (eq_attr "dot" "yes")
219        (eq_attr "cpu" "power8"))
220   "DU_cracked_power8,FXU_power8,FXU_power8")
222 ; Extra cycle to LU/LSU
223 (define_bypass 3 "power8-fast-compare,power8-compare"
224                  "power8-load*,power8-fpload*,power8-store*,power8-fpstore*,\
225                   power8-vecstore,power8-larx,power8-stcx")
227 ; 5 cycle CR latency 
228 (define_bypass 5 "power8-fast-compare,power8-compare"
229                  "power8-crlogical,power8-mfcr,power8-mfcrf,power8-branch")
231 (define_insn_reservation "power8-mul" 4
232   (and (eq_attr "type" "mul")
233        (eq_attr "dot" "no")
234        (eq_attr "cpu" "power8"))
235   "DU_any_power8,FXU_power8")
237 (define_insn_reservation "power8-mul-compare" 4
238   (and (eq_attr "type" "mul")
239        (eq_attr "dot" "yes")
240        (eq_attr "cpu" "power8"))
241   "DU_cracked_power8,FXU_power8")
243 ; Extra cycle to LU/LSU
244 (define_bypass 5 "power8-mul,power8-mul-compare"
245                  "power8-load*,power8-fpload*,power8-store*,power8-fpstore*,\
246                   power8-vecstore,power8-larx,power8-stcx")
248 ; 7 cycle CR latency 
249 (define_bypass 7 "power8-mul,power8-mul-compare"
250                  "power8-crlogical,power8-mfcr,power8-mfcrf,power8-branch")
252 ; FXU divides are not pipelined
253 (define_insn_reservation "power8-idiv" 37
254   (and (eq_attr "type" "div")
255        (eq_attr "size" "32")
256        (eq_attr "cpu" "power8"))
257   "DU_any_power8,fxu0_power8*37|fxu1_power8*37")
259 (define_insn_reservation "power8-ldiv" 68
260   (and (eq_attr "type" "div")
261        (eq_attr "size" "64")
262        (eq_attr "cpu" "power8"))
263   "DU_any_power8,fxu0_power8*68|fxu1_power8*68")
265 (define_insn_reservation "power8-mtjmpr" 5
266   (and (eq_attr "type" "mtjmpr")
267        (eq_attr "cpu" "power8"))
268   "DU_first_power8,FXU_power8")
270 ; Should differentiate between 1 cr field and > 1 since mtocrf is not microcode
271 (define_insn_reservation "power8-mtcr" 3
272   (and (eq_attr "type" "mtcr")
273        (eq_attr "cpu" "power8"))
274   "DU_both_power8,FXU_power8")
277 ; CR Unit
278 (define_insn_reservation "power8-mfjmpr" 5
279   (and (eq_attr "type" "mfjmpr")
280        (eq_attr "cpu" "power8"))
281   "DU_first_power8,cru_power8+FXU_power8")
283 (define_insn_reservation "power8-crlogical" 3
284   (and (eq_attr "type" "cr_logical,delayed_cr")
285        (eq_attr "cpu" "power8"))
286   "DU_first_power8,cru_power8")
288 (define_insn_reservation "power8-mfcr" 5
289   (and (eq_attr "type" "mfcr")
290        (eq_attr "cpu" "power8"))
291   "DU_both_power8,cru_power8")
293 (define_insn_reservation "power8-mfcrf" 3
294   (and (eq_attr "type" "mfcrf")
295        (eq_attr "cpu" "power8"))
296   "DU_first_power8,cru_power8")
299 ; BR Unit
300 ; Branches take dispatch slot 7, but reserve any remaining prior slots to
301 ; prevent other insns from grabbing them once this is assigned.
302 (define_insn_reservation "power8-branch" 3
303   (and (eq_attr "type" "jmpreg,branch")
304        (eq_attr "cpu" "power8"))
305   "(du6_power8\
306    |du5_power8+du6_power8\
307    |du4_power8+du5_power8+du6_power8\
308    |du3_power8+du4_power8+du5_power8+du6_power8\
309    |du2_power8+du3_power8+du4_power8+du5_power8+du6_power8\
310    |du1_power8+du2_power8+du3_power8+du4_power8+du5_power8+du6_power8\
311    |du0_power8+du1_power8+du2_power8+du3_power8+du4_power8+du5_power8+\
312     du6_power8),bpu_power8")
314 ; Branch updating LR/CTR feeding mf[lr|ctr]
315 (define_bypass 4 "power8-branch" "power8-mfjmpr")
318 ; VS Unit (includes FP/VSX/VMX/DFP/Crypto)
319 (define_insn_reservation "power8-fp" 6
320   (and (eq_attr "type" "fp,dmul")
321        (eq_attr "cpu" "power8"))
322   "DU_any_power8,VSU_power8")
324 ; Additional 3 cycles for any CR result
325 (define_bypass 9 "power8-fp" "power8-crlogical,power8-mfcr*,power8-branch")
327 (define_insn_reservation "power8-fpcompare" 8
328   (and (eq_attr "type" "fpcompare")
329        (eq_attr "cpu" "power8"))
330   "DU_any_power8,VSU_power8")
332 (define_insn_reservation "power8-sdiv" 27
333   (and (eq_attr "type" "sdiv")
334        (eq_attr "cpu" "power8"))
335   "DU_any_power8,VSU_power8")
337 (define_insn_reservation "power8-ddiv" 33
338   (and (eq_attr "type" "ddiv")
339        (eq_attr "cpu" "power8"))
340   "DU_any_power8,VSU_power8")
342 (define_insn_reservation "power8-sqrt" 32
343   (and (eq_attr "type" "ssqrt")
344        (eq_attr "cpu" "power8"))
345   "DU_any_power8,VSU_power8")
347 (define_insn_reservation "power8-dsqrt" 44
348   (and (eq_attr "type" "dsqrt")
349        (eq_attr "cpu" "power8"))
350   "DU_any_power8,VSU_power8")
352 (define_insn_reservation "power8-vecsimple" 2
353   (and (eq_attr "type" "vecperm,vecsimple,veccmp")
354        (eq_attr "cpu" "power8"))
355   "DU_any_power8,VSU_power8")
357 (define_insn_reservation "power8-vecnormal" 6
358   (and (eq_attr "type" "vecfloat,vecdouble")
359        (eq_attr "cpu" "power8"))
360   "DU_any_power8,VSU_power8")
362 (define_bypass 7 "power8-vecnormal"
363                  "power8-vecsimple,power8-veccomplex,power8-fpstore*,\
364                   power8-vecstore")
366 (define_insn_reservation "power8-veccomplex" 7
367   (and (eq_attr "type" "veccomplex")
368        (eq_attr "cpu" "power8"))
369   "DU_any_power8,VSU_power8")
371 (define_insn_reservation "power8-vecfdiv" 25
372   (and (eq_attr "type" "vecfdiv")
373        (eq_attr "cpu" "power8"))
374   "DU_any_power8,VSU_power8")
376 (define_insn_reservation "power8-vecdiv" 31
377   (and (eq_attr "type" "vecdiv")
378        (eq_attr "cpu" "power8"))
379   "DU_any_power8,VSU_power8")
381 (define_insn_reservation "power8-mffgpr" 5
382   (and (eq_attr "type" "mffgpr")
383        (eq_attr "cpu" "power8"))
384   "DU_any_power8,VSU_power8")
386 (define_insn_reservation "power8-mftgpr" 6
387   (and (eq_attr "type" "mftgpr")
388        (eq_attr "cpu" "power8"))
389   "DU_any_power8,VSU_power8")
391 (define_insn_reservation "power8-crypto" 7
392   (and (eq_attr "type" "crypto")
393        (eq_attr "cpu" "power8"))
394   "DU_any_power8,VSU_power8")