OSDN Git Service

* ia64.md (UNSPEC_SHRP): New.
[pf3gnuchains/gcc-fork.git] / gcc / config / ia64 / ia64.md
1 ;; IA-64 Machine description template
2 ;; Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004
3 ;; Free Software Foundation, Inc.
4 ;; Contributed by James E. Wilson <wilson@cygnus.com> and
5 ;;                David Mosberger <davidm@hpl.hp.com>.
6
7 ;; This file is part of GCC.
8
9 ;; GCC is free software; you can redistribute it and/or modify
10 ;; it under the terms of the GNU General Public License as published by
11 ;; the Free Software Foundation; either version 2, or (at your option)
12 ;; any later version.
13
14 ;; GCC is distributed in the hope that it will be useful,
15 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
16 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17 ;; GNU General Public License for more details.
18
19 ;; You should have received a copy of the GNU General Public License
20 ;; along with GCC; see the file COPYING.  If not, write to
21 ;; the Free Software Foundation, 59 Temple Place - Suite 330,
22 ;; Boston, MA 02111-1307, USA.
23
24 ;;- See file "rtl.def" for documentation on define_insn, match_*, et. al.
25
26 ;; ??? register_operand accepts (subreg:DI (mem:SI X)) which forces later
27 ;; reload.  This will be fixed once scheduling support is turned on.
28
29 ;; ??? Optimize for post-increment addressing modes.
30
31 ;; ??? fselect is not supported, because there is no integer register
32 ;; equivalent.
33
34 ;; ??? fp abs/min/max instructions may also work for integer values.
35
36 ;; ??? Would a predicate_reg_operand predicate be useful?  The HP one is buggy,
37 ;; it assumes the operand is a register and takes REGNO of it without checking.
38
39 ;; ??? Would a branch_reg_operand predicate be useful?  The HP one is buggy,
40 ;; it assumes the operand is a register and takes REGNO of it without checking.
41
42 ;; ??? Go through list of documented named patterns and look for more to
43 ;; implement.
44
45 ;; ??? Go through instruction manual and look for more instructions that
46 ;; can be emitted.
47
48 ;; ??? Add function unit scheduling info for Itanium (TM) processor.
49
50 ;; ??? Need a better way to describe alternate fp status registers.
51
52 (define_constants
53   [; Relocations
54    (UNSPEC_LTOFF_DTPMOD         0)
55    (UNSPEC_LTOFF_DTPREL         1)
56    (UNSPEC_DTPREL               2)
57    (UNSPEC_LTOFF_TPREL          3)
58    (UNSPEC_TPREL                4)
59
60    (UNSPEC_LD_BASE              9)
61    (UNSPEC_GR_SPILL             10)
62    (UNSPEC_GR_RESTORE           11)
63    (UNSPEC_FR_SPILL             12)
64    (UNSPEC_FR_RESTORE           13)
65    (UNSPEC_FR_RECIP_APPROX      14)
66    (UNSPEC_PRED_REL_MUTEX       15)
67    (UNSPEC_GETF_EXP             16)
68    (UNSPEC_PIC_CALL             17)
69    (UNSPEC_MF                   18)
70    (UNSPEC_CMPXCHG_ACQ          19)
71    (UNSPEC_FETCHADD_ACQ         20)
72    (UNSPEC_BSP_VALUE            21)
73    (UNSPEC_FLUSHRS              22)
74    (UNSPEC_BUNDLE_SELECTOR      23)
75    (UNSPEC_ADDP4                24)
76    (UNSPEC_PROLOGUE_USE         25)
77    (UNSPEC_RET_ADDR             26)
78    (UNSPEC_SETF_EXP             27)
79    (UNSPEC_FR_SQRT_RECIP_APPROX 28)
80    (UNSPEC_SHRP                 29)
81   ])
82
83 (define_constants
84   [(UNSPECV_ALLOC               0)
85    (UNSPECV_BLOCKAGE            1)
86    (UNSPECV_INSN_GROUP_BARRIER  2)
87    (UNSPECV_BREAK               3)
88    (UNSPECV_SET_BSP             4)
89    (UNSPECV_PSAC_ALL            5)      ; pred.safe_across_calls
90    (UNSPECV_PSAC_NORMAL         6)
91    (UNSPECV_SETJMP_RECEIVER     7)
92   ])
93 \f
94 ;; ::::::::::::::::::::
95 ;; ::
96 ;; :: Predicates
97 ;; ::
98 ;; ::::::::::::::::::::
99
100 ;; True if OP is a valid operand for the MEM of a CALL insn.
101 (define_predicate "call_operand"
102   (ior (match_code "symbol_ref")
103        (match_operand 0 "register_operand")))
104
105 ;; True if OP refers to any kind of symbol.
106 ;; For roughly the same reasons that pmode_register_operand exists, this
107 ;; predicate ignores its mode argument.
108 (define_special_predicate "symbolic_operand" 
109    (match_code "symbol_ref,const,label_ref"))
110
111 ;; True if OP is a SYMBOL_REF which refers to a function.
112 (define_predicate "function_operand"
113   (and (match_code "symbol_ref")
114        (match_test "SYMBOL_REF_FUNCTION_P (op)")))
115
116 ;; True if OP refers to a symbol, and is appropriate for a GOT load.
117 (define_predicate "got_symbolic_operand" 
118   (match_operand 0 "symbolic_operand" "")
119 {
120   switch (GET_CODE (op))
121     {
122     case LABEL_REF:
123       return true;
124
125     case SYMBOL_REF:
126       /* This sort of load should not be used for things in sdata.  */
127       return !SYMBOL_REF_SMALL_ADDR_P (op);
128
129     case CONST:
130       /* Accept only (plus (symbol_ref) (const_int)).  */
131       op = XEXP (op, 0);
132       if (GET_CODE (op) != PLUS
133           || GET_CODE (XEXP (op, 0)) != SYMBOL_REF
134           || GET_CODE (XEXP (op, 1)) != CONST_INT)
135         return false;
136
137       /* Ok if we're not using GOT entries at all.  */
138       if (TARGET_NO_PIC || TARGET_AUTO_PIC)
139         return true;
140
141       /* The low 14 bits of the constant have been forced to zero
142          by ia64_expand_load_address, so that we do not use up so
143          many GOT entries.  Prevent cse from undoing this.  */
144       op = XEXP (op, 1);
145       return (INTVAL (op) & 0x3fff) == 0;
146
147     default:
148       abort ();
149     }
150 })
151
152 ;; True if OP refers to a symbol in the sdata section.
153 (define_predicate "sdata_symbolic_operand" 
154   (match_code "symbol_ref,const")
155 {
156   switch (GET_CODE (op))
157     {
158     case CONST:
159       op = XEXP (op, 0);
160       if (GET_CODE (op) != PLUS
161           || GET_CODE (XEXP (op, 0)) != SYMBOL_REF)
162         return false;
163       op = XEXP (op, 0);
164       /* FALLTHRU */
165
166     case SYMBOL_REF:
167       if (CONSTANT_POOL_ADDRESS_P (op))
168         return GET_MODE_SIZE (get_pool_mode (op)) <= ia64_section_threshold;
169       else
170         return SYMBOL_REF_LOCAL_P (op) && SYMBOL_REF_SMALL_P (op);
171
172     default:
173       abort ();
174     }
175 })
176
177 ;; Like nonimmediate_operand, but don't allow MEMs that try to use a
178 ;; POST_MODIFY with a REG as displacement.
179 (define_predicate "destination_operand"
180   (and (match_operand 0 "nonimmediate_operand")
181        (match_test "GET_CODE (op) != MEM
182                     || GET_CODE (XEXP (op, 0)) != POST_MODIFY
183                     || GET_CODE (XEXP (XEXP (XEXP (op, 0), 1), 1)) != REG")))
184
185 ;; Like memory_operand, but don't allow post-increments.
186 (define_predicate "not_postinc_memory_operand"
187   (and (match_operand 0 "memory_operand")
188        (match_test "GET_RTX_CLASS (GET_CODE (XEXP (op, 0))) != RTX_AUTOINC")))
189
190 ;; True if OP is a general operand, excluding tls symbolic operands.
191 (define_predicate "move_operand"
192   (and (match_operand 0 "general_operand")
193        (not (match_test 
194              "GET_CODE (op) == SYMBOL_REF && SYMBOL_REF_TLS_MODEL (op)"))))
195
196 ;; True if OP is a register operand that is (or could be) a GR reg.
197 (define_predicate "gr_register_operand"
198   (match_operand 0 "register_operand")
199 {
200   unsigned int regno;
201   if (GET_CODE (op) == SUBREG)
202     op = SUBREG_REG (op);
203
204   regno = REGNO (op);
205   return (regno >= FIRST_PSEUDO_REGISTER || GENERAL_REGNO_P (regno));
206 })
207
208 ;; True if OP is a register operand that is (or could be) an FR reg.
209 (define_predicate "fr_register_operand"
210   (match_operand 0 "register_operand")
211 {
212   unsigned int regno;
213   if (GET_CODE (op) == SUBREG)
214     op = SUBREG_REG (op);
215
216   regno = REGNO (op);
217   return (regno >= FIRST_PSEUDO_REGISTER || FR_REGNO_P (regno));
218 })
219
220 ;; True if OP is a register operand that is (or could be) a GR/FR reg.
221 (define_predicate "grfr_register_operand"
222   (match_operand 0 "register_operand")
223 {
224   unsigned int regno;
225   if (GET_CODE (op) == SUBREG)
226     op = SUBREG_REG (op);
227
228   regno = REGNO (op);
229   return (regno >= FIRST_PSEUDO_REGISTER
230           || GENERAL_REGNO_P (regno)
231           || FR_REGNO_P (regno));
232 })
233
234 ;; True if OP is a nonimmediate operand that is (or could be) a GR reg.
235 (define_predicate "gr_nonimmediate_operand"
236   (match_operand 0 "nonimmediate_operand")
237 {
238   unsigned int regno;
239
240   if (GET_CODE (op) == MEM)
241     return true;
242   if (GET_CODE (op) == SUBREG)
243     op = SUBREG_REG (op);
244
245   regno = REGNO (op);
246   return (regno >= FIRST_PSEUDO_REGISTER || GENERAL_REGNO_P (regno));
247 })
248
249 ;; True if OP is a nonimmediate operand that is (or could be) a FR reg.
250 (define_predicate "fr_nonimmediate_operand"
251   (match_operand 0 "nonimmediate_operand")
252 {
253   unsigned int regno;
254
255   if (GET_CODE (op) == MEM)
256     return true;
257   if (GET_CODE (op) == SUBREG)
258     op = SUBREG_REG (op);
259
260   regno = REGNO (op);
261   return (regno >= FIRST_PSEUDO_REGISTER || FR_REGNO_P (regno));
262 })
263
264 ;; True if OP is a nonimmediate operand that is (or could be) a GR/FR reg.
265 (define_predicate "grfr_nonimmediate_operand"
266   (match_operand 0 "nonimmediate_operand")
267 {
268   unsigned int regno;
269
270   if (GET_CODE (op) == MEM)
271     return true;
272   if (GET_CODE (op) == SUBREG)
273     op = SUBREG_REG (op);
274
275   regno = REGNO (op);
276   return (regno >= FIRST_PSEUDO_REGISTER
277           || GENERAL_REGNO_P (regno)
278           || FR_REGNO_P (regno));
279 })
280
281 ;; True if OP is a GR register operand, or zero.
282 (define_predicate "gr_reg_or_0_operand"
283   (ior (match_operand 0 "gr_register_operand")
284        (and (match_code "const_int")
285             (match_test "op == const0_rtx"))))
286
287 ;; True if OP is a GR register operand, or a 5 bit immediate operand.
288 (define_predicate "gr_reg_or_5bit_operand"
289   (ior (match_operand 0 "gr_register_operand")
290        (and (match_code "const_int")
291             (match_test "INTVAL (op) >= 0 && INTVAL (op) < 32"))))
292
293 ;; True if OP is a GR register operand, or a 6 bit immediate operand.
294 (define_predicate "gr_reg_or_6bit_operand"
295   (ior (match_operand 0 "gr_register_operand")
296        (and (match_code "const_int")
297             (match_test "CONST_OK_FOR_M (INTVAL (op))"))))
298
299 ;; True if OP is a GR register operand, or an 8 bit immediate operand.
300 (define_predicate "gr_reg_or_8bit_operand"
301   (ior (match_operand 0 "gr_register_operand")
302        (and (match_code "const_int")
303             (match_test "CONST_OK_FOR_K (INTVAL (op))"))))
304
305 ;; True if OP is a GR/FR register operand, or an 8 bit immediate operand.
306 (define_predicate "grfr_reg_or_8bit_operand"
307   (ior (match_operand 0 "grfr_register_operand")
308        (and (match_code "const_int")
309             (match_test "CONST_OK_FOR_K (INTVAL (op))"))))
310
311 ;; True if OP is a register operand, or an 8 bit adjusted immediate operand.
312 (define_predicate "gr_reg_or_8bit_adjusted_operand"
313   (ior (match_operand 0 "gr_register_operand")
314        (and (match_code "const_int")
315             (match_test "CONST_OK_FOR_L (INTVAL (op))"))))
316
317 ;; True if OP is a register operand, or is valid for both an 8 bit
318 ;; immediate and an 8 bit adjusted immediate operand.  This is necessary
319 ;; because when we emit a compare, we don't know what the condition will be,
320 ;; so we need the union of the immediates accepted by GT and LT.
321 (define_predicate "gr_reg_or_8bit_and_adjusted_operand"
322   (ior (match_operand 0 "gr_register_operand")
323        (and (match_code "const_int")
324             (match_test "CONST_OK_FOR_K (INTVAL (op))
325                          && CONST_OK_FOR_L (INTVAL (op))"))))
326
327 ;; True if OP is a register operand, or a 14 bit immediate operand.
328 (define_predicate "gr_reg_or_14bit_operand"
329   (ior (match_operand 0 "gr_register_operand")
330        (and (match_code "const_int")
331             (match_test "CONST_OK_FOR_I (INTVAL (op))"))))
332
333 ;;  True if OP is a register operand, or a 22 bit immediate operand.
334 (define_predicate "gr_reg_or_22bit_operand"
335   (ior (match_operand 0 "gr_register_operand")
336        (and (match_code "const_int")
337             (match_test "CONST_OK_FOR_J (INTVAL (op))"))))
338
339 ;; True if OP is a 7 bit immediate operand.
340 (define_predicate "dshift_count_operand"
341   (and (match_code "const_int")
342        (match_test "INTVAL (op) >= 0 && INTVAL (op) < 128")))
343
344 ;; True if OP is a 6 bit immediate operand.
345 (define_predicate "shift_count_operand"
346   (and (match_code "const_int")
347        (match_test "CONST_OK_FOR_M (INTVAL (op))")))
348
349 ;; True if OP is a 5 bit immediate operand.
350 (define_predicate "shift_32bit_count_operand"
351    (and (match_code "const_int")
352         (match_test "INTVAL (op) >= 0 && INTVAL (op) < 32")))
353
354 ;; True if OP is one of the immediate values 2, 4, 8, or 16.
355 (define_predicate "shladd_operand"
356   (and (match_code "const_int")
357        (match_test "INTVAL (op) == 2 || INTVAL (op) == 4 ||
358                     INTVAL (op) == 8 || INTVAL (op) == 16")))
359
360 ;; True if OP is one of the immediate values  -16, -8, -4, -1, 1, 4, 8, 16.
361 (define_predicate "fetchadd_operand"
362   (and (match_code "const_int")
363        (match_test "INTVAL (op) == -16 || INTVAL (op) == -8 ||
364                     INTVAL (op) == -4  || INTVAL (op) == -1 ||
365                     INTVAL (op) == 1   || INTVAL (op) == 4  ||
366                     INTVAL (op) == 8   || INTVAL (op) == 16")))
367
368
369 ;; True if OP is a floating-point constant zero, one, or a register.
370 (define_predicate "fr_reg_or_fp01_operand"
371   (ior (match_operand 0 "fr_register_operand")
372        (and (match_code "const_double")
373             (match_test "CONST_DOUBLE_OK_FOR_G (op)"))))
374
375 ;; Like fr_reg_or_fp01_operand, but don't allow any SUBREGs.
376 (define_predicate "xfreg_or_fp01_operand"
377   (and (match_operand 0 "fr_reg_or_fp01_operand")
378        (not (match_code "subreg"))))
379
380 ;; True if this is a comparison operator, which accepts a normal 8-bit
381 ;; signed immediate operand.
382 (define_predicate "normal_comparison_operator"
383   (match_code "eq,ne,gt,le,gtu,leu"))
384
385 ;; True if this is a comparison operator, which accepts an adjusted 8-bit
386 ;; signed immediate operand.
387 (define_predicate "adjusted_comparison_operator"
388   (match_code "lt,ge,ltu,geu"))
389
390 ;; True if this is a signed inequality operator.
391 (define_predicate "signed_inequality_operator"
392   (match_code "ge,gt,le,lt"))
393
394 ;; True if this operator is valid for predication.
395 (define_predicate "predicate_operator"
396   (match_code "eq,ne"))
397
398 ;; True if this operator can be used in a conditional operation.
399 (define_predicate "condop_operator"
400   (match_code "plus,minus,ior,xor,and"))
401
402 ;; These three are hardware registers that can only be addressed in
403 ;; DImode.  It's not strictly necessary to test mode == DImode here,
404 ;; but it makes decent insurance against someone writing a
405 ;; match_operand wrong.
406
407 ;; True if this is the ar.lc register.
408 (define_predicate "ar_lc_reg_operand"
409   (and (match_code "reg")
410        (match_test "mode == DImode && REGNO (op) == AR_LC_REGNUM")))
411
412 ;; True if this is the ar.ccv register.
413 (define_predicate "ar_ccv_reg_operand"
414   (and (match_code "reg")
415        (match_test "mode == DImode && REGNO (op) == AR_CCV_REGNUM")))
416
417 ;; True if this is the ar.pfs register.
418 (define_predicate "ar_pfs_reg_operand"
419   (and (match_code "reg")
420        (match_test "mode == DImode && REGNO (op) == AR_PFS_REGNUM")))
421
422 ;; True if OP is valid as a base register in a reg + offset address.
423 ;; ??? Should I copy the flag_omit_frame_pointer and cse_not_expected
424 ;; checks from pa.c basereg_operand as well?  Seems to be OK without them
425 ;; in test runs.
426 (define_predicate "basereg_operand"
427   (match_operand 0 "register_operand")
428 {
429   if (GET_CODE (op) == SUBREG)
430     op = SUBREG_REG (op);
431   return REG_POINTER (op);
432 })
433
434 \f
435 ;; ::::::::::::::::::::
436 ;; ::
437 ;; :: Attributes
438 ;; ::
439 ;; ::::::::::::::::::::
440
441 ;; Processor type.  This attribute must exactly match the processor_type
442 ;; enumeration in ia64.h.
443 (define_attr "cpu" "itanium,itanium2" (const (symbol_ref "ia64_tune")))
444
445 ;; Instruction type.  This primarily determines how instructions can be
446 ;; packed in bundles, and secondarily affects scheduling to function units.
447
448 ;; A alu, can go in I or M syllable of a bundle
449 ;; I integer
450 ;; M memory
451 ;; F floating-point
452 ;; B branch
453 ;; L long immediate, takes two syllables
454 ;; S stop bit
455
456 ;; ??? Should not have any pattern with type unknown.  Perhaps add code to
457 ;; check this in md_reorg?  Currently use unknown for patterns which emit
458 ;; multiple instructions, patterns which emit 0 instructions, and patterns
459 ;; which emit instruction that can go in any slot (e.g. nop).
460
461 (define_attr "itanium_class" "unknown,ignore,stop_bit,br,fcmp,fcvtfx,fld,
462         fmac,fmisc,frar_i,frar_m,frbr,frfr,frpr,ialu,icmp,ilog,ishf,ld,
463         chk_s,long_i,mmmul,mmshf,mmshfi,rse_m,scall,sem,stf,st,syst_m0,
464         syst_m,tbit,toar_i,toar_m,tobr,tofr,topr,xmpy,xtd,nop,nop_b,nop_f,
465         nop_i,nop_m,nop_x,lfetch,pre_cycle"
466   (const_string "unknown"))
467
468 ;; chk_s has an I and an M form; use type A for convenience.
469 (define_attr "type" "unknown,A,I,M,F,B,L,X,S"
470   (cond [(eq_attr "itanium_class" "ld,st,fld,stf,sem,nop_m") (const_string "M")
471          (eq_attr "itanium_class" "rse_m,syst_m,syst_m0") (const_string "M")
472          (eq_attr "itanium_class" "frar_m,toar_m,frfr,tofr") (const_string "M")
473          (eq_attr "itanium_class" "lfetch") (const_string "M")
474          (eq_attr "itanium_class" "chk_s,ialu,icmp,ilog") (const_string "A")
475          (eq_attr "itanium_class" "fmisc,fmac,fcmp,xmpy") (const_string "F")
476          (eq_attr "itanium_class" "fcvtfx,nop_f") (const_string "F")
477          (eq_attr "itanium_class" "frar_i,toar_i,frbr,tobr") (const_string "I")
478          (eq_attr "itanium_class" "frpr,topr,ishf,xtd,tbit") (const_string "I")
479          (eq_attr "itanium_class" "mmmul,mmshf,mmshfi,nop_i") (const_string "I")
480          (eq_attr "itanium_class" "br,scall,nop_b") (const_string "B")
481          (eq_attr "itanium_class" "stop_bit") (const_string "S")
482          (eq_attr "itanium_class" "nop_x") (const_string "X")
483          (eq_attr "itanium_class" "long_i") (const_string "L")]
484         (const_string "unknown")))
485
486 (define_attr "itanium_requires_unit0" "no,yes"
487   (cond [(eq_attr "itanium_class" "syst_m0,sem,frfr,rse_m") (const_string "yes")
488          (eq_attr "itanium_class" "toar_m,frar_m") (const_string "yes")
489          (eq_attr "itanium_class" "frbr,tobr,mmmul") (const_string "yes")
490          (eq_attr "itanium_class" "tbit,ishf,topr,frpr") (const_string "yes")
491          (eq_attr "itanium_class" "toar_i,frar_i") (const_string "yes")
492          (eq_attr "itanium_class" "fmisc,fcmp") (const_string "yes")]
493         (const_string "no")))
494
495 ;; Predication.  True iff this instruction can be predicated.
496
497 (define_attr "predicable" "no,yes" (const_string "yes"))
498
499 ;; Empty.  True iff this insn does not generate any code.
500
501 (define_attr "empty" "no,yes" (const_string "no"))
502
503 \f
504
505 ;; DFA descriptions of ia64 processors used for insn scheduling and
506 ;; bundling.
507
508 (automata_option "ndfa")
509
510 ;; Uncomment the following line to output automata for debugging.
511 ;; (automata_option "v")
512
513 (automata_option "w")
514
515 ;;(automata_option "no-minimization")
516
517
518 (include "itanium1.md")
519 (include "itanium2.md")
520
521 \f
522 ;; ::::::::::::::::::::
523 ;; ::
524 ;; :: Moves
525 ;; ::
526 ;; ::::::::::::::::::::
527
528 ;; Set of a single predicate register.  This is only used to implement
529 ;; pr-to-pr move and complement.
530
531 (define_insn "*movcci"
532   [(set (match_operand:CCI 0 "register_operand" "=c,c,c")
533         (match_operand:CCI 1 "nonmemory_operand" "O,n,c"))]
534   ""
535   "@
536    cmp.ne %0, p0 = r0, r0
537    cmp.eq %0, p0 = r0, r0
538    (%1) cmp.eq.unc %0, p0 = r0, r0"
539   [(set_attr "itanium_class" "icmp")
540    (set_attr "predicable" "no")])
541
542 (define_insn "movbi"
543   [(set (match_operand:BI 0 "nonimmediate_operand" "=c,c,?c,?*r, c,*r,*r,*m,*r")
544         (match_operand:BI 1 "move_operand"         " O,n, c,  c,*r, n,*m,*r,*r"))]
545   ""
546   "@
547    cmp.ne %0, %I0 = r0, r0
548    cmp.eq %0, %I0 = r0, r0
549    #
550    #
551    tbit.nz %0, %I0 = %1, 0
552    adds %0 = %1, r0
553    ld1%O1 %0 = %1%P1
554    st1%Q0 %0 = %1%P0
555    mov %0 = %1"
556   [(set_attr "itanium_class" "icmp,icmp,unknown,unknown,tbit,ialu,ld,st,ialu")])
557
558 (define_split
559   [(set (match_operand:BI 0 "register_operand" "")
560         (match_operand:BI 1 "register_operand" ""))]
561   "reload_completed
562    && GET_CODE (operands[0]) == REG && GR_REGNO_P (REGNO (operands[0]))
563    && GET_CODE (operands[1]) == REG && PR_REGNO_P (REGNO (operands[1]))"
564   [(cond_exec (ne (match_dup 1) (const_int 0))
565      (set (match_dup 0) (const_int 1)))
566    (cond_exec (eq (match_dup 1) (const_int 0))
567      (set (match_dup 0) (const_int 0)))]
568   "")
569
570 (define_split
571   [(set (match_operand:BI 0 "register_operand" "")
572         (match_operand:BI 1 "register_operand" ""))]
573   "reload_completed
574    && GET_CODE (operands[0]) == REG && PR_REGNO_P (REGNO (operands[0]))
575    && GET_CODE (operands[1]) == REG && PR_REGNO_P (REGNO (operands[1]))"
576   [(set (match_dup 2) (match_dup 4))
577    (set (match_dup 3) (match_dup 5))
578    (set (match_dup 0) (unspec:BI [(match_dup 0)] UNSPEC_PRED_REL_MUTEX))]
579   "operands[2] = gen_rtx_REG (CCImode, REGNO (operands[0]));
580    operands[3] = gen_rtx_REG (CCImode, REGNO (operands[0]) + 1);
581    operands[4] = gen_rtx_REG (CCImode, REGNO (operands[1]));
582    operands[5] = gen_rtx_REG (CCImode, REGNO (operands[1]) + 1);")
583
584 (define_expand "movqi"
585   [(set (match_operand:QI 0 "general_operand" "")
586         (match_operand:QI 1 "general_operand" ""))]
587   ""
588 {
589   rtx op1 = ia64_expand_move (operands[0], operands[1]);
590   if (!op1)
591     DONE;
592   operands[1] = op1;
593 })
594
595 (define_insn "*movqi_internal"
596   [(set (match_operand:QI 0 "destination_operand" "=r,r,r, m, r,*f,*f")
597         (match_operand:QI 1 "move_operand"        "rO,J,m,rO,*f,rO,*f"))]
598   "ia64_move_ok (operands[0], operands[1])"
599   "@
600    mov %0 = %r1
601    addl %0 = %1, r0
602    ld1%O1 %0 = %1%P1
603    st1%Q0 %0 = %r1%P0
604    getf.sig %0 = %1
605    setf.sig %0 = %r1
606    mov %0 = %1"
607   [(set_attr "itanium_class" "ialu,ialu,ld,st,frfr,tofr,fmisc")])
608
609 (define_expand "movhi"
610   [(set (match_operand:HI 0 "general_operand" "")
611         (match_operand:HI 1 "general_operand" ""))]
612   ""
613 {
614   rtx op1 = ia64_expand_move (operands[0], operands[1]);
615   if (!op1)
616     DONE;
617   operands[1] = op1;
618 })
619
620 (define_insn "*movhi_internal"
621   [(set (match_operand:HI 0 "destination_operand" "=r,r,r, m, r,*f,*f")
622         (match_operand:HI 1 "move_operand"        "rO,J,m,rO,*f,rO,*f"))]
623   "ia64_move_ok (operands[0], operands[1])"
624   "@
625    mov %0 = %r1
626    addl %0 = %1, r0
627    ld2%O1 %0 = %1%P1
628    st2%Q0 %0 = %r1%P0
629    getf.sig %0 = %1
630    setf.sig %0 = %r1
631    mov %0 = %1"
632   [(set_attr "itanium_class" "ialu,ialu,ld,st,frfr,tofr,fmisc")])
633
634 (define_expand "movsi"
635   [(set (match_operand:SI 0 "general_operand" "")
636         (match_operand:SI 1 "general_operand" ""))]
637   ""
638 {
639   rtx op1 = ia64_expand_move (operands[0], operands[1]);
640   if (!op1)
641     DONE;
642   operands[1] = op1;
643 })
644
645 (define_insn "*movsi_internal"
646   [(set (match_operand:SI 0 "destination_operand" "=r,r,r,r, m, r,*f,*f, r,*d")
647         (match_operand:SI 1 "move_operand"        "rO,J,i,m,rO,*f,rO,*f,*d,rK"))]
648   "ia64_move_ok (operands[0], operands[1])"
649   "@
650   mov %0 = %r1
651   addl %0 = %1, r0
652   movl %0 = %1
653   ld4%O1 %0 = %1%P1
654   st4%Q0 %0 = %r1%P0
655   getf.sig %0 = %1
656   setf.sig %0 = %r1
657   mov %0 = %1
658   mov %0 = %1
659   mov %0 = %r1"
660   ;; frar_m, toar_m ??? why not frar_i and toar_i
661   [(set_attr "itanium_class" "ialu,ialu,long_i,ld,st,frfr,tofr,fmisc,frar_m,toar_m")])
662
663 (define_expand "movdi"
664   [(set (match_operand:DI 0 "general_operand" "")
665         (match_operand:DI 1 "general_operand" ""))]
666   ""
667 {
668   rtx op1 = ia64_expand_move (operands[0], operands[1]);
669   if (!op1)
670     DONE;
671   operands[1] = op1;
672 })
673
674 (define_insn "*movdi_internal"
675   [(set (match_operand:DI 0 "destination_operand"
676                     "=r,r,r,r, m, r,*f,*f,*f, Q, r,*b, r,*e, r,*d, r,*c")
677         (match_operand:DI 1 "move_operand"
678                     "rO,JT,i,m,rO,*f,rO,*f, Q,*f,*b,rO,*e,rK,*d,rK,*c,rO"))]
679   "ia64_move_ok (operands[0], operands[1])"
680 {
681   static const char * const alt[] = {
682     "%,mov %0 = %r1",
683     "%,addl %0 = %1, r0",
684     "%,movl %0 = %1",
685     "%,ld8%O1 %0 = %1%P1",
686     "%,st8%Q0 %0 = %r1%P0",
687     "%,getf.sig %0 = %1",
688     "%,setf.sig %0 = %r1",
689     "%,mov %0 = %1",
690     "%,ldf8 %0 = %1%P1",
691     "%,stf8 %0 = %1%P0",
692     "%,mov %0 = %1",
693     "%,mov %0 = %r1",
694     "%,mov %0 = %1",
695     "%,mov %0 = %1",
696     "%,mov %0 = %1",
697     "%,mov %0 = %1",
698     "mov %0 = pr",
699     "mov pr = %1, -1"
700   };
701
702   if (which_alternative == 2 && ! TARGET_NO_PIC
703       && symbolic_operand (operands[1], VOIDmode))
704     abort ();
705
706   return alt[which_alternative];
707 }
708   [(set_attr "itanium_class" "ialu,ialu,long_i,ld,st,frfr,tofr,fmisc,fld,stf,frbr,tobr,frar_i,toar_i,frar_m,toar_m,frpr,topr")])
709
710 (define_split
711   [(set (match_operand 0 "register_operand" "")
712         (match_operand 1 "symbolic_operand" ""))]
713   "reload_completed && ! TARGET_NO_PIC"
714   [(const_int 0)]
715 {
716   ia64_expand_load_address (operands[0], operands[1]);
717   DONE;
718 })
719
720 (define_expand "load_fptr"
721   [(set (match_dup 2)
722         (plus:DI (reg:DI 1) (match_operand 1 "function_operand" "")))
723    (set (match_operand:DI 0 "register_operand" "") (match_dup 3))]
724   ""
725 {
726   operands[2] = no_new_pseudos ? operands[0] : gen_reg_rtx (DImode);
727   operands[3] = gen_const_mem (DImode, operands[2]);
728 })
729
730 (define_insn "*load_fptr_internal1"
731   [(set (match_operand:DI 0 "register_operand" "=r")
732         (plus:DI (reg:DI 1) (match_operand 1 "function_operand" "s")))]
733   ""
734   "addl %0 = @ltoff(@fptr(%1)), gp"
735   [(set_attr "itanium_class" "ialu")])
736
737 (define_insn "load_gprel"
738   [(set (match_operand:DI 0 "register_operand" "=r")
739         (plus:DI (reg:DI 1) (match_operand 1 "sdata_symbolic_operand" "s")))]
740   ""
741   "addl %0 = @gprel(%1), gp"
742   [(set_attr "itanium_class" "ialu")])
743
744 (define_insn "gprel64_offset"
745   [(set (match_operand:DI 0 "register_operand" "=r")
746         (minus:DI (match_operand:DI 1 "symbolic_operand" "") (reg:DI 1)))]
747   ""
748   "movl %0 = @gprel(%1)"
749   [(set_attr "itanium_class" "long_i")])
750
751 (define_expand "load_gprel64"
752   [(set (match_dup 2)
753         (minus:DI (match_operand:DI 1 "symbolic_operand" "") (match_dup 3)))
754    (set (match_operand:DI 0 "register_operand" "")
755         (plus:DI (match_dup 3) (match_dup 2)))]
756   ""
757 {
758   operands[2] = no_new_pseudos ? operands[0] : gen_reg_rtx (DImode);
759   operands[3] = pic_offset_table_rtx;
760 })
761
762 ;; This is used as a placeholder for the return address during early
763 ;; compilation.  We won't know where we've placed this until during
764 ;; reload, at which point it can wind up in b0, a general register,
765 ;; or memory.  The only safe destination under these conditions is a
766 ;; general register.
767
768 (define_insn_and_split "*movdi_ret_addr"
769   [(set (match_operand:DI 0 "register_operand" "=r")
770         (unspec:DI [(const_int 0)] UNSPEC_RET_ADDR))]
771   ""
772   "#"
773   "reload_completed"
774   [(const_int 0)]
775 {
776   ia64_split_return_addr_rtx (operands[0]);
777   DONE;
778 }
779   [(set_attr "itanium_class" "ialu")])
780
781 (define_insn "*load_symptr_high"
782   [(set (match_operand:DI 0 "register_operand" "=r")
783         (plus:DI (high:DI (match_operand 1 "got_symbolic_operand" "s"))
784                  (match_operand:DI 2 "register_operand" "a")))]
785   ""
786 {
787   if (HAVE_AS_LTOFFX_LDXMOV_RELOCS)
788     return "%,addl %0 = @ltoffx(%1), %2";
789   else
790     return "%,addl %0 = @ltoff(%1), %2";
791 }
792   [(set_attr "itanium_class" "ialu")])
793
794 (define_insn "*load_symptr_low"
795   [(set (match_operand:DI 0 "register_operand" "=r")
796         (lo_sum:DI (match_operand:DI 1 "register_operand" "r")
797                    (match_operand 2 "got_symbolic_operand" "s")))]
798   ""
799 {
800   if (HAVE_AS_LTOFFX_LDXMOV_RELOCS)
801     return "%,ld8.mov %0 = [%1], %2";
802   else
803     return "%,ld8 %0 = [%1]";
804 }
805   [(set_attr "itanium_class" "ld")])
806
807 (define_insn "load_ltoff_dtpmod"
808   [(set (match_operand:DI 0 "register_operand" "=r")
809         (plus:DI (reg:DI 1)
810                  (unspec:DI [(match_operand:DI 1 "symbolic_operand" "")]
811                             UNSPEC_LTOFF_DTPMOD)))]
812   ""
813   "addl %0 = @ltoff(@dtpmod(%1)), gp"
814   [(set_attr "itanium_class" "ialu")])
815
816 (define_insn "load_ltoff_dtprel"
817   [(set (match_operand:DI 0 "register_operand" "=r")
818         (plus:DI (reg:DI 1)
819                  (unspec:DI [(match_operand:DI 1 "symbolic_operand" "")]
820                             UNSPEC_LTOFF_DTPREL)))]
821   ""
822   "addl %0 = @ltoff(@dtprel(%1)), gp"
823   [(set_attr "itanium_class" "ialu")])
824
825 (define_expand "load_dtprel"
826   [(set (match_operand:DI 0 "register_operand" "")
827         (unspec:DI [(match_operand:DI 1 "symbolic_operand" "")]
828                    UNSPEC_DTPREL))]
829   ""
830   "")
831
832 (define_insn "*load_dtprel64"
833   [(set (match_operand:DI 0 "register_operand" "=r")
834         (unspec:DI [(match_operand:DI 1 "symbolic_operand" "")]
835                    UNSPEC_DTPREL))]
836   "TARGET_TLS64"
837   "movl %0 = @dtprel(%1)"
838   [(set_attr "itanium_class" "long_i")])
839
840 (define_insn "*load_dtprel22"
841   [(set (match_operand:DI 0 "register_operand" "=r")
842         (unspec:DI [(match_operand:DI 1 "symbolic_operand" "")]
843                    UNSPEC_DTPREL))]
844   ""
845   "addl %0 = @dtprel(%1), r0"
846   [(set_attr "itanium_class" "ialu")])
847
848 (define_expand "add_dtprel"
849   [(set (match_operand:DI 0 "register_operand" "")
850         (plus:DI (match_operand:DI 1 "register_operand" "")
851                  (unspec:DI [(match_operand:DI 2 "symbolic_operand" "")]
852                             UNSPEC_DTPREL)))]
853   "!TARGET_TLS64"
854   "")
855
856 (define_insn "*add_dtprel14"
857   [(set (match_operand:DI 0 "register_operand" "=r")
858         (plus:DI (match_operand:DI 1 "register_operand" "r")
859                  (unspec:DI [(match_operand:DI 2 "symbolic_operand" "")]
860                             UNSPEC_DTPREL)))]
861   "TARGET_TLS14"
862   "adds %0 = @dtprel(%2), %1"
863   [(set_attr "itanium_class" "ialu")])
864
865 (define_insn "*add_dtprel22"
866   [(set (match_operand:DI 0 "register_operand" "=r")
867         (plus:DI (match_operand:DI 1 "register_operand" "a")
868                  (unspec:DI [(match_operand:DI 2 "symbolic_operand" "")]
869                             UNSPEC_DTPREL)))]
870   "TARGET_TLS22"
871   "addl %0 = @dtprel(%2), %1"
872   [(set_attr "itanium_class" "ialu")])
873
874 (define_insn "load_ltoff_tprel"
875   [(set (match_operand:DI 0 "register_operand" "=r")
876         (plus:DI (reg:DI 1)
877                  (unspec:DI [(match_operand:DI 1 "symbolic_operand" "")]
878                             UNSPEC_LTOFF_TPREL)))]
879   ""
880   "addl %0 = @ltoff(@tprel(%1)), gp"
881   [(set_attr "itanium_class" "ialu")])
882
883 (define_expand "load_tprel"
884   [(set (match_operand:DI 0 "register_operand" "")
885         (unspec:DI [(match_operand:DI 1 "symbolic_operand" "")]
886                    UNSPEC_TPREL))]
887   ""
888   "")
889
890 (define_insn "*load_tprel64"
891   [(set (match_operand:DI 0 "register_operand" "=r")
892         (unspec:DI [(match_operand:DI 1 "symbolic_operand" "")]
893                    UNSPEC_TPREL))]
894   "TARGET_TLS64"
895   "movl %0 = @tprel(%1)"
896   [(set_attr "itanium_class" "long_i")])
897
898 (define_insn "*load_tprel22"
899   [(set (match_operand:DI 0 "register_operand" "=r")
900         (unspec:DI [(match_operand:DI 1 "symbolic_operand" "")]
901                    UNSPEC_TPREL))]
902   ""
903   "addl %0 = @tprel(%1), r0"
904   [(set_attr "itanium_class" "ialu")])
905
906 (define_expand "add_tprel"
907   [(set (match_operand:DI 0 "register_operand" "")
908         (plus:DI (match_operand:DI 1 "register_operand" "")
909                  (unspec:DI [(match_operand:DI 2 "symbolic_operand" "")]
910                             UNSPEC_TPREL)))]
911   "!TARGET_TLS64"
912   "")
913
914 (define_insn "*add_tprel14"
915   [(set (match_operand:DI 0 "register_operand" "=r")
916         (plus:DI (match_operand:DI 1 "register_operand" "r")
917                  (unspec:DI [(match_operand:DI 2 "symbolic_operand" "")]
918                             UNSPEC_TPREL)))]
919   "TARGET_TLS14"
920   "adds %0 = @tprel(%2), %1"
921   [(set_attr "itanium_class" "ialu")])
922
923 (define_insn "*add_tprel22"
924   [(set (match_operand:DI 0 "register_operand" "=r")
925         (plus:DI (match_operand:DI 1 "register_operand" "a")
926                  (unspec:DI [(match_operand:DI 2 "symbolic_operand" "")]
927                             UNSPEC_TPREL)))]
928   "TARGET_TLS22"
929   "addl %0 = @tprel(%2), %1"
930   [(set_attr "itanium_class" "ialu")])
931
932 ;; With no offsettable memory references, we've got to have a scratch
933 ;; around to play with the second word.  However, in order to avoid a
934 ;; reload nightmare we lie, claim we don't need one, and fix it up
935 ;; in ia64_split_tmode_move.
936 (define_expand "movti"
937   [(set (match_operand:TI 0 "general_operand" "")
938         (match_operand:TI 1 "general_operand" ""))]
939   ""
940 {
941   rtx op1 = ia64_expand_move (operands[0], operands[1]);
942   if (!op1)
943     DONE;
944   operands[1] = op1;
945 })
946
947 (define_insn_and_split "*movti_internal"
948   [(set (match_operand:TI 0 "nonimmediate_operand" "=r,r,m")
949         (match_operand:TI 1 "general_operand"      "ri,m,r"))]
950   "ia64_move_ok (operands[0], operands[1])"
951   "#"
952   "reload_completed"
953   [(const_int 0)]
954 {
955   ia64_split_tmode_move (operands);
956   DONE;
957 }
958   [(set_attr "itanium_class" "unknown")
959    (set_attr "predicable" "no")])
960
961 ;; Floating Point Moves
962 ;;
963 ;; Note - Patterns for SF mode moves are compulsory, but
964 ;; patterns for DF are optional, as GCC can synthesize them.
965
966 (define_expand "movsf"
967   [(set (match_operand:SF 0 "general_operand" "")
968         (match_operand:SF 1 "general_operand" ""))]
969   ""
970 {
971   rtx op1 = ia64_expand_move (operands[0], operands[1]);
972   if (!op1)
973     DONE;
974   operands[1] = op1;
975 })
976
977 (define_insn "*movsf_internal"
978   [(set (match_operand:SF 0 "destination_operand" "=f,f, Q,*r, f,*r,*r, m")
979         (match_operand:SF 1 "general_operand"     "fG,Q,fG,fG,*r,*r, m,*r"))]
980   "ia64_move_ok (operands[0], operands[1])"
981   "@
982    mov %0 = %F1
983    ldfs %0 = %1%P1
984    stfs %0 = %F1%P0
985    getf.s %0 = %F1
986    setf.s %0 = %1
987    mov %0 = %1
988    ld4%O1 %0 = %1%P1
989    st4%Q0 %0 = %1%P0"
990   [(set_attr "itanium_class" "fmisc,fld,stf,frfr,tofr,ialu,ld,st")])
991
992 (define_expand "movdf"
993   [(set (match_operand:DF 0 "general_operand" "")
994         (match_operand:DF 1 "general_operand" ""))]
995   ""
996 {
997   rtx op1 = ia64_expand_move (operands[0], operands[1]);
998   if (!op1)
999     DONE;
1000   operands[1] = op1;
1001 })
1002
1003 (define_insn "*movdf_internal"
1004   [(set (match_operand:DF 0 "destination_operand" "=f,f, Q,*r, f,*r,*r, m")
1005         (match_operand:DF 1 "general_operand"     "fG,Q,fG,fG,*r,*r, m,*r"))]
1006   "ia64_move_ok (operands[0], operands[1])"
1007   "@
1008    mov %0 = %F1
1009    ldfd %0 = %1%P1
1010    stfd %0 = %F1%P0
1011    getf.d %0 = %F1
1012    setf.d %0 = %1
1013    mov %0 = %1
1014    ld8%O1 %0 = %1%P1
1015    st8%Q0 %0 = %1%P0"
1016   [(set_attr "itanium_class" "fmisc,fld,stf,frfr,tofr,ialu,ld,st")])
1017
1018 ;; With no offsettable memory references, we've got to have a scratch
1019 ;; around to play with the second word if the variable winds up in GRs.
1020 (define_expand "movxf"
1021   [(set (match_operand:XF 0 "general_operand" "")
1022         (match_operand:XF 1 "general_operand" ""))]
1023   ""
1024 {
1025   rtx op0 = operands[0];
1026
1027   if (GET_CODE (op0) == SUBREG)
1028     op0 = SUBREG_REG (op0);
1029
1030   /* We must support XFmode loads into general registers for stdarg/vararg
1031      and unprototyped calls.  We split them into DImode loads for convenience.
1032      We don't need XFmode stores from general regs, because a stdarg/vararg
1033      routine does a block store to memory of unnamed arguments.  */
1034
1035   if (GET_CODE (op0) == REG && GR_REGNO_P (REGNO (op0)))
1036     {
1037       /* We're hoping to transform everything that deals with XFmode
1038          quantities and GR registers early in the compiler.  */
1039       if (no_new_pseudos)
1040         abort ();
1041
1042       /* Struct to register can just use TImode instead.  */
1043       if ((GET_CODE (operands[1]) == SUBREG
1044            && GET_MODE (SUBREG_REG (operands[1])) == TImode)
1045           || (GET_CODE (operands[1]) == REG
1046               && GR_REGNO_P (REGNO (operands[1]))))
1047         {
1048           rtx op1 = operands[1];
1049
1050           if (GET_CODE (op1) == SUBREG)
1051             op1 = SUBREG_REG (op1);
1052           else
1053             /* ??? Maybe we should make a SUBREG here?  */
1054             op1 = gen_rtx_REG (TImode, REGNO (op1));
1055
1056           emit_move_insn (gen_rtx_REG (TImode, REGNO (op0)), op1);
1057           DONE;
1058         }
1059
1060       if (GET_CODE (operands[1]) == CONST_DOUBLE)
1061         {
1062           emit_move_insn (gen_rtx_REG (DImode, REGNO (op0)),
1063                           operand_subword (operands[1], 0, 0, XFmode));
1064           emit_move_insn (gen_rtx_REG (DImode, REGNO (op0) + 1),
1065                           operand_subword (operands[1], 1, 0, XFmode));
1066           DONE;
1067         }
1068
1069       /* If the quantity is in a register not known to be GR, spill it.  */
1070       if (register_operand (operands[1], XFmode))
1071         operands[1] = spill_xfmode_operand (operands[1], 1);
1072
1073       if (GET_CODE (operands[1]) == MEM)
1074         {
1075           rtx out[2];
1076
1077           out[WORDS_BIG_ENDIAN] = gen_rtx_REG (DImode, REGNO (op0));
1078           out[!WORDS_BIG_ENDIAN] = gen_rtx_REG (DImode, REGNO (op0) + 1);
1079
1080           emit_move_insn (out[0], adjust_address (operands[1], DImode, 0));
1081           emit_move_insn (out[1], adjust_address (operands[1], DImode, 8));
1082           DONE;
1083         }
1084
1085       abort ();
1086     }
1087
1088   if (! reload_in_progress && ! reload_completed)
1089     {
1090       operands[1] = spill_xfmode_operand (operands[1], 0);
1091
1092       if (GET_MODE (op0) == TImode && GET_CODE (op0) == REG)
1093         {
1094           rtx memt, memx, in = operands[1];
1095           if (CONSTANT_P (in))
1096             in = validize_mem (force_const_mem (XFmode, in));
1097           if (GET_CODE (in) == MEM)
1098             memt = adjust_address (in, TImode, 0);
1099           else
1100             {
1101               memt = assign_stack_temp (TImode, 16, 0);
1102               memx = adjust_address (memt, XFmode, 0);
1103               emit_move_insn (memx, in);
1104             }
1105           emit_move_insn (op0, memt);
1106           DONE;
1107         }
1108
1109       if (! ia64_move_ok (operands[0], operands[1]))
1110         operands[1] = force_reg (XFmode, operands[1]);
1111     }
1112 })
1113
1114 ;; ??? There's no easy way to mind volatile acquire/release semantics.
1115
1116 (define_insn "*movxf_internal"
1117   [(set (match_operand:XF 0 "destination_operand" "=f,f, m")
1118         (match_operand:XF 1 "general_operand"     "fG,m,fG"))]
1119   "ia64_move_ok (operands[0], operands[1])"
1120   "@
1121    mov %0 = %F1
1122    ldfe %0 = %1%P1
1123    stfe %0 = %F1%P0"
1124   [(set_attr "itanium_class" "fmisc,fld,stf")])
1125
1126 ;; Better code generation via insns that deal with TFmode register pairs
1127 ;; directly.  Same concerns apply as for TImode.
1128 (define_expand "movtf"
1129   [(set (match_operand:TF 0 "general_operand" "")
1130         (match_operand:TF 1 "general_operand" ""))]
1131   ""
1132 {
1133   rtx op1 = ia64_expand_move (operands[0], operands[1]);
1134   if (!op1)
1135     DONE;
1136   operands[1] = op1;
1137 })
1138
1139 (define_insn_and_split "*movtf_internal"
1140   [(set (match_operand:TF 0 "nonimmediate_operand" "=r,r,m")
1141         (match_operand:TF 1 "general_operand"      "ri,m,r"))]
1142   "ia64_move_ok (operands[0], operands[1])"
1143   "#"
1144   "reload_completed"
1145   [(const_int 0)]
1146 {
1147   ia64_split_tmode_move (operands);
1148   DONE;
1149 }
1150   [(set_attr "itanium_class" "unknown")
1151    (set_attr "predicable" "no")])
1152
1153 \f
1154 ;; ::::::::::::::::::::
1155 ;; ::
1156 ;; :: Conversions
1157 ;; ::
1158 ;; ::::::::::::::::::::
1159
1160 ;; Signed conversions from a smaller integer to a larger integer
1161
1162 (define_insn "extendqidi2"
1163   [(set (match_operand:DI 0 "gr_register_operand" "=r")
1164         (sign_extend:DI (match_operand:QI 1 "gr_register_operand" "r")))]
1165   ""
1166   "sxt1 %0 = %1"
1167   [(set_attr "itanium_class" "xtd")])
1168
1169 (define_insn "extendhidi2"
1170   [(set (match_operand:DI 0 "gr_register_operand" "=r")
1171         (sign_extend:DI (match_operand:HI 1 "gr_register_operand" "r")))]
1172   ""
1173   "sxt2 %0 = %1"
1174   [(set_attr "itanium_class" "xtd")])
1175
1176 (define_insn "extendsidi2"
1177   [(set (match_operand:DI 0 "grfr_register_operand" "=r,?f")
1178         (sign_extend:DI (match_operand:SI 1 "grfr_register_operand" "r,f")))]
1179   ""
1180   "@
1181    sxt4 %0 = %1
1182    fsxt.r %0 = %1, %1"
1183   [(set_attr "itanium_class" "xtd,fmisc")])
1184
1185 ;; Unsigned conversions from a smaller integer to a larger integer
1186
1187 (define_insn "zero_extendqidi2"
1188   [(set (match_operand:DI 0 "gr_register_operand" "=r,r")
1189         (zero_extend:DI (match_operand:QI 1 "gr_nonimmediate_operand" "r,m")))]
1190   ""
1191   "@
1192    zxt1 %0 = %1
1193    ld1%O1 %0 = %1%P1"
1194   [(set_attr "itanium_class" "xtd,ld")])
1195
1196 (define_insn "zero_extendhidi2"
1197   [(set (match_operand:DI 0 "gr_register_operand" "=r,r")
1198         (zero_extend:DI (match_operand:HI 1 "gr_nonimmediate_operand" "r,m")))]
1199   ""
1200   "@
1201    zxt2 %0 = %1
1202    ld2%O1 %0 = %1%P1"
1203   [(set_attr "itanium_class" "xtd,ld")])
1204
1205 (define_insn "zero_extendsidi2"
1206   [(set (match_operand:DI 0 "grfr_register_operand" "=r,r,?f")
1207         (zero_extend:DI
1208           (match_operand:SI 1 "grfr_nonimmediate_operand" "r,m,f")))]
1209   ""
1210   "@
1211    zxt4 %0 = %1
1212    ld4%O1 %0 = %1%P1
1213    fmix.r %0 = f0, %1"
1214   [(set_attr "itanium_class" "xtd,ld,fmisc")])
1215
1216 ;; Convert between floating point types of different sizes.
1217
1218 ;; At first glance, it would appear that emitting fnorm for an extending
1219 ;; conversion is unnecessary.  However, the stf and getf instructions work
1220 ;; correctly only if the input is properly rounded for its type.  In
1221 ;; particular, we get the wrong result for getf.d/stfd if the input is a
1222 ;; denorm single.  Since we don't know what the next instruction will be, we
1223 ;; have to emit an fnorm.
1224
1225 ;; ??? Optimization opportunity here.  Get rid of the insn altogether
1226 ;; when we can.  Should probably use a scheme like has been proposed
1227 ;; for ia32 in dealing with operands that match unary operators.  This
1228 ;; would let combine merge the thing into adjacent insns.  See also how the
1229 ;; mips port handles SIGN_EXTEND as operands to integer arithmetic insns via
1230 ;; se_register_operand.
1231
1232 (define_insn "extendsfdf2"
1233   [(set (match_operand:DF 0 "fr_register_operand" "=f")
1234         (float_extend:DF (match_operand:SF 1 "fr_register_operand" "f")))]
1235   ""
1236   "fnorm.d %0 = %1"
1237   [(set_attr "itanium_class" "fmac")])
1238
1239 (define_insn "extendsfxf2"
1240   [(set (match_operand:XF 0 "fr_register_operand" "=f")
1241         (float_extend:XF (match_operand:SF 1 "fr_register_operand" "f")))]
1242   ""
1243   "fnorm %0 = %1"
1244   [(set_attr "itanium_class" "fmac")])
1245
1246 (define_insn "extenddfxf2"
1247   [(set (match_operand:XF 0 "fr_register_operand" "=f")
1248         (float_extend:XF (match_operand:DF 1 "fr_register_operand" "f")))]
1249   ""
1250   "fnorm %0 = %1"
1251   [(set_attr "itanium_class" "fmac")])
1252
1253 (define_insn "truncdfsf2"
1254   [(set (match_operand:SF 0 "fr_register_operand" "=f")
1255         (float_truncate:SF (match_operand:DF 1 "fr_register_operand" "f")))]
1256   ""
1257   "fnorm.s %0 = %1"
1258   [(set_attr "itanium_class" "fmac")])
1259
1260 (define_insn "truncxfsf2"
1261   [(set (match_operand:SF 0 "fr_register_operand" "=f")
1262         (float_truncate:SF (match_operand:XF 1 "fr_register_operand" "f")))]
1263   ""
1264   "fnorm.s %0 = %1"
1265   [(set_attr "itanium_class" "fmac")])
1266
1267 (define_insn "truncxfdf2"
1268   [(set (match_operand:DF 0 "fr_register_operand" "=f")
1269         (float_truncate:DF (match_operand:XF 1 "fr_register_operand" "f")))]
1270   ""
1271   "fnorm.d %0 = %1"
1272   [(set_attr "itanium_class" "fmac")])
1273
1274 ;; Convert between signed integer types and floating point.
1275
1276 (define_insn "floatdixf2"
1277   [(set (match_operand:XF 0 "fr_register_operand" "=f")
1278         (float:XF (match_operand:DI 1 "fr_register_operand" "f")))]
1279   ""
1280   "fcvt.xf %0 = %1"
1281   [(set_attr "itanium_class" "fcvtfx")])
1282
1283 (define_insn "fix_truncsfdi2"
1284   [(set (match_operand:DI 0 "fr_register_operand" "=f")
1285         (fix:DI (match_operand:SF 1 "fr_register_operand" "f")))]
1286   ""
1287   "fcvt.fx.trunc %0 = %1"
1288   [(set_attr "itanium_class" "fcvtfx")])
1289
1290 (define_insn "fix_truncdfdi2"
1291   [(set (match_operand:DI 0 "fr_register_operand" "=f")
1292         (fix:DI (match_operand:DF 1 "fr_register_operand" "f")))]
1293   ""
1294   "fcvt.fx.trunc %0 = %1"
1295   [(set_attr "itanium_class" "fcvtfx")])
1296
1297 (define_insn "fix_truncxfdi2"
1298   [(set (match_operand:DI 0 "fr_register_operand" "=f")
1299         (fix:DI (match_operand:XF 1 "fr_register_operand" "f")))]
1300   ""
1301   "fcvt.fx.trunc %0 = %1"
1302   [(set_attr "itanium_class" "fcvtfx")])
1303
1304 (define_insn "fix_truncxfdi2_alts"
1305   [(set (match_operand:DI 0 "fr_register_operand" "=f")
1306         (fix:DI (match_operand:XF 1 "fr_register_operand" "f")))
1307    (use (match_operand:SI 2 "const_int_operand" ""))]
1308   ""
1309   "fcvt.fx.trunc.s%2 %0 = %1"
1310   [(set_attr "itanium_class" "fcvtfx")])
1311
1312 ;; Convert between unsigned integer types and floating point.
1313
1314 (define_insn "floatunsdisf2"
1315   [(set (match_operand:SF 0 "fr_register_operand" "=f")
1316         (unsigned_float:SF (match_operand:DI 1 "fr_register_operand" "f")))]
1317   ""
1318   "fcvt.xuf.s %0 = %1"
1319   [(set_attr "itanium_class" "fcvtfx")])
1320
1321 (define_insn "floatunsdidf2"
1322   [(set (match_operand:DF 0 "fr_register_operand" "=f")
1323         (unsigned_float:DF (match_operand:DI 1 "fr_register_operand" "f")))]
1324   ""
1325   "fcvt.xuf.d %0 = %1"
1326   [(set_attr "itanium_class" "fcvtfx")])
1327
1328 (define_insn "floatunsdixf2"
1329   [(set (match_operand:XF 0 "fr_register_operand" "=f")
1330         (unsigned_float:XF (match_operand:DI 1 "fr_register_operand" "f")))]
1331   ""
1332   "fcvt.xuf %0 = %1"
1333   [(set_attr "itanium_class" "fcvtfx")])
1334
1335 (define_insn "fixuns_truncsfdi2"
1336   [(set (match_operand:DI 0 "fr_register_operand" "=f")
1337         (unsigned_fix:DI (match_operand:SF 1 "fr_register_operand" "f")))]
1338   ""
1339   "fcvt.fxu.trunc %0 = %1"
1340   [(set_attr "itanium_class" "fcvtfx")])
1341
1342 (define_insn "fixuns_truncdfdi2"
1343   [(set (match_operand:DI 0 "fr_register_operand" "=f")
1344         (unsigned_fix:DI (match_operand:DF 1 "fr_register_operand" "f")))]
1345   ""
1346   "fcvt.fxu.trunc %0 = %1"
1347   [(set_attr "itanium_class" "fcvtfx")])
1348
1349 (define_insn "fixuns_truncxfdi2"
1350   [(set (match_operand:DI 0 "fr_register_operand" "=f")
1351         (unsigned_fix:DI (match_operand:XF 1 "fr_register_operand" "f")))]
1352   ""
1353   "fcvt.fxu.trunc %0 = %1"
1354   [(set_attr "itanium_class" "fcvtfx")])
1355
1356 (define_insn "fixuns_truncxfdi2_alts"
1357   [(set (match_operand:DI 0 "fr_register_operand" "=f")
1358         (unsigned_fix:DI (match_operand:XF 1 "fr_register_operand" "f")))
1359    (use (match_operand:SI 2 "const_int_operand" ""))]
1360   ""
1361   "fcvt.fxu.trunc.s%2 %0 = %1"
1362   [(set_attr "itanium_class" "fcvtfx")])
1363 \f
1364 ;; ::::::::::::::::::::
1365 ;; ::
1366 ;; :: Bit field extraction
1367 ;; ::
1368 ;; ::::::::::::::::::::
1369
1370 (define_insn "extv"
1371   [(set (match_operand:DI 0 "gr_register_operand" "=r")
1372         (sign_extract:DI (match_operand:DI 1 "gr_register_operand" "r")
1373                          (match_operand:DI 2 "const_int_operand" "n")
1374                          (match_operand:DI 3 "const_int_operand" "n")))]
1375   ""
1376   "extr %0 = %1, %3, %2"
1377   [(set_attr "itanium_class" "ishf")])
1378
1379 (define_insn "extzv"
1380   [(set (match_operand:DI 0 "gr_register_operand" "=r")
1381         (zero_extract:DI (match_operand:DI 1 "gr_register_operand" "r")
1382                          (match_operand:DI 2 "const_int_operand" "n")
1383                          (match_operand:DI 3 "const_int_operand" "n")))]
1384   ""
1385   "extr.u %0 = %1, %3, %2"
1386   [(set_attr "itanium_class" "ishf")])
1387
1388 ;; Insert a bit field.
1389 ;; Can have 3 operands, source1 (inserter), source2 (insertee), dest.
1390 ;; Source1 can be 0 or -1.
1391 ;; Source2 can be 0.
1392
1393 ;; ??? Actual dep instruction is more powerful than what these insv
1394 ;; patterns support.  Unfortunately, combine is unable to create patterns
1395 ;; where source2 != dest.
1396
1397 (define_expand "insv"
1398   [(set (zero_extract:DI (match_operand:DI 0 "gr_register_operand" "")
1399                          (match_operand:DI 1 "const_int_operand" "")
1400                          (match_operand:DI 2 "const_int_operand" ""))
1401         (match_operand:DI 3 "nonmemory_operand" ""))]
1402   ""
1403 {
1404   int width = INTVAL (operands[1]);
1405   int shift = INTVAL (operands[2]);
1406
1407   /* If operand[3] is a constant, and isn't 0 or -1, then load it into a
1408      pseudo.  */
1409   if (! register_operand (operands[3], DImode)
1410       && operands[3] != const0_rtx && operands[3] != constm1_rtx)
1411     operands[3] = force_reg (DImode, operands[3]);
1412
1413   /* If this is a single dep instruction, we have nothing to do.  */
1414   if (! ((register_operand (operands[3], DImode) && width <= 16)
1415          || operands[3] == const0_rtx || operands[3] == constm1_rtx))
1416     {
1417       /* Check for cases that can be implemented with a mix instruction.  */
1418       if (width == 32 && shift == 0)
1419         {
1420           /* Directly generating the mix4left instruction confuses
1421              optimize_bit_field in function.c.  Since this is performing
1422              a useful optimization, we defer generation of the complicated
1423              mix4left RTL to the first splitting phase.  */
1424           rtx tmp = gen_reg_rtx (DImode);
1425           emit_insn (gen_shift_mix4left (operands[0], operands[3], tmp));
1426           DONE;
1427         }
1428       else if (width == 32 && shift == 32)
1429         {
1430           emit_insn (gen_mix4right (operands[0], operands[3]));
1431           DONE;
1432         }
1433
1434       /* We could handle remaining cases by emitting multiple dep
1435          instructions.
1436
1437          If we need more than two dep instructions then we lose.  A 6
1438          insn sequence mov mask1,mov mask2,shl;;and,and;;or is better than
1439          mov;;dep,shr;;dep,shr;;dep.  The former can be executed in 3 cycles,
1440          the latter is 6 cycles on an Itanium (TM) processor, because there is
1441          only one function unit that can execute dep and shr immed.
1442
1443          If we only need two dep instruction, then we still lose.
1444          mov;;dep,shr;;dep is still 4 cycles.  Even if we optimize away
1445          the unnecessary mov, this is still undesirable because it will be
1446          hard to optimize, and it creates unnecessary pressure on the I0
1447          function unit.  */
1448
1449       FAIL;
1450
1451 #if 0
1452       /* This code may be useful for other IA-64 processors, so we leave it in
1453          for now.  */
1454       while (width > 16)
1455         {
1456           rtx tmp;
1457
1458           emit_insn (gen_insv (operands[0], GEN_INT (16), GEN_INT (shift),
1459                                operands[3]));
1460           shift += 16;
1461           width -= 16;
1462           tmp = gen_reg_rtx (DImode);
1463           emit_insn (gen_lshrdi3 (tmp, operands[3], GEN_INT (16)));
1464           operands[3] = tmp;
1465         }
1466       operands[1] = GEN_INT (width);
1467       operands[2] = GEN_INT (shift);
1468 #endif
1469     }
1470 })
1471
1472 (define_insn "*insv_internal"
1473   [(set (zero_extract:DI (match_operand:DI 0 "gr_register_operand" "+r")
1474                          (match_operand:DI 1 "const_int_operand" "n")
1475                          (match_operand:DI 2 "const_int_operand" "n"))
1476         (match_operand:DI 3 "nonmemory_operand" "rP"))]
1477   "(gr_register_operand (operands[3], DImode) && INTVAL (operands[1]) <= 16)
1478    || operands[3] == const0_rtx || operands[3] == constm1_rtx"
1479   "dep %0 = %3, %0, %2, %1"
1480   [(set_attr "itanium_class" "ishf")])
1481
1482 ;; Combine doesn't like to create bit-field insertions into zero.
1483 (define_insn "*depz_internal"
1484   [(set (match_operand:DI 0 "gr_register_operand" "=r")
1485         (and:DI (ashift:DI (match_operand:DI 1 "gr_register_operand" "r")
1486                            (match_operand:DI 2 "const_int_operand" "n"))
1487                 (match_operand:DI 3 "const_int_operand" "n")))]
1488   "CONST_OK_FOR_M (INTVAL (operands[2]))
1489    && ia64_depz_field_mask (operands[3], operands[2]) > 0"
1490 {
1491   operands[3] = GEN_INT (ia64_depz_field_mask (operands[3], operands[2]));
1492   return "%,dep.z %0 = %1, %2, %3";
1493 }
1494   [(set_attr "itanium_class" "ishf")])
1495
1496 (define_insn "shift_mix4left"
1497   [(set (zero_extract:DI (match_operand:DI 0 "gr_register_operand" "+r")
1498                          (const_int 32) (const_int 0))
1499         (match_operand:DI 1 "gr_register_operand" "r"))
1500    (clobber (match_operand:DI 2 "gr_register_operand" "=r"))]
1501   ""
1502   "#"
1503   [(set_attr "itanium_class" "unknown")])
1504
1505 (define_split
1506   [(set (zero_extract:DI (match_operand:DI 0 "register_operand" "")
1507                          (const_int 32) (const_int 0))
1508         (match_operand:DI 1 "register_operand" ""))
1509    (clobber (match_operand:DI 2 "register_operand" ""))]
1510   ""
1511   [(set (match_dup 3) (ashift:DI (match_dup 1) (const_int 32)))
1512    (set (zero_extract:DI (match_dup 0) (const_int 32) (const_int 0))
1513         (lshiftrt:DI (match_dup 3) (const_int 32)))]
1514   "operands[3] = operands[2];")
1515
1516 (define_insn "*mix4left"
1517   [(set (zero_extract:DI (match_operand:DI 0 "gr_register_operand" "+r")
1518                          (const_int 32) (const_int 0))
1519         (lshiftrt:DI (match_operand:DI 1 "gr_register_operand" "r")
1520                      (const_int 32)))]
1521   ""
1522   "mix4.l %0 = %0, %r1"
1523   [(set_attr "itanium_class" "mmshf")])
1524
1525 (define_insn "mix4right"
1526   [(set (zero_extract:DI (match_operand:DI 0 "gr_register_operand" "+r")
1527                          (const_int 32) (const_int 32))
1528         (match_operand:DI 1 "gr_reg_or_0_operand" "rO"))]
1529   ""
1530   "mix4.r %0 = %r1, %0"
1531   [(set_attr "itanium_class" "mmshf")])
1532
1533 ;; This is used by the rotrsi3 pattern.
1534
1535 (define_insn "*mix4right_3op"
1536   [(set (match_operand:DI 0 "gr_register_operand" "=r")
1537         (ior:DI (zero_extend:DI (match_operand:SI 1 "gr_register_operand" "r"))
1538                 (ashift:DI (zero_extend:DI
1539                              (match_operand:SI 2 "gr_register_operand" "r"))
1540                            (const_int 32))))]
1541   ""
1542   "mix4.r %0 = %2, %1"
1543   [(set_attr "itanium_class" "mmshf")])
1544
1545 \f
1546 ;; ::::::::::::::::::::
1547 ;; ::
1548 ;; :: 1 bit Integer arithmetic
1549 ;; ::
1550 ;; ::::::::::::::::::::
1551
1552 (define_insn_and_split "andbi3"
1553   [(set (match_operand:BI 0 "register_operand" "=c,c,r")
1554         (and:BI (match_operand:BI 1 "register_operand" "%0,0,r")
1555                 (match_operand:BI 2 "register_operand" "c,r,r")))]
1556   ""
1557   "@
1558    #
1559    tbit.nz.and.orcm %0, %I0 = %2, 0
1560    and %0 = %2, %1"
1561   "reload_completed
1562    && GET_CODE (operands[0]) == REG && PR_REGNO_P (REGNO (operands[0]))
1563    && GET_CODE (operands[2]) == REG && PR_REGNO_P (REGNO (operands[2]))"
1564   [(cond_exec (eq (match_dup 2) (const_int 0))
1565      (set (match_dup 0) (and:BI (ne:BI (const_int 0) (const_int 0))
1566                                 (match_dup 0))))]
1567   ""
1568   [(set_attr "itanium_class" "unknown,tbit,ilog")])
1569
1570 (define_insn_and_split "*andcmbi3"
1571   [(set (match_operand:BI 0 "register_operand" "=c,c,r")
1572         (and:BI (not:BI (match_operand:BI 1 "register_operand" "c,r,r"))
1573                 (match_operand:BI 2 "register_operand" "0,0,r")))]
1574   ""
1575   "@
1576    #
1577    tbit.z.and.orcm %0, %I0 = %1, 0
1578    andcm %0 = %2, %1"
1579   "reload_completed
1580    && GET_CODE (operands[0]) == REG && PR_REGNO_P (REGNO (operands[0]))
1581    && GET_CODE (operands[1]) == REG && PR_REGNO_P (REGNO (operands[1]))"
1582   [(cond_exec (ne (match_dup 1) (const_int 0))
1583      (set (match_dup 0) (and:BI (ne:BI (const_int 0) (const_int 0))
1584                                 (match_dup 0))))]
1585   ""
1586   [(set_attr "itanium_class" "unknown,tbit,ilog")])
1587
1588 (define_insn_and_split "iorbi3"
1589   [(set (match_operand:BI 0 "register_operand" "=c,c,r")
1590         (ior:BI (match_operand:BI 1 "register_operand" "%0,0,r")
1591                 (match_operand:BI 2 "register_operand" "c,r,r")))]
1592   ""
1593   "@
1594    #
1595    tbit.nz.or.andcm %0, %I0 = %2, 0
1596    or %0 = %2, %1"
1597   "reload_completed
1598    && GET_CODE (operands[0]) == REG && PR_REGNO_P (REGNO (operands[0]))
1599    && GET_CODE (operands[2]) == REG && PR_REGNO_P (REGNO (operands[2]))"
1600   [(cond_exec (ne (match_dup 2) (const_int 0))
1601      (set (match_dup 0) (ior:BI (eq:BI (const_int 0) (const_int 0))
1602                                 (match_dup 0))))]
1603   ""
1604   [(set_attr "itanium_class" "unknown,tbit,ilog")])
1605
1606 (define_insn_and_split "*iorcmbi3"
1607   [(set (match_operand:BI 0 "register_operand" "=c,c")
1608         (ior:BI (not:BI (match_operand:BI 1 "register_operand" "c,r"))
1609                 (match_operand:BI 2 "register_operand" "0,0")))]
1610   ""
1611   "@
1612    #
1613    tbit.z.or.andcm %0, %I0 = %1, 0"
1614   "reload_completed
1615    && GET_CODE (operands[0]) == REG && PR_REGNO_P (REGNO (operands[0]))
1616    && GET_CODE (operands[1]) == REG && PR_REGNO_P (REGNO (operands[1]))"
1617   [(cond_exec (eq (match_dup 1) (const_int 0))
1618      (set (match_dup 0) (ior:BI (eq:BI (const_int 0) (const_int 0))
1619                                 (match_dup 0))))]
1620   ""
1621   [(set_attr "itanium_class" "unknown,tbit")])
1622
1623 (define_insn "one_cmplbi2"
1624   [(set (match_operand:BI 0 "register_operand" "=c,r,c,&c")
1625         (not:BI (match_operand:BI 1 "register_operand" "r,r,0,c")))
1626    (clobber (match_scratch:BI 2 "=X,X,c,X"))]
1627   ""
1628   "@
1629    tbit.z %0, %I0 = %1, 0
1630    xor %0 = 1, %1
1631    #
1632    #"
1633   [(set_attr "itanium_class" "tbit,ilog,unknown,unknown")])
1634
1635 (define_split
1636   [(set (match_operand:BI 0 "register_operand" "")
1637         (not:BI (match_operand:BI 1 "register_operand" "")))
1638    (clobber (match_scratch:BI 2 ""))]
1639   "reload_completed
1640    && GET_CODE (operands[0]) == REG && PR_REGNO_P (REGNO (operands[0]))
1641    && rtx_equal_p (operands[0], operands[1])"
1642   [(set (match_dup 4) (match_dup 3))
1643    (set (match_dup 0) (const_int 1))
1644    (cond_exec (ne (match_dup 2) (const_int 0))
1645      (set (match_dup 0) (const_int 0)))
1646    (set (match_dup 0) (unspec:BI [(match_dup 0)] UNSPEC_PRED_REL_MUTEX))]
1647   "operands[3] = gen_rtx_REG (CCImode, REGNO (operands[1]));
1648    operands[4] = gen_rtx_REG (CCImode, REGNO (operands[2]));")
1649
1650 (define_split
1651   [(set (match_operand:BI 0 "register_operand" "")
1652         (not:BI (match_operand:BI 1 "register_operand" "")))
1653    (clobber (match_scratch:BI 2 ""))]
1654   "reload_completed
1655    && GET_CODE (operands[0]) == REG && PR_REGNO_P (REGNO (operands[0]))
1656    && GET_CODE (operands[1]) == REG && PR_REGNO_P (REGNO (operands[1]))
1657    && ! rtx_equal_p (operands[0], operands[1])"
1658   [(cond_exec (ne (match_dup 1) (const_int 0))
1659      (set (match_dup 0) (const_int 0)))
1660    (cond_exec (eq (match_dup 1) (const_int 0))
1661      (set (match_dup 0) (const_int 1)))
1662    (set (match_dup 0) (unspec:BI [(match_dup 0)] UNSPEC_PRED_REL_MUTEX))]
1663   "")
1664
1665 (define_insn "*cmpsi_and_0"
1666   [(set (match_operand:BI 0 "register_operand" "=c")
1667         (and:BI (match_operator:BI 4 "predicate_operator"
1668                   [(match_operand:SI 2 "gr_reg_or_0_operand" "rO")
1669                    (match_operand:SI 3 "gr_reg_or_8bit_operand" "rK")])
1670                 (match_operand:BI 1 "register_operand" "0")))]
1671   ""
1672   "cmp4.%C4.and.orcm %0, %I0 = %3, %r2"
1673   [(set_attr "itanium_class" "icmp")])
1674
1675 (define_insn "*cmpsi_and_1"
1676   [(set (match_operand:BI 0 "register_operand" "=c")
1677         (and:BI (match_operator:BI 3 "signed_inequality_operator"
1678                   [(match_operand:SI 2 "gr_register_operand" "r")
1679                    (const_int 0)])
1680                 (match_operand:BI 1 "register_operand" "0")))]
1681   ""
1682   "cmp4.%C3.and.orcm %0, %I0 = r0, %2"
1683   [(set_attr "itanium_class" "icmp")])
1684
1685 (define_insn "*cmpsi_andnot_0"
1686   [(set (match_operand:BI 0 "register_operand" "=c")
1687         (and:BI (not:BI (match_operator:BI 4 "predicate_operator"
1688                          [(match_operand:SI 2 "gr_reg_or_0_operand" "rO")
1689                           (match_operand:SI 3 "gr_reg_or_8bit_operand" "rK")]))
1690                 (match_operand:BI 1 "register_operand" "0")))]
1691   ""
1692   "cmp4.%C4.or.andcm %I0, %0 = %3, %r2"
1693   [(set_attr "itanium_class" "icmp")])
1694
1695 (define_insn "*cmpsi_andnot_1"
1696   [(set (match_operand:BI 0 "register_operand" "=c")
1697         (and:BI (not:BI (match_operator:BI 3 "signed_inequality_operator"
1698                           [(match_operand:SI 2 "gr_register_operand" "r")
1699                            (const_int 0)]))
1700                 (match_operand:BI 1 "register_operand" "0")))]
1701   ""
1702   "cmp4.%C3.or.andcm %I0, %0 = r0, %2"
1703   [(set_attr "itanium_class" "icmp")])
1704
1705 (define_insn "*cmpdi_and_0"
1706   [(set (match_operand:BI 0 "register_operand" "=c")
1707         (and:BI (match_operator:BI 4 "predicate_operator"
1708                   [(match_operand:DI 2 "gr_register_operand" "r")
1709                    (match_operand:DI 3 "gr_reg_or_8bit_operand" "rK")])
1710                 (match_operand:BI 1 "register_operand" "0")))]
1711   ""
1712   "cmp.%C4.and.orcm %0, %I0 = %3, %2"
1713   [(set_attr "itanium_class" "icmp")])
1714
1715 (define_insn "*cmpdi_and_1"
1716   [(set (match_operand:BI 0 "register_operand" "=c")
1717         (and:BI (match_operator:BI 3 "signed_inequality_operator"
1718                   [(match_operand:DI 2 "gr_register_operand" "r")
1719                    (const_int 0)])
1720                 (match_operand:BI 1 "register_operand" "0")))]
1721   ""
1722   "cmp.%C3.and.orcm %0, %I0 = r0, %2"
1723   [(set_attr "itanium_class" "icmp")])
1724
1725 (define_insn "*cmpdi_andnot_0"
1726   [(set (match_operand:BI 0 "register_operand" "=c")
1727         (and:BI (not:BI (match_operator:BI 4 "predicate_operator"
1728                          [(match_operand:DI 2 "gr_register_operand" "r")
1729                           (match_operand:DI 3 "gr_reg_or_8bit_operand" "rK")]))
1730                 (match_operand:BI 1 "register_operand" "0")))]
1731   ""
1732   "cmp.%C4.or.andcm %I0, %0 = %3, %2"
1733   [(set_attr "itanium_class" "icmp")])
1734
1735 (define_insn "*cmpdi_andnot_1"
1736   [(set (match_operand:BI 0 "register_operand" "=c")
1737         (and:BI (not:BI (match_operator:BI 3 "signed_inequality_operator"
1738                           [(match_operand:DI 2 "gr_register_operand" "r")
1739                            (const_int 0)]))
1740                 (match_operand:BI 1 "register_operand" "0")))]
1741   ""
1742   "cmp.%C3.or.andcm %I0, %0 = r0, %2"
1743   [(set_attr "itanium_class" "icmp")])
1744
1745 (define_insn "*tbit_and_0"
1746   [(set (match_operand:BI 0 "register_operand" "=c")
1747         (and:BI (ne:BI (and:DI (match_operand:DI 1 "gr_register_operand" "r")
1748                                (const_int 1))
1749                        (const_int 0))
1750                 (match_operand:BI 2 "register_operand" "0")))]
1751   ""
1752   "tbit.nz.and.orcm %0, %I0 = %1, 0"
1753   [(set_attr "itanium_class" "tbit")])
1754
1755 (define_insn "*tbit_and_1"
1756   [(set (match_operand:BI 0 "register_operand" "=c")
1757         (and:BI (eq:BI (and:DI (match_operand:DI 1 "gr_register_operand" "r")
1758                                (const_int 1))
1759                        (const_int 0))
1760                 (match_operand:BI 2 "register_operand" "0")))]
1761   ""
1762   "tbit.z.and.orcm %0, %I0 = %1, 0"
1763   [(set_attr "itanium_class" "tbit")])
1764
1765 (define_insn "*tbit_and_2"
1766   [(set (match_operand:BI 0 "register_operand" "=c")
1767         (and:BI (ne:BI (zero_extract:DI
1768                          (match_operand:DI 1 "gr_register_operand" "r")
1769                          (const_int 1)
1770                          (match_operand:DI 2 "const_int_operand" "n"))
1771                        (const_int 0))
1772                 (match_operand:BI 3 "register_operand" "0")))]
1773   ""
1774   "tbit.nz.and.orcm %0, %I0 = %1, %2"
1775   [(set_attr "itanium_class" "tbit")])
1776
1777 (define_insn "*tbit_and_3"
1778   [(set (match_operand:BI 0 "register_operand" "=c")
1779         (and:BI (eq:BI (zero_extract:DI
1780                          (match_operand:DI 1 "gr_register_operand" "r")
1781                          (const_int 1)
1782                          (match_operand:DI 2 "const_int_operand" "n"))
1783                        (const_int 0))
1784                 (match_operand:BI 3 "register_operand" "0")))]
1785   ""
1786   "tbit.z.and.orcm %0, %I0 = %1, %2"
1787   [(set_attr "itanium_class" "tbit")])
1788
1789 (define_insn "*cmpsi_or_0"
1790   [(set (match_operand:BI 0 "register_operand" "=c")
1791         (ior:BI (match_operator:BI 4 "predicate_operator"
1792                   [(match_operand:SI 2 "gr_reg_or_0_operand" "rO")
1793                    (match_operand:SI 3 "gr_reg_or_8bit_operand" "rK")])
1794                 (match_operand:BI 1 "register_operand" "0")))]
1795   ""
1796   "cmp4.%C4.or.andcm %0, %I0 = %3, %r2"
1797   [(set_attr "itanium_class" "icmp")])
1798
1799 (define_insn "*cmpsi_or_1"
1800   [(set (match_operand:BI 0 "register_operand" "=c")
1801         (ior:BI (match_operator:BI 3 "signed_inequality_operator"
1802                   [(match_operand:SI 2 "gr_register_operand" "r")
1803                    (const_int 0)])
1804                 (match_operand:BI 1 "register_operand" "0")))]
1805   ""
1806   "cmp4.%C3.or.andcm %0, %I0 = r0, %2"
1807   [(set_attr "itanium_class" "icmp")])
1808
1809 (define_insn "*cmpsi_orcm_0"
1810   [(set (match_operand:BI 0 "register_operand" "=c")
1811         (ior:BI (not:BI (match_operator:BI 4 "predicate_operator"
1812                          [(match_operand:SI 2 "gr_reg_or_0_operand" "rO")
1813                           (match_operand:SI 3 "gr_reg_or_8bit_operand" "rK")]))
1814                 (match_operand:BI 1 "register_operand" "0")))]
1815   ""
1816   "cmp4.%C4.and.orcm %I0, %0 = %3, %r2"
1817   [(set_attr "itanium_class" "icmp")])
1818
1819 (define_insn "*cmpsi_orcm_1"
1820   [(set (match_operand:BI 0 "register_operand" "=c")
1821         (ior:BI (not:BI (match_operator:BI 3 "signed_inequality_operator"
1822                           [(match_operand:SI 2 "gr_register_operand" "r")
1823                            (const_int 0)]))
1824                 (match_operand:BI 1 "register_operand" "0")))]
1825   ""
1826   "cmp4.%C3.and.orcm %I0, %0 = r0, %2"
1827   [(set_attr "itanium_class" "icmp")])
1828
1829 (define_insn "*cmpdi_or_0"
1830   [(set (match_operand:BI 0 "register_operand" "=c")
1831         (ior:BI (match_operator:BI 4 "predicate_operator"
1832                   [(match_operand:DI 2 "gr_register_operand" "r")
1833                    (match_operand:DI 3 "gr_reg_or_8bit_operand" "rK")])
1834                 (match_operand:BI 1 "register_operand" "0")))]
1835   ""
1836   "cmp.%C4.or.andcm %0, %I0 = %3, %2"
1837   [(set_attr "itanium_class" "icmp")])
1838
1839 (define_insn "*cmpdi_or_1"
1840   [(set (match_operand:BI 0 "register_operand" "=c")
1841         (ior:BI (match_operator:BI 3 "signed_inequality_operator"
1842                   [(match_operand:DI 2 "gr_register_operand" "r")
1843                    (const_int 0)])
1844                 (match_operand:BI 1 "register_operand" "0")))]
1845   ""
1846   "cmp.%C3.or.andcm %0, %I0 = r0, %2"
1847   [(set_attr "itanium_class" "icmp")])
1848
1849 (define_insn "*cmpdi_orcm_0"
1850   [(set (match_operand:BI 0 "register_operand" "=c")
1851         (ior:BI (not:BI (match_operator:BI 4 "predicate_operator"
1852                          [(match_operand:DI 2 "gr_register_operand" "r")
1853                           (match_operand:DI 3 "gr_reg_or_8bit_operand" "rK")]))
1854                 (match_operand:BI 1 "register_operand" "0")))]
1855   ""
1856   "cmp.%C4.and.orcm %I0, %0 = %3, %2"
1857   [(set_attr "itanium_class" "icmp")])
1858
1859 (define_insn "*cmpdi_orcm_1"
1860   [(set (match_operand:BI 0 "register_operand" "=c")
1861         (ior:BI (not:BI (match_operator:BI 3 "signed_inequality_operator"
1862                           [(match_operand:DI 2 "gr_register_operand" "r")
1863                            (const_int 0)]))
1864                 (match_operand:BI 1 "register_operand" "0")))]
1865   ""
1866   "cmp.%C3.and.orcm %I0, %0 = r0, %2"
1867   [(set_attr "itanium_class" "icmp")])
1868
1869 (define_insn "*tbit_or_0"
1870   [(set (match_operand:BI 0 "register_operand" "=c")
1871         (ior:BI (ne:BI (and:DI (match_operand:DI 1 "gr_register_operand" "r")
1872                                (const_int 1))
1873                        (const_int 0))
1874                 (match_operand:BI 2 "register_operand" "0")))]
1875   ""
1876   "tbit.nz.or.andcm %0, %I0 = %1, 0"
1877   [(set_attr "itanium_class" "tbit")])
1878
1879 (define_insn "*tbit_or_1"
1880   [(set (match_operand:BI 0 "register_operand" "=c")
1881         (ior:BI (eq:BI (and:DI (match_operand:DI 1 "gr_register_operand" "r")
1882                                (const_int 1))
1883                        (const_int 0))
1884                 (match_operand:BI 2 "register_operand" "0")))]
1885   ""
1886   "tbit.z.or.andcm %0, %I0 = %1, 0"
1887   [(set_attr "itanium_class" "tbit")])
1888
1889 (define_insn "*tbit_or_2"
1890   [(set (match_operand:BI 0 "register_operand" "=c")
1891         (ior:BI (ne:BI (zero_extract:DI
1892                          (match_operand:DI 1 "gr_register_operand" "r")
1893                          (const_int 1)
1894                          (match_operand:DI 2 "const_int_operand" "n"))
1895                        (const_int 0))
1896                 (match_operand:BI 3 "register_operand" "0")))]
1897   ""
1898   "tbit.nz.or.andcm %0, %I0 = %1, %2"
1899   [(set_attr "itanium_class" "tbit")])
1900
1901 (define_insn "*tbit_or_3"
1902   [(set (match_operand:BI 0 "register_operand" "=c")
1903         (ior:BI (eq:BI (zero_extract:DI
1904                          (match_operand:DI 1 "gr_register_operand" "r")
1905                          (const_int 1)
1906                          (match_operand:DI 2 "const_int_operand" "n"))
1907                        (const_int 0))
1908                 (match_operand:BI 3 "register_operand" "0")))]
1909   ""
1910   "tbit.z.or.andcm %0, %I0 = %1, %2"
1911   [(set_attr "itanium_class" "tbit")])
1912
1913 ;; Transform test of and/or of setcc into parallel comparisons.
1914
1915 (define_split
1916   [(set (match_operand:BI 0 "register_operand" "")
1917         (ne:BI (and:DI (ne:DI (match_operand:BI 2 "register_operand" "")
1918                               (const_int 0))
1919                        (match_operand:DI 3 "register_operand" ""))
1920                (const_int 0)))]
1921   ""
1922   [(set (match_dup 0)
1923         (and:BI (ne:BI (and:DI (match_dup 3) (const_int 1)) (const_int 0))
1924                 (match_dup 2)))]
1925   "")
1926
1927 (define_split
1928   [(set (match_operand:BI 0 "register_operand" "")
1929         (eq:BI (and:DI (ne:DI (match_operand:BI 2 "register_operand" "")
1930                               (const_int 0))
1931                        (match_operand:DI 3 "register_operand" ""))
1932                (const_int 0)))]
1933   ""
1934   [(set (match_dup 0)
1935         (and:BI (ne:BI (and:DI (match_dup 3) (const_int 1)) (const_int 0))
1936                 (match_dup 2)))
1937    (parallel [(set (match_dup 0) (not:BI (match_dup 0)))
1938               (clobber (scratch))])]
1939   "")
1940
1941 (define_split
1942   [(set (match_operand:BI 0 "register_operand" "")
1943         (ne:BI (ior:DI (ne:DI (match_operand:BI 2 "register_operand" "")
1944                               (const_int 0))
1945                        (match_operand:DI 3 "register_operand" ""))
1946                (const_int 0)))]
1947   ""
1948   [(set (match_dup 0) 
1949         (ior:BI (ne:BI (match_dup 3) (const_int 0))
1950                 (match_dup 2)))]
1951   "")
1952
1953 (define_split
1954   [(set (match_operand:BI 0 "register_operand" "")
1955         (eq:BI (ior:DI (ne:DI (match_operand:BI 2 "register_operand" "")
1956                               (const_int 0))
1957                        (match_operand:DI 3 "register_operand" ""))
1958                (const_int 0)))]
1959   ""
1960   [(set (match_dup 0) 
1961         (ior:BI (ne:BI (match_dup 3) (const_int 0))
1962                 (match_dup 2)))
1963    (parallel [(set (match_dup 0) (not:BI (match_dup 0)))
1964               (clobber (scratch))])]
1965   "")
1966
1967 ;; ??? Incredibly hackish.  Either need four proper patterns with all
1968 ;; the alternatives, or rely on sched1 to split the insn and hope that
1969 ;; nothing bad happens to the comparisons in the meantime.
1970 ;;
1971 ;; Alternately, adjust combine to allow 2->2 and 3->3 splits, assuming
1972 ;; that we're doing height reduction.
1973 ;
1974 ;(define_insn_and_split ""
1975 ;  [(set (match_operand:BI 0 "register_operand" "=c")
1976 ;       (and:BI (and:BI (match_operator:BI 1 "comparison_operator"
1977 ;                         [(match_operand 2 "" "")
1978 ;                          (match_operand 3 "" "")])
1979 ;                       (match_operator:BI 4 "comparison_operator"
1980 ;                         [(match_operand 5 "" "")
1981 ;                          (match_operand 6 "" "")]))
1982 ;               (match_dup 0)))]
1983 ;  "flag_schedule_insns"
1984 ;  "#"
1985 ;  ""
1986 ;  [(set (match_dup 0) (and:BI (match_dup 1) (match_dup 0)))
1987 ;   (set (match_dup 0) (and:BI (match_dup 4) (match_dup 0)))]
1988 ;  "")
1989 ;
1990 ;(define_insn_and_split ""
1991 ;  [(set (match_operand:BI 0 "register_operand" "=c")
1992 ;       (ior:BI (ior:BI (match_operator:BI 1 "comparison_operator"
1993 ;                         [(match_operand 2 "" "")
1994 ;                          (match_operand 3 "" "")])
1995 ;                       (match_operator:BI 4 "comparison_operator"
1996 ;                         [(match_operand 5 "" "")
1997 ;                          (match_operand 6 "" "")]))
1998 ;               (match_dup 0)))]
1999 ;  "flag_schedule_insns"
2000 ;  "#"
2001 ;  ""
2002 ;  [(set (match_dup 0) (ior:BI (match_dup 1) (match_dup 0)))
2003 ;   (set (match_dup 0) (ior:BI (match_dup 4) (match_dup 0)))]
2004 ;  "")
2005 ;
2006 ;(define_split
2007 ;  [(set (match_operand:BI 0 "register_operand" "")
2008 ;       (and:BI (and:BI (match_operator:BI 1 "comparison_operator"
2009 ;                         [(match_operand 2 "" "")
2010 ;                          (match_operand 3 "" "")])
2011 ;                       (match_operand:BI 7 "register_operand" ""))
2012 ;               (and:BI (match_operator:BI 4 "comparison_operator"
2013 ;                         [(match_operand 5 "" "")
2014 ;                          (match_operand 6 "" "")])
2015 ;                       (match_operand:BI 8 "register_operand" ""))))]
2016 ;  ""
2017 ;  [(set (match_dup 0) (and:BI (match_dup 7) (match_dup 8)))
2018 ;   (set (match_dup 0) (and:BI (and:BI (match_dup 1) (match_dup 4))
2019 ;                             (match_dup 0)))]
2020 ;  "")
2021 ;
2022 ;(define_split
2023 ;  [(set (match_operand:BI 0 "register_operand" "")
2024 ;       (ior:BI (ior:BI (match_operator:BI 1 "comparison_operator"
2025 ;                         [(match_operand 2 "" "")
2026 ;                          (match_operand 3 "" "")])
2027 ;                       (match_operand:BI 7 "register_operand" ""))
2028 ;               (ior:BI (match_operator:BI 4 "comparison_operator"
2029 ;                         [(match_operand 5 "" "")
2030 ;                          (match_operand 6 "" "")])
2031 ;                       (match_operand:BI 8 "register_operand" ""))))]
2032 ;  ""
2033 ;  [(set (match_dup 0) (ior:BI (match_dup 7) (match_dup 8)))
2034 ;   (set (match_dup 0) (ior:BI (ior:BI (match_dup 1) (match_dup 4))
2035 ;                             (match_dup 0)))]
2036 ;  "")
2037
2038 ;; Try harder to avoid predicate copies by duplicating compares.
2039 ;; Note that we'll have already split the predicate copy, which
2040 ;; is kind of a pain, but oh well.
2041
2042 (define_peephole2
2043   [(set (match_operand:BI 0 "register_operand" "")
2044         (match_operand:BI 1 "comparison_operator" ""))
2045    (set (match_operand:CCI 2 "register_operand" "")
2046         (match_operand:CCI 3 "register_operand" ""))
2047    (set (match_operand:CCI 4 "register_operand" "")
2048         (match_operand:CCI 5 "register_operand" ""))
2049    (set (match_operand:BI 6 "register_operand" "")
2050         (unspec:BI [(match_dup 6)] UNSPEC_PRED_REL_MUTEX))]
2051   "REGNO (operands[3]) == REGNO (operands[0])
2052    && REGNO (operands[4]) == REGNO (operands[0]) + 1
2053    && REGNO (operands[4]) == REGNO (operands[2]) + 1
2054    && REGNO (operands[6]) == REGNO (operands[2])"
2055   [(set (match_dup 0) (match_dup 1))
2056    (set (match_dup 6) (match_dup 7))]
2057   "operands[7] = copy_rtx (operands[1]);")
2058 \f
2059 ;; ::::::::::::::::::::
2060 ;; ::
2061 ;; :: 16 bit Integer arithmetic
2062 ;; ::
2063 ;; ::::::::::::::::::::
2064
2065 (define_insn "mulhi3"
2066   [(set (match_operand:HI 0 "gr_register_operand" "=r")
2067         (mult:HI (match_operand:HI 1 "gr_register_operand" "r")
2068                  (match_operand:HI 2 "gr_register_operand" "r")))]
2069   ""
2070   "pmpy2.r %0 = %1, %2"
2071   [(set_attr "itanium_class" "mmmul")])
2072
2073 \f
2074 ;; ::::::::::::::::::::
2075 ;; ::
2076 ;; :: 32 bit Integer arithmetic
2077 ;; ::
2078 ;; ::::::::::::::::::::
2079
2080 (define_insn "addsi3"
2081   [(set (match_operand:SI 0 "gr_register_operand" "=r,r,r")
2082         (plus:SI (match_operand:SI 1 "gr_register_operand" "%r,r,a")
2083                  (match_operand:SI 2 "gr_reg_or_22bit_operand" "r,I,J")))]
2084   ""
2085   "@
2086    add %0 = %1, %2
2087    adds %0 = %2, %1
2088    addl %0 = %2, %1"
2089   [(set_attr "itanium_class" "ialu")])
2090
2091 (define_insn "*addsi3_plus1"
2092   [(set (match_operand:SI 0 "gr_register_operand" "=r")
2093         (plus:SI (plus:SI (match_operand:SI 1 "gr_register_operand" "r")
2094                           (match_operand:SI 2 "gr_register_operand" "r"))
2095                  (const_int 1)))]
2096   ""
2097   "add %0 = %1, %2, 1"
2098   [(set_attr "itanium_class" "ialu")])
2099
2100 (define_insn "*addsi3_plus1_alt"
2101   [(set (match_operand:SI 0 "gr_register_operand" "=r")
2102         (plus:SI (mult:SI (match_operand:SI 1 "gr_register_operand" "r")
2103                           (const_int 2))
2104                  (const_int 1)))]
2105   ""
2106   "add %0 = %1, %1, 1"
2107   [(set_attr "itanium_class" "ialu")])
2108
2109 (define_insn "*addsi3_shladd"
2110   [(set (match_operand:SI 0 "gr_register_operand" "=r")
2111         (plus:SI (mult:SI (match_operand:SI 1 "gr_register_operand" "r")
2112                           (match_operand:SI 2 "shladd_operand" "n"))
2113                  (match_operand:SI 3 "gr_register_operand" "r")))]
2114   ""
2115   "shladd %0 = %1, %S2, %3"
2116   [(set_attr "itanium_class" "ialu")])
2117
2118 (define_insn "subsi3"
2119   [(set (match_operand:SI 0 "gr_register_operand" "=r")
2120         (minus:SI (match_operand:SI 1 "gr_reg_or_8bit_operand" "rK")
2121                   (match_operand:SI 2 "gr_register_operand" "r")))]
2122   ""
2123   "sub %0 = %1, %2"
2124   [(set_attr "itanium_class" "ialu")])
2125
2126 (define_insn "*subsi3_minus1"
2127   [(set (match_operand:SI 0 "gr_register_operand" "=r")
2128         (plus:SI (not:SI (match_operand:SI 1 "gr_register_operand" "r"))
2129                  (match_operand:SI 2 "gr_register_operand" "r")))]
2130   ""
2131   "sub %0 = %2, %1, 1"
2132   [(set_attr "itanium_class" "ialu")])
2133
2134 ;; ??? Could add maddsi3 patterns patterned after the madddi3 patterns.
2135
2136 (define_insn "mulsi3"
2137   [(set (match_operand:SI 0 "fr_register_operand" "=f")
2138         (mult:SI (match_operand:SI 1 "grfr_register_operand" "f")
2139                  (match_operand:SI 2 "grfr_register_operand" "f")))]
2140   ""
2141   "xmpy.l %0 = %1, %2"
2142   [(set_attr "itanium_class" "xmpy")])
2143
2144 (define_insn "maddsi4"
2145   [(set (match_operand:SI 0 "fr_register_operand" "=f")
2146         (plus:SI (mult:SI (match_operand:SI 1 "grfr_register_operand" "f")
2147                           (match_operand:SI 2 "grfr_register_operand" "f"))
2148                  (match_operand:SI 3 "grfr_register_operand" "f")))]
2149   ""
2150   "xma.l %0 = %1, %2, %3"
2151   [(set_attr "itanium_class" "xmpy")])
2152
2153 (define_insn "negsi2"
2154   [(set (match_operand:SI 0 "gr_register_operand" "=r")
2155         (neg:SI (match_operand:SI 1 "gr_register_operand" "r")))]
2156   ""
2157   "sub %0 = r0, %1"
2158   [(set_attr "itanium_class" "ialu")])
2159
2160 (define_expand "abssi2"
2161   [(set (match_dup 2)
2162         (ge:BI (match_operand:SI 1 "gr_register_operand" "") (const_int 0)))
2163    (set (match_operand:SI 0 "gr_register_operand" "")
2164         (if_then_else:SI (eq (match_dup 2) (const_int 0))
2165                          (neg:SI (match_dup 1))
2166                          (match_dup 1)))]
2167   ""
2168   { operands[2] = gen_reg_rtx (BImode); })
2169
2170 (define_expand "sminsi3"
2171   [(set (match_dup 3)
2172         (ge:BI (match_operand:SI 1 "gr_register_operand" "")
2173                (match_operand:SI 2 "gr_register_operand" "")))
2174    (set (match_operand:SI 0 "gr_register_operand" "")
2175         (if_then_else:SI (ne (match_dup 3) (const_int 0))
2176                          (match_dup 2) (match_dup 1)))]
2177   ""
2178   { operands[3] = gen_reg_rtx (BImode); })
2179
2180 (define_expand "smaxsi3"
2181   [(set (match_dup 3)
2182         (ge:BI (match_operand:SI 1 "gr_register_operand" "")
2183                (match_operand:SI 2 "gr_register_operand" "")))
2184    (set (match_operand:SI 0 "gr_register_operand" "")
2185         (if_then_else:SI (ne (match_dup 3) (const_int 0))
2186                          (match_dup 1) (match_dup 2)))]
2187   ""
2188   { operands[3] = gen_reg_rtx (BImode); })
2189
2190 (define_expand "uminsi3"
2191   [(set (match_dup 3)
2192         (geu:BI (match_operand:SI 1 "gr_register_operand" "")
2193                 (match_operand:SI 2 "gr_register_operand" "")))
2194    (set (match_operand:SI 0 "gr_register_operand" "")
2195         (if_then_else:SI (ne (match_dup 3) (const_int 0))
2196                          (match_dup 2) (match_dup 1)))]
2197   ""
2198   { operands[3] = gen_reg_rtx (BImode); })
2199
2200 (define_expand "umaxsi3"
2201   [(set (match_dup 3)
2202         (geu:BI (match_operand:SI 1 "gr_register_operand" "")
2203                 (match_operand:SI 2 "gr_register_operand" "")))
2204    (set (match_operand:SI 0 "gr_register_operand" "")
2205         (if_then_else:SI (ne (match_dup 3) (const_int 0))
2206                          (match_dup 1) (match_dup 2)))]
2207   ""
2208   { operands[3] = gen_reg_rtx (BImode); })
2209
2210 (define_expand "divsi3"
2211   [(set (match_operand:SI 0 "register_operand" "")
2212         (div:SI (match_operand:SI 1 "general_operand" "")
2213                 (match_operand:SI 2 "general_operand" "")))]
2214   "TARGET_INLINE_INT_DIV"
2215 {
2216   rtx op1_xf, op2_xf, op0_xf, op0_di, twon34, twon34_exp;
2217
2218   op0_xf = gen_reg_rtx (XFmode);
2219   op0_di = gen_reg_rtx (DImode);
2220
2221   if (CONSTANT_P (operands[1]))
2222     operands[1] = force_reg (SImode, operands[1]);
2223   op1_xf = gen_reg_rtx (XFmode);
2224   expand_float (op1_xf, operands[1], 0);
2225
2226   if (CONSTANT_P (operands[2]))
2227     operands[2] = force_reg (SImode, operands[2]);
2228   op2_xf = gen_reg_rtx (XFmode);
2229   expand_float (op2_xf, operands[2], 0);
2230
2231   /* 2^-34 */
2232   twon34_exp = gen_reg_rtx (DImode);
2233   emit_move_insn (twon34_exp, GEN_INT (65501));
2234   twon34 = gen_reg_rtx (XFmode);
2235   emit_insn (gen_setf_exp_xf (twon34, twon34_exp));
2236
2237   emit_insn (gen_divsi3_internal (op0_xf, op1_xf, op2_xf, twon34));
2238
2239   emit_insn (gen_fix_truncxfdi2_alts (op0_di, op0_xf, const1_rtx));
2240   emit_move_insn (operands[0], gen_lowpart (SImode, op0_di));
2241   DONE;
2242 })
2243
2244 (define_expand "modsi3"
2245   [(set (match_operand:SI 0 "register_operand" "")
2246         (mod:SI (match_operand:SI 1 "general_operand" "")
2247                 (match_operand:SI 2 "general_operand" "")))]
2248   "TARGET_INLINE_INT_DIV"
2249 {
2250   rtx op2_neg, op1_di, div;
2251
2252   div = gen_reg_rtx (SImode);
2253   emit_insn (gen_divsi3 (div, operands[1], operands[2]));
2254
2255   op2_neg = expand_unop (SImode, neg_optab, operands[2], NULL_RTX, 0);
2256
2257   /* This is a trick to get us to reuse the value that we're sure to
2258      have already copied to the FP regs.  */
2259   op1_di = gen_reg_rtx (DImode);
2260   convert_move (op1_di, operands[1], 0);
2261
2262   emit_insn (gen_maddsi4 (operands[0], div, op2_neg,
2263                           gen_lowpart (SImode, op1_di)));
2264   DONE;
2265 })
2266
2267 (define_expand "udivsi3"
2268   [(set (match_operand:SI 0 "register_operand" "")
2269         (udiv:SI (match_operand:SI 1 "general_operand" "")
2270                  (match_operand:SI 2 "general_operand" "")))]
2271   "TARGET_INLINE_INT_DIV"
2272 {
2273   rtx op1_xf, op2_xf, op0_xf, op0_di, twon34, twon34_exp;
2274
2275   op0_xf = gen_reg_rtx (XFmode);
2276   op0_di = gen_reg_rtx (DImode);
2277
2278   if (CONSTANT_P (operands[1]))
2279     operands[1] = force_reg (SImode, operands[1]);
2280   op1_xf = gen_reg_rtx (XFmode);
2281   expand_float (op1_xf, operands[1], 1);
2282
2283   if (CONSTANT_P (operands[2]))
2284     operands[2] = force_reg (SImode, operands[2]);
2285   op2_xf = gen_reg_rtx (XFmode);
2286   expand_float (op2_xf, operands[2], 1);
2287
2288   /* 2^-34 */
2289   twon34_exp = gen_reg_rtx (DImode);
2290   emit_move_insn (twon34_exp, GEN_INT (65501));
2291   twon34 = gen_reg_rtx (XFmode);
2292   emit_insn (gen_setf_exp_xf (twon34, twon34_exp));
2293
2294   emit_insn (gen_divsi3_internal (op0_xf, op1_xf, op2_xf, twon34));
2295
2296   emit_insn (gen_fixuns_truncxfdi2_alts (op0_di, op0_xf, const1_rtx));
2297   emit_move_insn (operands[0], gen_lowpart (SImode, op0_di));
2298   DONE;
2299 })
2300
2301 (define_expand "umodsi3"
2302   [(set (match_operand:SI 0 "register_operand" "")
2303         (umod:SI (match_operand:SI 1 "general_operand" "")
2304                  (match_operand:SI 2 "general_operand" "")))]
2305   "TARGET_INLINE_INT_DIV"
2306 {
2307   rtx op2_neg, op1_di, div;
2308
2309   div = gen_reg_rtx (SImode);
2310   emit_insn (gen_udivsi3 (div, operands[1], operands[2]));
2311
2312   op2_neg = expand_unop (SImode, neg_optab, operands[2], NULL_RTX, 0);
2313
2314   /* This is a trick to get us to reuse the value that we're sure to
2315      have already copied to the FP regs.  */
2316   op1_di = gen_reg_rtx (DImode);
2317   convert_move (op1_di, operands[1], 1);
2318
2319   emit_insn (gen_maddsi4 (operands[0], div, op2_neg,
2320                           gen_lowpart (SImode, op1_di)));
2321   DONE;
2322 })
2323
2324 (define_insn_and_split "divsi3_internal"
2325   [(set (match_operand:XF 0 "fr_register_operand" "=&f")
2326         (float:XF (div:SI (match_operand:XF 1 "fr_register_operand" "f")
2327                           (match_operand:XF 2 "fr_register_operand" "f"))))
2328    (clobber (match_scratch:XF 4 "=&f"))
2329    (clobber (match_scratch:XF 5 "=&f"))
2330    (clobber (match_scratch:BI 6 "=c"))
2331    (use (match_operand:XF 3 "fr_register_operand" "f"))]
2332   "TARGET_INLINE_INT_DIV"
2333   "#"
2334   "&& reload_completed"
2335   [(parallel [(set (match_dup 0) (div:XF (const_int 1) (match_dup 2)))
2336               (set (match_dup 6) (unspec:BI [(match_dup 1) (match_dup 2)]
2337                                             UNSPEC_FR_RECIP_APPROX))
2338               (use (const_int 1))])
2339    (cond_exec (ne (match_dup 6) (const_int 0))
2340      (parallel [(set (match_dup 4) (mult:XF (match_dup 1) (match_dup 0)))
2341                 (use (const_int 1))]))
2342    (cond_exec (ne (match_dup 6) (const_int 0))
2343      (parallel [(set (match_dup 5)
2344                      (minus:XF (match_dup 7)
2345                                (mult:XF (match_dup 2) (match_dup 0))))
2346                 (use (const_int 1))]))
2347    (cond_exec (ne (match_dup 6) (const_int 0))
2348      (parallel [(set (match_dup 4)
2349                      (plus:XF (mult:XF (match_dup 5) (match_dup 4))
2350                               (match_dup 4)))
2351                 (use (const_int 1))]))
2352    (cond_exec (ne (match_dup 6) (const_int 0))
2353      (parallel [(set (match_dup 5)
2354                      (plus:XF (mult:XF (match_dup 5) (match_dup 5))
2355                               (match_dup 3)))
2356                 (use (const_int 1))]))
2357    (cond_exec (ne (match_dup 6) (const_int 0))
2358      (parallel [(set (match_dup 0)
2359                      (plus:XF (mult:XF (match_dup 5) (match_dup 4))
2360                               (match_dup 4)))
2361                 (use (const_int 1))]))
2362   ] 
2363   "operands[7] = CONST1_RTX (XFmode);"
2364   [(set_attr "predicable" "no")])
2365 \f
2366 ;; ::::::::::::::::::::
2367 ;; ::
2368 ;; :: 64 bit Integer arithmetic
2369 ;; ::
2370 ;; ::::::::::::::::::::
2371
2372 (define_insn "adddi3"
2373   [(set (match_operand:DI 0 "gr_register_operand" "=r,r,r")
2374         (plus:DI (match_operand:DI 1 "gr_register_operand" "%r,r,a")
2375                  (match_operand:DI 2 "gr_reg_or_22bit_operand" "r,I,J")))]
2376   ""
2377   "@
2378    add %0 = %1, %2
2379    adds %0 = %2, %1
2380    addl %0 = %2, %1"
2381   [(set_attr "itanium_class" "ialu")])
2382
2383 (define_insn "*adddi3_plus1"
2384   [(set (match_operand:DI 0 "gr_register_operand" "=r")
2385         (plus:DI (plus:DI (match_operand:DI 1 "gr_register_operand" "r")
2386                           (match_operand:DI 2 "gr_register_operand" "r"))
2387                  (const_int 1)))]
2388   ""
2389   "add %0 = %1, %2, 1"
2390   [(set_attr "itanium_class" "ialu")])
2391
2392 ;; This has some of the same problems as shladd.  We let the shladd
2393 ;; eliminator hack handle it, which results in the 1 being forced into
2394 ;; a register, but not more ugliness here.
2395 (define_insn "*adddi3_plus1_alt"
2396   [(set (match_operand:DI 0 "gr_register_operand" "=r")
2397         (plus:DI (mult:DI (match_operand:DI 1 "gr_register_operand" "r")
2398                           (const_int 2))
2399                  (const_int 1)))]
2400   ""
2401   "add %0 = %1, %1, 1"
2402   [(set_attr "itanium_class" "ialu")])
2403
2404 (define_insn "subdi3"
2405   [(set (match_operand:DI 0 "gr_register_operand" "=r")
2406         (minus:DI (match_operand:DI 1 "gr_reg_or_8bit_operand" "rK")
2407                   (match_operand:DI 2 "gr_register_operand" "r")))]
2408   ""
2409   "sub %0 = %1, %2"
2410   [(set_attr "itanium_class" "ialu")])
2411
2412 (define_insn "*subdi3_minus1"
2413   [(set (match_operand:DI 0 "gr_register_operand" "=r")
2414         (plus:DI (not:DI (match_operand:DI 1 "gr_register_operand" "r"))
2415                  (match_operand:DI 2 "gr_register_operand" "r")))]
2416   ""
2417   "sub %0 = %2, %1, 1"
2418   [(set_attr "itanium_class" "ialu")])
2419
2420 ;; ??? Use grfr instead of fr because of virtual register elimination
2421 ;; and silly test cases multiplying by the frame pointer.
2422 (define_insn "muldi3"
2423   [(set (match_operand:DI 0 "fr_register_operand" "=f")
2424         (mult:DI (match_operand:DI 1 "grfr_register_operand" "f")
2425                  (match_operand:DI 2 "grfr_register_operand" "f")))]
2426   ""
2427   "xmpy.l %0 = %1, %2"
2428   [(set_attr "itanium_class" "xmpy")])
2429
2430 ;; ??? If operand 3 is an eliminable reg, then register elimination causes the
2431 ;; same problem that we have with shladd below.  Unfortunately, this case is
2432 ;; much harder to fix because the multiply puts the result in an FP register,
2433 ;; but the add needs inputs from a general register.  We add a spurious clobber
2434 ;; here so that it will be present just in case register elimination gives us
2435 ;; the funny result.
2436
2437 ;; ??? Maybe validate_changes should try adding match_scratch clobbers?
2438
2439 ;; ??? Maybe we should change how adds are canonicalized.
2440
2441 (define_insn "madddi4"
2442   [(set (match_operand:DI 0 "fr_register_operand" "=f")
2443         (plus:DI (mult:DI (match_operand:DI 1 "grfr_register_operand" "f")
2444                           (match_operand:DI 2 "grfr_register_operand" "f"))
2445                  (match_operand:DI 3 "grfr_register_operand" "f")))
2446    (clobber (match_scratch:DI 4 "=X"))]
2447   ""
2448   "xma.l %0 = %1, %2, %3"
2449   [(set_attr "itanium_class" "xmpy")])
2450
2451 ;; This can be created by register elimination if operand3 of shladd is an
2452 ;; eliminable register or has reg_equiv_constant set.
2453
2454 ;; We have to use nonmemory_operand for operand 4, to ensure that the
2455 ;; validate_changes call inside eliminate_regs will always succeed.  If it
2456 ;; doesn't succeed, then this remain a madddi4 pattern, and will be reloaded
2457 ;; incorrectly.
2458
2459 (define_insn "*madddi4_elim"
2460   [(set (match_operand:DI 0 "register_operand" "=&r")
2461         (plus:DI (plus:DI (mult:DI (match_operand:DI 1 "register_operand" "f")
2462                                    (match_operand:DI 2 "register_operand" "f"))
2463                           (match_operand:DI 3 "register_operand" "f"))
2464                  (match_operand:DI 4 "nonmemory_operand" "rI")))
2465    (clobber (match_scratch:DI 5 "=f"))]
2466   "reload_in_progress"
2467   "#"
2468   [(set_attr "itanium_class" "unknown")])
2469
2470 (define_split
2471   [(set (match_operand:DI 0 "register_operand" "")
2472         (plus:DI (plus:DI (mult:DI (match_operand:DI 1 "register_operand" "")
2473                                    (match_operand:DI 2 "register_operand" ""))
2474                           (match_operand:DI 3 "register_operand" ""))
2475                  (match_operand:DI 4 "gr_reg_or_14bit_operand" "")))
2476    (clobber (match_scratch:DI 5 ""))]
2477   "reload_completed"
2478   [(parallel [(set (match_dup 5) (plus:DI (mult:DI (match_dup 1) (match_dup 2))
2479                                           (match_dup 3)))
2480               (clobber (match_dup 0))])
2481    (set (match_dup 0) (match_dup 5))
2482    (set (match_dup 0) (plus:DI (match_dup 0) (match_dup 4)))]
2483   "")
2484
2485 ;; ??? There are highpart multiply and add instructions, but we have no way
2486 ;; to generate them.
2487
2488 (define_insn "smuldi3_highpart"
2489   [(set (match_operand:DI 0 "fr_register_operand" "=f")
2490         (truncate:DI
2491          (lshiftrt:TI
2492           (mult:TI (sign_extend:TI
2493                      (match_operand:DI 1 "fr_register_operand" "f"))
2494                    (sign_extend:TI
2495                      (match_operand:DI 2 "fr_register_operand" "f")))
2496           (const_int 64))))]
2497   ""
2498   "xmpy.h %0 = %1, %2"
2499   [(set_attr "itanium_class" "xmpy")])
2500
2501 (define_insn "umuldi3_highpart"
2502   [(set (match_operand:DI 0 "fr_register_operand" "=f")
2503         (truncate:DI
2504          (lshiftrt:TI
2505           (mult:TI (zero_extend:TI
2506                      (match_operand:DI 1 "fr_register_operand" "f"))
2507                    (zero_extend:TI
2508                      (match_operand:DI 2 "fr_register_operand" "f")))
2509           (const_int 64))))]
2510   ""
2511   "xmpy.hu %0 = %1, %2"
2512   [(set_attr "itanium_class" "xmpy")])
2513
2514 (define_insn "negdi2"
2515   [(set (match_operand:DI 0 "gr_register_operand" "=r")
2516         (neg:DI (match_operand:DI 1 "gr_register_operand" "r")))]
2517   ""
2518   "sub %0 = r0, %1"
2519   [(set_attr "itanium_class" "ialu")])
2520
2521 (define_expand "absdi2"
2522   [(set (match_dup 2)
2523         (ge:BI (match_operand:DI 1 "gr_register_operand" "") (const_int 0)))
2524    (set (match_operand:DI 0 "gr_register_operand" "")
2525         (if_then_else:DI (eq (match_dup 2) (const_int 0))
2526                          (neg:DI (match_dup 1))
2527                          (match_dup 1)))]
2528   ""
2529   { operands[2] = gen_reg_rtx (BImode); })
2530
2531 (define_expand "smindi3"
2532   [(set (match_dup 3)
2533         (ge:BI (match_operand:DI 1 "gr_register_operand" "")
2534                (match_operand:DI 2 "gr_register_operand" "")))
2535    (set (match_operand:DI 0 "gr_register_operand" "")
2536         (if_then_else:DI (ne (match_dup 3) (const_int 0))
2537                          (match_dup 2) (match_dup 1)))]
2538   ""
2539   { operands[3] = gen_reg_rtx (BImode); })
2540
2541 (define_expand "smaxdi3"
2542   [(set (match_dup 3)
2543         (ge:BI (match_operand:DI 1 "gr_register_operand" "")
2544                (match_operand:DI 2 "gr_register_operand" "")))
2545    (set (match_operand:DI 0 "gr_register_operand" "")
2546         (if_then_else:DI (ne (match_dup 3) (const_int 0))
2547                          (match_dup 1) (match_dup 2)))]
2548   ""
2549   { operands[3] = gen_reg_rtx (BImode); })
2550
2551 (define_expand "umindi3"
2552   [(set (match_dup 3)
2553         (geu:BI (match_operand:DI 1 "gr_register_operand" "")
2554                 (match_operand:DI 2 "gr_register_operand" "")))
2555    (set (match_operand:DI 0 "gr_register_operand" "")
2556         (if_then_else:DI (ne (match_dup 3) (const_int 0))
2557                          (match_dup 2) (match_dup 1)))]
2558   ""
2559   { operands[3] = gen_reg_rtx (BImode); })
2560
2561 (define_expand "umaxdi3"
2562   [(set (match_dup 3)
2563         (geu:BI (match_operand:DI 1 "gr_register_operand" "")
2564                 (match_operand:DI 2 "gr_register_operand" "")))
2565    (set (match_operand:DI 0 "gr_register_operand" "")
2566         (if_then_else:DI (ne (match_dup 3) (const_int 0))
2567                          (match_dup 1) (match_dup 2)))]
2568   ""
2569   { operands[3] = gen_reg_rtx (BImode); })
2570
2571 (define_expand "ffsdi2"
2572   [(set (match_dup 6)
2573         (eq:BI (match_operand:DI 1 "gr_register_operand" "") (const_int 0)))
2574    (set (match_dup 2) (plus:DI (match_dup 1) (const_int -1)))
2575    (set (match_dup 5) (const_int 0))
2576    (set (match_dup 3) (xor:DI (match_dup 1) (match_dup 2)))
2577    (set (match_dup 4) (popcount:DI (match_dup 3)))
2578    (set (match_operand:DI 0 "gr_register_operand" "")
2579         (if_then_else:DI (ne (match_dup 6) (const_int 0))
2580                          (match_dup 5) (match_dup 4)))]
2581   ""
2582 {
2583   operands[2] = gen_reg_rtx (DImode);
2584   operands[3] = gen_reg_rtx (DImode);
2585   operands[4] = gen_reg_rtx (DImode);
2586   operands[5] = gen_reg_rtx (DImode);
2587   operands[6] = gen_reg_rtx (BImode);
2588 })
2589
2590 (define_expand "ctzdi2"
2591   [(set (match_dup 2) (plus:DI (match_operand:DI 1 "gr_register_operand" "")
2592                                (const_int -1)))
2593    (set (match_dup 3) (not:DI (match_dup 1)))
2594    (set (match_dup 4) (and:DI (match_dup 2) (match_dup 3)))
2595    (set (match_operand:DI 0 "gr_register_operand" "")
2596         (popcount:DI (match_dup 4)))]
2597   ""
2598 {
2599   operands[2] = gen_reg_rtx (DImode);
2600   operands[3] = gen_reg_rtx (DImode);
2601   operands[4] = gen_reg_rtx (DImode);
2602 })
2603
2604 ;; Note the computation here is op0 = 63 - (exp - 0xffff).
2605 (define_expand "clzdi2"
2606   [(set (match_dup 2)
2607         (unsigned_float:XF (match_operand:DI 1 "fr_register_operand" "")))
2608    (set (match_dup 3)
2609         (unspec:DI [(match_dup 2)] UNSPEC_GETF_EXP))
2610    (set (match_dup 4) (const_int 65598))
2611    (set (match_operand:DI 0 "gr_register_operand" "")
2612         (minus:DI (match_dup 4) (match_dup 3)))]
2613   ""
2614 {
2615   operands[2] = gen_reg_rtx (XFmode);
2616   operands[3] = gen_reg_rtx (DImode);
2617   operands[4] = gen_reg_rtx (DImode);
2618 })
2619
2620 (define_insn "popcountdi2"
2621   [(set (match_operand:DI 0 "gr_register_operand" "=r")
2622         (popcount:DI (match_operand:DI 1 "gr_register_operand" "r")))]
2623   ""
2624   "popcnt %0 = %1"
2625   [(set_attr "itanium_class" "mmmul")])
2626
2627 (define_insn "*getf_exp_xf"
2628   [(set (match_operand:DI 0 "gr_register_operand" "=r")
2629         (unspec:DI [(match_operand:XF 1 "fr_register_operand" "f")]
2630                    UNSPEC_GETF_EXP))]
2631   ""
2632   "getf.exp %0 = %1"
2633   [(set_attr "itanium_class" "frfr")])
2634
2635 (define_expand "divdi3"
2636   [(set (match_operand:DI 0 "register_operand" "")
2637         (div:DI (match_operand:DI 1 "general_operand" "")
2638                 (match_operand:DI 2 "general_operand" "")))]
2639   "TARGET_INLINE_INT_DIV"
2640 {
2641   rtx op1_xf, op2_xf, op0_xf;
2642
2643   op0_xf = gen_reg_rtx (XFmode);
2644
2645   if (CONSTANT_P (operands[1]))
2646     operands[1] = force_reg (DImode, operands[1]);
2647   op1_xf = gen_reg_rtx (XFmode);
2648   expand_float (op1_xf, operands[1], 0);
2649
2650   if (CONSTANT_P (operands[2]))
2651     operands[2] = force_reg (DImode, operands[2]);
2652   op2_xf = gen_reg_rtx (XFmode);
2653   expand_float (op2_xf, operands[2], 0);
2654
2655   if (TARGET_INLINE_INT_DIV_LAT)
2656     emit_insn (gen_divdi3_internal_lat (op0_xf, op1_xf, op2_xf));
2657   else
2658     emit_insn (gen_divdi3_internal_thr (op0_xf, op1_xf, op2_xf));
2659
2660   emit_insn (gen_fix_truncxfdi2_alts (operands[0], op0_xf, const1_rtx));
2661   DONE;
2662 })
2663
2664 (define_expand "moddi3"
2665   [(set (match_operand:DI 0 "register_operand" "")
2666         (mod:SI (match_operand:DI 1 "general_operand" "")
2667                 (match_operand:DI 2 "general_operand" "")))]
2668   "TARGET_INLINE_INT_DIV"
2669 {
2670   rtx op2_neg, div;
2671
2672   div = gen_reg_rtx (DImode);
2673   emit_insn (gen_divdi3 (div, operands[1], operands[2]));
2674
2675   op2_neg = expand_unop (DImode, neg_optab, operands[2], NULL_RTX, 0);
2676
2677   emit_insn (gen_madddi4 (operands[0], div, op2_neg, operands[1]));
2678   DONE;
2679 })
2680
2681 (define_expand "udivdi3"
2682   [(set (match_operand:DI 0 "register_operand" "")
2683         (udiv:DI (match_operand:DI 1 "general_operand" "")
2684                  (match_operand:DI 2 "general_operand" "")))]
2685   "TARGET_INLINE_INT_DIV"
2686 {
2687   rtx op1_xf, op2_xf, op0_xf;
2688
2689   op0_xf = gen_reg_rtx (XFmode);
2690
2691   if (CONSTANT_P (operands[1]))
2692     operands[1] = force_reg (DImode, operands[1]);
2693   op1_xf = gen_reg_rtx (XFmode);
2694   expand_float (op1_xf, operands[1], 1);
2695
2696   if (CONSTANT_P (operands[2]))
2697     operands[2] = force_reg (DImode, operands[2]);
2698   op2_xf = gen_reg_rtx (XFmode);
2699   expand_float (op2_xf, operands[2], 1);
2700
2701   if (TARGET_INLINE_INT_DIV_LAT)
2702     emit_insn (gen_divdi3_internal_lat (op0_xf, op1_xf, op2_xf));
2703   else
2704     emit_insn (gen_divdi3_internal_thr (op0_xf, op1_xf, op2_xf));
2705
2706   emit_insn (gen_fixuns_truncxfdi2_alts (operands[0], op0_xf, const1_rtx));
2707   DONE;
2708 })
2709
2710 (define_expand "umoddi3"
2711   [(set (match_operand:DI 0 "register_operand" "")
2712         (umod:DI (match_operand:DI 1 "general_operand" "")
2713                  (match_operand:DI 2 "general_operand" "")))]
2714   "TARGET_INLINE_INT_DIV"
2715 {
2716   rtx op2_neg, div;
2717
2718   div = gen_reg_rtx (DImode);
2719   emit_insn (gen_udivdi3 (div, operands[1], operands[2]));
2720
2721   op2_neg = expand_unop (DImode, neg_optab, operands[2], NULL_RTX, 0);
2722
2723   emit_insn (gen_madddi4 (operands[0], div, op2_neg, operands[1]));
2724   DONE;
2725 })
2726
2727 (define_insn_and_split "divdi3_internal_lat"
2728   [(set (match_operand:XF 0 "fr_register_operand" "=&f")
2729         (float:XF (div:SI (match_operand:XF 1 "fr_register_operand" "f")
2730                           (match_operand:XF 2 "fr_register_operand" "f"))))
2731    (clobber (match_scratch:XF 3 "=&f"))
2732    (clobber (match_scratch:XF 4 "=&f"))
2733    (clobber (match_scratch:XF 5 "=&f"))
2734    (clobber (match_scratch:BI 6 "=c"))]
2735   "TARGET_INLINE_INT_DIV_LAT"
2736   "#"
2737   "&& reload_completed"
2738   [(parallel [(set (match_dup 0) (div:XF (const_int 1) (match_dup 2)))
2739               (set (match_dup 6) (unspec:BI [(match_dup 1) (match_dup 2)]
2740                                             UNSPEC_FR_RECIP_APPROX))
2741               (use (const_int 1))])
2742    (cond_exec (ne (match_dup 6) (const_int 0))
2743      (parallel [(set (match_dup 3)
2744                      (minus:XF (match_dup 7)
2745                                (mult:XF (match_dup 2) (match_dup 0))))
2746                 (use (const_int 1))]))
2747    (cond_exec (ne (match_dup 6) (const_int 0))
2748      (parallel [(set (match_dup 4) (mult:XF (match_dup 1) (match_dup 0)))
2749                 (use (const_int 1))]))
2750    (cond_exec (ne (match_dup 6) (const_int 0))
2751      (parallel [(set (match_dup 5) (mult:XF (match_dup 3) (match_dup 3)))
2752                 (use (const_int 1))]))
2753    (cond_exec (ne (match_dup 6) (const_int 0))
2754      (parallel [(set (match_dup 4)
2755                      (plus:XF (mult:XF (match_dup 3) (match_dup 4))
2756                               (match_dup 4)))
2757                 (use (const_int 1))]))
2758    (cond_exec (ne (match_dup 6) (const_int 0))
2759      (parallel [(set (match_dup 0)
2760                      (plus:XF (mult:XF (match_dup 3) (match_dup 0))
2761                               (match_dup 0)))
2762                 (use (const_int 1))]))
2763    (cond_exec (ne (match_dup 6) (const_int 0))
2764      (parallel [(set (match_dup 3)
2765                      (plus:XF (mult:XF (match_dup 5) (match_dup 4))
2766                               (match_dup 4)))
2767                 (use (const_int 1))]))
2768    (cond_exec (ne (match_dup 6) (const_int 0))
2769      (parallel [(set (match_dup 0)
2770                      (plus:XF (mult:XF (match_dup 5) (match_dup 0))
2771                               (match_dup 0)))
2772                 (use (const_int 1))]))
2773    (cond_exec (ne (match_dup 6) (const_int 0))
2774      (parallel [(set (match_dup 4)
2775                      (minus:XF (match_dup 1)
2776                                (mult:XF (match_dup 2) (match_dup 3))))
2777                 (use (const_int 1))]))
2778    (cond_exec (ne (match_dup 6) (const_int 0))
2779      (parallel [(set (match_dup 0)
2780                      (plus:XF (mult:XF (match_dup 4) (match_dup 0))
2781                               (match_dup 3)))
2782                 (use (const_int 1))]))
2783   ] 
2784   "operands[7] = CONST1_RTX (XFmode);"
2785   [(set_attr "predicable" "no")])
2786
2787 (define_insn_and_split "divdi3_internal_thr"
2788   [(set (match_operand:XF 0 "fr_register_operand" "=&f")
2789         (float:XF (div:SI (match_operand:XF 1 "fr_register_operand" "f")
2790                           (match_operand:XF 2 "fr_register_operand" "f"))))
2791    (clobber (match_scratch:XF 3 "=&f"))
2792    (clobber (match_scratch:XF 4 "=f"))
2793    (clobber (match_scratch:BI 5 "=c"))]
2794   "TARGET_INLINE_INT_DIV_THR"
2795   "#"
2796   "&& reload_completed"
2797   [(parallel [(set (match_dup 0) (div:XF (const_int 1) (match_dup 2)))
2798               (set (match_dup 5) (unspec:BI [(match_dup 1) (match_dup 2)] 
2799                                             UNSPEC_FR_RECIP_APPROX))
2800               (use (const_int 1))])
2801    (cond_exec (ne (match_dup 5) (const_int 0))
2802      (parallel [(set (match_dup 3)
2803                      (minus:XF (match_dup 6)
2804                                (mult:XF (match_dup 2) (match_dup 0))))
2805                 (use (const_int 1))]))
2806    (cond_exec (ne (match_dup 5) (const_int 0))
2807      (parallel [(set (match_dup 0)
2808                      (plus:XF (mult:XF (match_dup 3) (match_dup 0))
2809                               (match_dup 0)))
2810                 (use (const_int 1))]))
2811    (cond_exec (ne (match_dup 5) (const_int 0))
2812      (parallel [(set (match_dup 3) (mult:XF (match_dup 3) (match_dup 3)))
2813                 (use (const_int 1))]))
2814    (cond_exec (ne (match_dup 5) (const_int 0))
2815      (parallel [(set (match_dup 0)
2816                      (plus:XF (mult:XF (match_dup 3) (match_dup 0))
2817                               (match_dup 0)))
2818                 (use (const_int 1))]))
2819    (cond_exec (ne (match_dup 5) (const_int 0))
2820      (parallel [(set (match_dup 3) (mult:XF (match_dup 0) (match_dup 1)))
2821                 (use (const_int 1))]))
2822    (cond_exec (ne (match_dup 5) (const_int 0))
2823      (parallel [(set (match_dup 4)
2824                      (minus:XF (match_dup 1)
2825                                (mult:XF (match_dup 2) (match_dup 3))))
2826                 (use (const_int 1))]))
2827    (cond_exec (ne (match_dup 5) (const_int 0))
2828      (parallel [(set (match_dup 0)
2829                      (plus:XF (mult:XF (match_dup 4) (match_dup 0))
2830                               (match_dup 3)))
2831                 (use (const_int 1))]))
2832   ] 
2833   "operands[6] = CONST1_RTX (XFmode);"
2834   [(set_attr "predicable" "no")])
2835 \f
2836 ;; ::::::::::::::::::::
2837 ;; ::
2838 ;; :: 32 bit floating point arithmetic
2839 ;; ::
2840 ;; ::::::::::::::::::::
2841
2842 (define_insn "addsf3"
2843   [(set (match_operand:SF 0 "fr_register_operand" "=f")
2844         (plus:SF (match_operand:SF 1 "fr_register_operand" "%f")
2845                  (match_operand:SF 2 "fr_reg_or_fp01_operand" "fG")))]
2846   ""
2847   "fadd.s %0 = %1, %F2"
2848   [(set_attr "itanium_class" "fmac")])
2849
2850 (define_insn "subsf3"
2851   [(set (match_operand:SF 0 "fr_register_operand" "=f")
2852         (minus:SF (match_operand:SF 1 "fr_reg_or_fp01_operand" "fG")
2853                   (match_operand:SF 2 "fr_reg_or_fp01_operand" "fG")))]
2854   ""
2855   "fsub.s %0 = %F1, %F2"
2856   [(set_attr "itanium_class" "fmac")])
2857
2858 (define_insn "mulsf3"
2859   [(set (match_operand:SF 0 "fr_register_operand" "=f")
2860         (mult:SF (match_operand:SF 1 "fr_register_operand" "%f")
2861                  (match_operand:SF 2 "fr_register_operand" "f")))]
2862   ""
2863   "fmpy.s %0 = %1, %2"
2864   [(set_attr "itanium_class" "fmac")])
2865
2866 (define_insn "abssf2"
2867   [(set (match_operand:SF 0 "fr_register_operand" "=f")
2868         (abs:SF (match_operand:SF 1 "fr_register_operand" "f")))]
2869   ""
2870   "fabs %0 = %1"
2871   [(set_attr "itanium_class" "fmisc")])
2872
2873 (define_insn "negsf2"
2874   [(set (match_operand:SF 0 "fr_register_operand" "=f")
2875         (neg:SF (match_operand:SF 1 "fr_register_operand" "f")))]
2876   ""
2877   "fneg %0 = %1"
2878   [(set_attr "itanium_class" "fmisc")])
2879
2880 (define_insn "*nabssf2"
2881   [(set (match_operand:SF 0 "fr_register_operand" "=f")
2882         (neg:SF (abs:SF (match_operand:SF 1 "fr_register_operand" "f"))))]
2883   ""
2884   "fnegabs %0 = %1"
2885   [(set_attr "itanium_class" "fmisc")])
2886
2887 (define_insn "minsf3"
2888   [(set (match_operand:SF 0 "fr_register_operand" "=f")
2889         (smin:SF (match_operand:SF 1 "fr_register_operand" "f")
2890                  (match_operand:SF 2 "fr_reg_or_fp01_operand" "fG")))]
2891   ""
2892   "fmin %0 = %1, %F2"
2893   [(set_attr "itanium_class" "fmisc")])
2894
2895 (define_insn "maxsf3"
2896   [(set (match_operand:SF 0 "fr_register_operand" "=f")
2897         (smax:SF (match_operand:SF 1 "fr_register_operand" "f")
2898                  (match_operand:SF 2 "fr_reg_or_fp01_operand" "fG")))]
2899   ""
2900   "fmax %0 = %1, %F2"
2901   [(set_attr "itanium_class" "fmisc")])
2902
2903 (define_insn "*maddsf4"
2904   [(set (match_operand:SF 0 "fr_register_operand" "=f")
2905         (plus:SF (mult:SF (match_operand:SF 1 "fr_register_operand" "f")
2906                           (match_operand:SF 2 "fr_register_operand" "f"))
2907                  (match_operand:SF 3 "fr_reg_or_fp01_operand" "fG")))]
2908   ""
2909   "fma.s %0 = %1, %2, %F3"
2910   [(set_attr "itanium_class" "fmac")])
2911
2912 (define_insn "*msubsf4"
2913   [(set (match_operand:SF 0 "fr_register_operand" "=f")
2914         (minus:SF (mult:SF (match_operand:SF 1 "fr_register_operand" "f")
2915                            (match_operand:SF 2 "fr_register_operand" "f"))
2916                   (match_operand:SF 3 "fr_reg_or_fp01_operand" "fG")))]
2917   ""
2918   "fms.s %0 = %1, %2, %F3"
2919   [(set_attr "itanium_class" "fmac")])
2920
2921 (define_insn "*nmulsf3"
2922   [(set (match_operand:SF 0 "fr_register_operand" "=f")
2923         (neg:SF (mult:SF (match_operand:SF 1 "fr_register_operand" "f")
2924                          (match_operand:SF 2 "fr_register_operand" "f"))))]
2925   ""
2926   "fnmpy.s %0 = %1, %2"
2927   [(set_attr "itanium_class" "fmac")])
2928
2929 (define_insn "*nmaddsf4"
2930   [(set (match_operand:SF 0 "fr_register_operand" "=f")
2931         (minus:SF (match_operand:SF 3 "fr_reg_or_fp01_operand" "fG") 
2932                   (mult:SF (match_operand:SF 1 "fr_register_operand" "f")
2933                            (match_operand:SF 2 "fr_register_operand" "f"))))]
2934   ""
2935   "fnma.s %0 = %1, %2, %F3"
2936   [(set_attr "itanium_class" "fmac")])
2937
2938 (define_insn "*nmaddsf4_alts"
2939   [(set (match_operand:SF 0 "fr_register_operand" "=f")
2940         (minus:SF (match_operand:SF 3 "fr_reg_or_fp01_operand" "fG") 
2941                   (mult:SF (match_operand:SF 1 "fr_register_operand" "f")
2942                            (match_operand:SF 2 "fr_register_operand" "f"))))
2943    (use (match_operand:SI 4 "const_int_operand" ""))]
2944   ""
2945   "fnma.s.s%4 %0 = %1, %2, %F3"
2946   [(set_attr "itanium_class" "fmac")])
2947
2948 (define_expand "divsf3"
2949   [(set (match_operand:SF 0 "fr_register_operand" "")
2950         (div:SF (match_operand:SF 1 "fr_register_operand" "")
2951                 (match_operand:SF 2 "fr_register_operand" "")))]
2952   "TARGET_INLINE_FLOAT_DIV"
2953 {
2954   rtx insn;
2955   if (TARGET_INLINE_FLOAT_DIV_LAT)
2956     insn = gen_divsf3_internal_lat (operands[0], operands[1], operands[2]);
2957   else
2958     insn = gen_divsf3_internal_thr (operands[0], operands[1], operands[2]);
2959   emit_insn (insn);
2960   DONE;
2961 })
2962
2963 (define_insn_and_split "divsf3_internal_lat"
2964   [(set (match_operand:SF 0 "fr_register_operand" "=&f")
2965         (div:SF (match_operand:SF 1 "fr_register_operand" "f")
2966                 (match_operand:SF 2 "fr_register_operand" "f")))
2967    (clobber (match_scratch:XF 3 "=&f"))
2968    (clobber (match_scratch:XF 4 "=f"))
2969    (clobber (match_scratch:BI 5 "=c"))]
2970   "TARGET_INLINE_FLOAT_DIV_LAT"
2971   "#"
2972   "&& reload_completed"
2973   [(parallel [(set (match_dup 6) (div:XF (const_int 1) (match_dup 8)))
2974               (set (match_dup 5) (unspec:BI [(match_dup 7) (match_dup 8)]
2975                                             UNSPEC_FR_RECIP_APPROX))
2976               (use (const_int 1))])
2977    (cond_exec (ne (match_dup 5) (const_int 0))
2978      (parallel [(set (match_dup 3) (mult:XF (match_dup 7) (match_dup 6)))
2979                 (use (const_int 1))]))
2980    (cond_exec (ne (match_dup 5) (const_int 0))
2981      (parallel [(set (match_dup 4)
2982                      (minus:XF (match_dup 10)
2983                                (mult:XF (match_dup 8) (match_dup 6))))
2984                 (use (const_int 1))]))
2985    (cond_exec (ne (match_dup 5) (const_int 0))
2986      (parallel [(set (match_dup 3)
2987                      (plus:XF (mult:XF (match_dup 4) (match_dup 3))
2988                               (match_dup 3)))
2989                 (use (const_int 1))]))
2990    (cond_exec (ne (match_dup 5) (const_int 0))
2991      (parallel [(set (match_dup 4) (mult:XF (match_dup 4) (match_dup 4)))
2992                 (use (const_int 1))]))
2993    (cond_exec (ne (match_dup 5) (const_int 0))
2994      (parallel [(set (match_dup 3)
2995                      (plus:XF (mult:XF (match_dup 4) (match_dup 3))
2996                               (match_dup 3)))
2997                 (use (const_int 1))]))
2998    (cond_exec (ne (match_dup 5) (const_int 0))
2999      (parallel [(set (match_dup 4) (mult:XF (match_dup 4) (match_dup 4)))
3000                 (use (const_int 1))]))
3001    (cond_exec (ne (match_dup 5) (const_int 0))
3002      (parallel [(set (match_dup 9)
3003                      (float_truncate:DF
3004                        (plus:XF (mult:XF (match_dup 4) (match_dup 3))
3005                               (match_dup 3))))
3006                 (use (const_int 1))]))
3007    (cond_exec (ne (match_dup 5) (const_int 0))
3008      (set (match_dup 0)
3009           (float_truncate:SF (match_dup 6))))
3010   ] 
3011 {
3012   operands[6] = gen_rtx_REG (XFmode, REGNO (operands[0]));
3013   operands[7] = gen_rtx_REG (XFmode, REGNO (operands[1]));
3014   operands[8] = gen_rtx_REG (XFmode, REGNO (operands[2]));
3015   operands[9] = gen_rtx_REG (DFmode, REGNO (operands[0]));
3016   operands[10] = CONST1_RTX (XFmode);
3017 }
3018   [(set_attr "predicable" "no")])
3019
3020 (define_insn_and_split "divsf3_internal_thr"
3021   [(set (match_operand:SF 0 "fr_register_operand" "=&f")
3022         (div:SF (match_operand:SF 1 "fr_register_operand" "f")
3023                 (match_operand:SF 2 "fr_register_operand" "f")))
3024    (clobber (match_scratch:XF 3 "=&f"))
3025    (clobber (match_scratch:XF 4 "=f"))
3026    (clobber (match_scratch:BI 5 "=c"))]
3027   "TARGET_INLINE_FLOAT_DIV_THR"
3028   "#"
3029   "&& reload_completed"
3030   [(parallel [(set (match_dup 6) (div:XF (const_int 1) (match_dup 8)))
3031               (set (match_dup 5) (unspec:BI [(match_dup 7) (match_dup 8)]
3032                                             UNSPEC_FR_RECIP_APPROX))
3033               (use (const_int 1))])
3034    (cond_exec (ne (match_dup 5) (const_int 0))
3035      (parallel [(set (match_dup 3)
3036                      (minus:XF (match_dup 10)
3037                                (mult:XF (match_dup 8) (match_dup 6))))
3038                 (use (const_int 1))]))
3039    (cond_exec (ne (match_dup 5) (const_int 0))
3040      (parallel [(set (match_dup 3)
3041                      (plus:XF (mult:XF (match_dup 3) (match_dup 3))
3042                               (match_dup 3)))
3043                 (use (const_int 1))]))
3044    (cond_exec (ne (match_dup 5) (const_int 0))
3045      (parallel [(set (match_dup 6)
3046                      (plus:XF (mult:XF (match_dup 3) (match_dup 6))
3047                               (match_dup 6)))
3048                 (use (const_int 1))]))
3049    (cond_exec (ne (match_dup 5) (const_int 0))
3050      (parallel [(set (match_dup 9)
3051                      (float_truncate:SF
3052                        (mult:XF (match_dup 7) (match_dup 6))))
3053                 (use (const_int 1))]))
3054    (cond_exec (ne (match_dup 5) (const_int 0))
3055      (parallel [(set (match_dup 4)
3056                      (minus:XF (match_dup 7)
3057                                (mult:XF (match_dup 8) (match_dup 3))))
3058                 (use (const_int 1))]))
3059    (cond_exec (ne (match_dup 5) (const_int 0))
3060      (set (match_dup 0)
3061           (float_truncate:SF
3062             (plus:XF (mult:XF (match_dup 4) (match_dup 6))
3063                               (match_dup 3)))))
3064   ] 
3065 {
3066   operands[6] = gen_rtx_REG (XFmode, REGNO (operands[0]));
3067   operands[7] = gen_rtx_REG (XFmode, REGNO (operands[1]));
3068   operands[8] = gen_rtx_REG (XFmode, REGNO (operands[2]));
3069   operands[9] = gen_rtx_REG (SFmode, REGNO (operands[3]));
3070   operands[10] = CONST1_RTX (XFmode);
3071 }
3072   [(set_attr "predicable" "no")])
3073
3074 ;; Inline square root.
3075
3076 (define_insn "*sqrt_approx"
3077   [(set (match_operand:XF 0 "fr_register_operand" "=f")
3078         (div:XF (const_int 1)
3079                 (sqrt:XF (match_operand:XF 2 "fr_register_operand" "f"))))
3080    (set (match_operand:BI 1 "register_operand" "=c")
3081         (unspec:BI [(match_dup 2)] UNSPEC_FR_SQRT_RECIP_APPROX))
3082    (use (match_operand:SI 3 "const_int_operand" "")) ]
3083   ""
3084   "frsqrta.s%3 %0, %1 = %2"
3085   [(set_attr "itanium_class" "fmisc")
3086    (set_attr "predicable" "no")])
3087
3088 (define_insn "setf_exp_xf"
3089   [(set (match_operand:XF 0 "fr_register_operand" "=f")
3090         (unspec:XF [(match_operand:DI 1 "register_operand" "r")]
3091                   UNSPEC_SETF_EXP))]
3092   ""
3093   "setf.exp %0 = %1"
3094   [(set_attr "itanium_class" "frfr")])
3095
3096 (define_expand "sqrtsf2"
3097   [(set (match_operand:SF 0 "fr_register_operand" "=&f")
3098         (sqrt:SF (match_operand:SF 1 "fr_register_operand" "f")))]
3099   "TARGET_INLINE_SQRT"
3100 {
3101   rtx insn;
3102   if (TARGET_INLINE_SQRT_LAT)
3103 #if 0
3104     insn = gen_sqrtsf2_internal_lat (operands[0], operands[1]);
3105 #else
3106     abort ();
3107 #endif
3108   else
3109     insn = gen_sqrtsf2_internal_thr (operands[0], operands[1]);
3110   emit_insn (insn);
3111   DONE;
3112 })
3113
3114 ;; Latency-optimized square root.
3115 ;; FIXME: Implement.
3116
3117 ;; Throughput-optimized square root.
3118
3119 (define_insn_and_split "sqrtsf2_internal_thr"
3120   [(set (match_operand:SF 0 "fr_register_operand" "=&f")
3121         (sqrt:SF (match_operand:SF 1 "fr_register_operand" "f")))
3122    ;; Register r2 in optimization guide.
3123    (clobber (match_scratch:DI 2 "=r"))
3124    ;; Register f8 in optimization guide
3125    (clobber (match_scratch:XF 3 "=&f"))
3126    ;; Register f9 in optimization guide
3127    (clobber (match_scratch:XF 4 "=&f"))
3128    ;; Register f10 in optimization guide
3129    (clobber (match_scratch:XF 5 "=&f"))
3130    ;; Register p6 in optimization guide.
3131    (clobber (match_scratch:BI 6 "=c"))]
3132   "TARGET_INLINE_SQRT_THR"
3133   "#"
3134   "&& reload_completed"
3135   [ ;; exponent of +1/2 in r2
3136     (set (match_dup 2) (const_int 65534))
3137     ;; +1/2 in f8
3138     (set (match_dup 3) 
3139          (unspec:XF [(match_dup 2)] UNSPEC_SETF_EXP))
3140     ;; Step 1
3141     ;; y0 = 1/sqrt(a) in f7
3142     (parallel [(set (match_dup 7)
3143                     (div:XF (const_int 1)
3144                             (sqrt:XF (match_dup 8))))
3145                (set (match_dup 6)
3146                     (unspec:BI [(match_dup 8)]
3147                                  UNSPEC_FR_SQRT_RECIP_APPROX))
3148                (use (const_int 0))])
3149     ;; Step 2
3150     ;; H0 = 1/2 * y0 in f9
3151     (cond_exec (ne (match_dup 6) (const_int 0))
3152       (parallel [(set (match_dup 4)
3153                       (plus:XF (mult:XF (match_dup 3) (match_dup 7))
3154                                (match_dup 9)))
3155                  (use (const_int 1))]))
3156     ;; Step 3
3157     ;; S0 = a * y0 in f7
3158     (cond_exec (ne (match_dup 6) (const_int 0))
3159       (parallel [(set (match_dup 7)
3160                       (plus:XF (mult:XF (match_dup 8) (match_dup 7))
3161                                (match_dup 9)))
3162                  (use (const_int 1))]))
3163     ;; Step 4
3164     ;; d = 1/2 - S0 * H0 in f10
3165     (cond_exec (ne (match_dup 6) (const_int 0))
3166       (parallel [(set (match_dup 5)
3167                       (minus:XF (match_dup 3)
3168                                 (mult:XF (match_dup 7) (match_dup 4))))
3169                  (use (const_int 1))]))
3170     ;; Step 5
3171     ;; d' = d + 1/2 * d in f8
3172     (cond_exec (ne (match_dup 6) (const_int 0))
3173        (parallel [(set (match_dup 3)
3174                        (plus:XF (mult:XF (match_dup 3) (match_dup 5))
3175                                 (match_dup 5)))
3176                   (use (const_int 1))]))
3177     ;; Step 6
3178     ;; e = d + d * d' in f8
3179     (cond_exec (ne (match_dup 6) (const_int 0))
3180        (parallel [(set (match_dup 3)
3181                        (plus:XF (mult:XF (match_dup 5) (match_dup 3))
3182                                 (match_dup 5)))
3183                   (use (const_int 1))]))
3184     ;; Step 7
3185     ;; S1 = S0 + e * S0 in f7
3186     (cond_exec (ne (match_dup 6) (const_int 0))
3187       (parallel [(set (match_dup 0)
3188                       (float_truncate:SF
3189                         (plus:XF (mult:XF (match_dup 3) (match_dup 7))
3190                                  (match_dup 7))))
3191                  (use (const_int 1))]))
3192     ;; Step 8
3193     ;; H1 = H0 + e * H0 in f8
3194     (cond_exec (ne (match_dup 6) (const_int 0))
3195        (parallel [(set (match_dup 3)
3196                        (plus:XF (mult:XF (match_dup 3) (match_dup 4))
3197                                 (match_dup 4)))
3198                   (use (const_int 1))]))
3199     ;; Step 9 
3200     ;; d1 = a - S1 * S1 in f9
3201     (cond_exec (ne (match_dup 6) (const_int 0))
3202        (parallel [(set (match_dup 4)
3203                        (minus:XF (match_dup 8)
3204                                  (mult:XF (match_dup 7) (match_dup 7))))
3205                   (use (const_int 1))]))
3206     ;; Step 10
3207     ;; S = S1 + d1 * H1 in f7
3208     (cond_exec (ne (match_dup 6) (const_int 0))
3209        (parallel [(set (match_dup 0)
3210                        (float_truncate:SF
3211                          (plus:XF (mult:XF (match_dup 4) (match_dup 3))
3212                                   (match_dup 7))))
3213                   (use (const_int 0))]))]
3214 {
3215   /* Generate 82-bit versions of the input and output operands.  */
3216   operands[7] = gen_rtx_REG (XFmode, REGNO (operands[0]));
3217   operands[8] = gen_rtx_REG (XFmode, REGNO (operands[1]));
3218   /* Generate required floating-point constants.  */
3219   operands[9] = CONST0_RTX (XFmode);
3220 }
3221   [(set_attr "predicable" "no")])
3222 \f
3223 ;; ::::::::::::::::::::
3224 ;; ::
3225 ;; :: 64 bit floating point arithmetic
3226 ;; ::
3227 ;; ::::::::::::::::::::
3228
3229 (define_insn "adddf3"
3230   [(set (match_operand:DF 0 "fr_register_operand" "=f")
3231         (plus:DF (match_operand:DF 1 "fr_register_operand" "%f")
3232                  (match_operand:DF 2 "fr_reg_or_fp01_operand" "fG")))]
3233   ""
3234   "fadd.d %0 = %1, %F2"
3235   [(set_attr "itanium_class" "fmac")])
3236
3237 (define_insn "*adddf3_trunc"
3238   [(set (match_operand:SF 0 "fr_register_operand" "=f")
3239         (float_truncate:SF
3240           (plus:DF (match_operand:DF 1 "fr_register_operand" "%f")
3241                    (match_operand:DF 2 "fr_reg_or_fp01_operand" "fG"))))]
3242   ""
3243   "fadd.s %0 = %1, %F2"
3244   [(set_attr "itanium_class" "fmac")])
3245
3246 (define_insn "subdf3"
3247   [(set (match_operand:DF 0 "fr_register_operand" "=f")
3248         (minus:DF (match_operand:DF 1 "fr_reg_or_fp01_operand" "fG")
3249                   (match_operand:DF 2 "fr_reg_or_fp01_operand" "fG")))]
3250   ""
3251   "fsub.d %0 = %F1, %F2"
3252   [(set_attr "itanium_class" "fmac")])
3253
3254 (define_insn "*subdf3_trunc"
3255   [(set (match_operand:SF 0 "fr_register_operand" "=f")
3256         (float_truncate:SF
3257           (minus:DF (match_operand:DF 1 "fr_reg_or_fp01_operand" "fG")
3258                     (match_operand:DF 2 "fr_reg_or_fp01_operand" "fG"))))]
3259   ""
3260   "fsub.s %0 = %F1, %F2"
3261   [(set_attr "itanium_class" "fmac")])
3262
3263 (define_insn "muldf3"
3264   [(set (match_operand:DF 0 "fr_register_operand" "=f")
3265         (mult:DF (match_operand:DF 1 "fr_register_operand" "f")
3266                  (match_operand:DF 2 "fr_register_operand" "f")))]
3267   ""
3268   "fmpy.d %0 = %1, %2"
3269   [(set_attr "itanium_class" "fmac")])
3270
3271 (define_insn "*muldf3_trunc"
3272   [(set (match_operand:SF 0 "fr_register_operand" "=f")
3273         (float_truncate:SF
3274           (mult:DF (match_operand:DF 1 "fr_register_operand" "f")
3275                    (match_operand:DF 2 "fr_register_operand" "f"))))]
3276   ""
3277   "fmpy.s %0 = %1, %2"
3278   [(set_attr "itanium_class" "fmac")])
3279
3280 (define_insn "absdf2"
3281   [(set (match_operand:DF 0 "fr_register_operand" "=f")
3282         (abs:DF (match_operand:DF 1 "fr_register_operand" "f")))]
3283   ""
3284   "fabs %0 = %1"
3285   [(set_attr "itanium_class" "fmisc")])
3286
3287 (define_insn "negdf2"
3288   [(set (match_operand:DF 0 "fr_register_operand" "=f")
3289         (neg:DF (match_operand:DF 1 "fr_register_operand" "f")))]
3290   ""
3291   "fneg %0 = %1"
3292   [(set_attr "itanium_class" "fmisc")])
3293
3294 (define_insn "*nabsdf2"
3295   [(set (match_operand:DF 0 "fr_register_operand" "=f")
3296         (neg:DF (abs:DF (match_operand:DF 1 "fr_register_operand" "f"))))]
3297   ""
3298   "fnegabs %0 = %1"
3299   [(set_attr "itanium_class" "fmisc")])
3300
3301 (define_insn "mindf3"
3302   [(set (match_operand:DF 0 "fr_register_operand" "=f")
3303         (smin:DF (match_operand:DF 1 "fr_register_operand" "f")
3304                  (match_operand:DF 2 "fr_reg_or_fp01_operand" "fG")))]
3305   ""
3306   "fmin %0 = %1, %F2"
3307   [(set_attr "itanium_class" "fmisc")])
3308
3309 (define_insn "maxdf3"
3310   [(set (match_operand:DF 0 "fr_register_operand" "=f")
3311         (smax:DF (match_operand:DF 1 "fr_register_operand" "f")
3312                  (match_operand:DF 2 "fr_reg_or_fp01_operand" "fG")))]
3313   ""
3314   "fmax %0 = %1, %F2"
3315   [(set_attr "itanium_class" "fmisc")])
3316
3317 (define_insn "*madddf4"
3318   [(set (match_operand:DF 0 "fr_register_operand" "=f")
3319         (plus:DF (mult:DF (match_operand:DF 1 "fr_register_operand" "f")
3320                           (match_operand:DF 2 "fr_register_operand" "f"))
3321                  (match_operand:DF 3 "fr_reg_or_fp01_operand" "fG")))]
3322   ""
3323   "fma.d %0 = %1, %2, %F3"
3324   [(set_attr "itanium_class" "fmac")])
3325
3326 (define_insn "*madddf4_trunc"
3327   [(set (match_operand:SF 0 "fr_register_operand" "=f")
3328         (float_truncate:SF
3329           (plus:DF (mult:DF (match_operand:DF 1 "fr_register_operand" "f")
3330                             (match_operand:DF 2 "fr_register_operand" "f"))
3331                    (match_operand:DF 3 "fr_reg_or_fp01_operand" "fG"))))]
3332   ""
3333   "fma.s %0 = %1, %2, %F3"
3334   [(set_attr "itanium_class" "fmac")])
3335
3336 (define_insn "*msubdf4"
3337   [(set (match_operand:DF 0 "fr_register_operand" "=f")
3338         (minus:DF (mult:DF (match_operand:DF 1 "fr_register_operand" "f")
3339                            (match_operand:DF 2 "fr_register_operand" "f"))
3340                   (match_operand:DF 3 "fr_reg_or_fp01_operand" "fG")))]
3341   ""
3342   "fms.d %0 = %1, %2, %F3"
3343   [(set_attr "itanium_class" "fmac")])
3344
3345 (define_insn "*msubdf4_trunc"
3346   [(set (match_operand:SF 0 "fr_register_operand" "=f")
3347         (float_truncate:SF
3348           (minus:DF (mult:DF (match_operand:DF 1 "fr_register_operand" "f")
3349                              (match_operand:DF 2 "fr_register_operand" "f"))
3350                     (match_operand:DF 3 "fr_reg_or_fp01_operand" "fG"))))]
3351   ""
3352   "fms.s %0 = %1, %2, %F3"
3353   [(set_attr "itanium_class" "fmac")])
3354
3355 (define_insn "*nmuldf3"
3356   [(set (match_operand:DF 0 "fr_register_operand" "=f")
3357         (neg:DF (mult:DF (match_operand:DF 1 "fr_register_operand" "f")
3358                          (match_operand:DF 2 "fr_register_operand" "f"))))]
3359   ""
3360   "fnmpy.d %0 = %1, %2"
3361   [(set_attr "itanium_class" "fmac")])
3362
3363 (define_insn "*nmuldf3_trunc"
3364   [(set (match_operand:SF 0 "fr_register_operand" "=f")
3365         (float_truncate:SF
3366           (neg:DF (mult:DF (match_operand:DF 1 "fr_register_operand" "f")
3367                            (match_operand:DF 2 "fr_register_operand" "f")))))]
3368   ""
3369   "fnmpy.s %0 = %1, %2"
3370   [(set_attr "itanium_class" "fmac")])
3371
3372 (define_insn "*nmadddf4"
3373   [(set (match_operand:DF 0 "fr_register_operand" "=f")
3374         (minus:DF (match_operand:DF 3 "fr_reg_or_fp01_operand" "fG")
3375                   (mult:DF (match_operand:DF 1 "fr_register_operand" "f")
3376                            (match_operand:DF 2 "fr_register_operand" "f"))))]
3377   ""
3378   "fnma.d %0 = %1, %2, %F3"
3379   [(set_attr "itanium_class" "fmac")])
3380
3381 (define_insn "*nmadddf4_alts"
3382   [(set (match_operand:DF 0 "fr_register_operand" "=f")
3383         (minus:DF (match_operand:DF 3 "fr_reg_or_fp01_operand" "fG")
3384                   (mult:DF (match_operand:DF 1 "fr_register_operand" "f")
3385                            (match_operand:DF 2 "fr_register_operand" "f"))))
3386    (use (match_operand:SI 4 "const_int_operand" ""))]
3387   ""
3388   "fnma.d.s%4 %0 = %1, %2, %F3"
3389   [(set_attr "itanium_class" "fmac")])
3390
3391 (define_insn "*nmadddf4_truncsf"
3392   [(set (match_operand:SF 0 "fr_register_operand" "=f")
3393         (float_truncate:SF
3394         (minus:DF (match_operand:DF 3 "fr_reg_or_fp01_operand" "fG")
3395                   (mult:DF (match_operand:DF 1 "fr_register_operand" "f")
3396                            (match_operand:DF 2 "fr_register_operand" "f")))))]
3397   ""
3398   "fnma.s %0 = %1, %2, %F3"
3399   [(set_attr "itanium_class" "fmac")])
3400
3401 (define_insn "*nmadddf4_truncsf_alts"
3402   [(set (match_operand:SF 0 "fr_register_operand" "=f")
3403         (float_truncate:SF
3404         (minus:DF (match_operand:DF 3 "fr_reg_or_fp01_operand" "fG")
3405                   (mult:DF (match_operand:DF 1 "fr_register_operand" "f")
3406                            (match_operand:DF 2 "fr_register_operand" "f")))))
3407    (use (match_operand:SI 4 "const_int_operand" ""))]
3408   ""
3409   "fnma.s.s%4 %0 = %1, %2, %F3"
3410   [(set_attr "itanium_class" "fmac")])
3411
3412 (define_expand "divdf3"
3413   [(set (match_operand:DF 0 "fr_register_operand" "")
3414         (div:DF (match_operand:DF 1 "fr_register_operand" "")
3415                 (match_operand:DF 2 "fr_register_operand" "")))]
3416   "TARGET_INLINE_FLOAT_DIV"
3417 {
3418   rtx insn;
3419   if (TARGET_INLINE_FLOAT_DIV_LAT)
3420     insn = gen_divdf3_internal_lat (operands[0], operands[1], operands[2]);
3421   else
3422     insn = gen_divdf3_internal_thr (operands[0], operands[1], operands[2]);
3423   emit_insn (insn);
3424   DONE;
3425 })
3426
3427 (define_insn_and_split "divdf3_internal_lat"
3428   [(set (match_operand:DF 0 "fr_register_operand" "=&f")
3429         (div:DF (match_operand:DF 1 "fr_register_operand" "f")
3430                 (match_operand:DF 2 "fr_register_operand" "f")))
3431    (clobber (match_scratch:XF 3 "=&f"))
3432    (clobber (match_scratch:XF 4 "=&f"))
3433    (clobber (match_scratch:XF 5 "=&f"))
3434    (clobber (match_scratch:BI 6 "=c"))]
3435   "TARGET_INLINE_FLOAT_DIV_LAT"
3436   "#"
3437   "&& reload_completed"
3438   [(parallel [(set (match_dup 7) (div:XF (const_int 1) (match_dup 9)))
3439               (set (match_dup 6) (unspec:BI [(match_dup 8) (match_dup 9)]
3440                                             UNSPEC_FR_RECIP_APPROX))
3441               (use (const_int 1))])
3442    (cond_exec (ne (match_dup 6) (const_int 0))
3443      (parallel [(set (match_dup 3) (mult:XF (match_dup 8) (match_dup 7)))
3444                 (use (const_int 1))]))
3445    (cond_exec (ne (match_dup 6) (const_int 0))
3446      (parallel [(set (match_dup 4)
3447                      (minus:XF (match_dup 12)
3448                                (mult:XF (match_dup 9) (match_dup 7))))
3449                 (use (const_int 1))]))
3450    (cond_exec (ne (match_dup 6) (const_int 0))
3451      (parallel [(set (match_dup 3)
3452                      (plus:XF (mult:XF (match_dup 4) (match_dup 3))
3453                               (match_dup 3)))
3454                 (use (const_int 1))]))
3455    (cond_exec (ne (match_dup 6) (const_int 0))
3456      (parallel [(set (match_dup 5) (mult:XF (match_dup 4) (match_dup 4)))
3457                 (use (const_int 1))]))
3458    (cond_exec (ne (match_dup 6) (const_int 0))
3459      (parallel [(set (match_dup 7)
3460                      (plus:XF (mult:XF (match_dup 4) (match_dup 7))
3461                               (match_dup 7)))
3462                 (use (const_int 1))]))
3463    (cond_exec (ne (match_dup 6) (const_int 0))
3464      (parallel [(set (match_dup 3)
3465                      (plus:XF (mult:XF (match_dup 5) (match_dup 3))
3466                               (match_dup 3)))
3467                 (use (const_int 1))]))
3468    (cond_exec (ne (match_dup 6) (const_int 0))
3469      (parallel [(set (match_dup 4) (mult:XF (match_dup 5) (match_dup 5)))
3470                 (use (const_int 1))]))
3471    (cond_exec (ne (match_dup 6) (const_int 0))
3472      (parallel [(set (match_dup 7)
3473                      (plus:XF (mult:XF (match_dup 5) (match_dup 7))
3474                               (match_dup 7)))
3475                 (use (const_int 1))]))
3476    (cond_exec (ne (match_dup 6) (const_int 0))
3477      (parallel [(set (match_dup 10)
3478                      (float_truncate:DF
3479                        (plus:XF (mult:XF (match_dup 4) (match_dup 3))
3480                               (match_dup 3))))
3481                 (use (const_int 1))]))
3482    (cond_exec (ne (match_dup 6) (const_int 0))
3483      (parallel [(set (match_dup 7)
3484                      (plus:XF (mult:XF (match_dup 4) (match_dup 7))
3485                               (match_dup 7)))
3486                 (use (const_int 1))]))
3487    (cond_exec (ne (match_dup 6) (const_int 0))
3488      (parallel [(set (match_dup 11)
3489                      (float_truncate:DF
3490                        (minus:XF (match_dup 8)
3491                                  (mult:XF (match_dup 9) (match_dup 3)))))
3492                 (use (const_int 1))]))
3493    (cond_exec (ne (match_dup 6) (const_int 0))
3494      (set (match_dup 0)
3495           (float_truncate:DF (plus:XF (mult:XF (match_dup 5) (match_dup 7))
3496                               (match_dup 3)))))
3497   ] 
3498 {
3499   operands[7] = gen_rtx_REG (XFmode, REGNO (operands[0]));
3500   operands[8] = gen_rtx_REG (XFmode, REGNO (operands[1]));
3501   operands[9] = gen_rtx_REG (XFmode, REGNO (operands[2]));
3502   operands[10] = gen_rtx_REG (DFmode, REGNO (operands[3]));
3503   operands[11] = gen_rtx_REG (DFmode, REGNO (operands[5]));
3504   operands[12] = CONST1_RTX (XFmode);
3505 }
3506   [(set_attr "predicable" "no")])
3507
3508 (define_insn_and_split "divdf3_internal_thr"
3509   [(set (match_operand:DF 0 "fr_register_operand" "=&f")
3510         (div:DF (match_operand:DF 1 "fr_register_operand" "f")
3511                 (match_operand:DF 2 "fr_register_operand" "f")))
3512    (clobber (match_scratch:XF 3 "=&f"))
3513    (clobber (match_scratch:DF 4 "=f"))
3514    (clobber (match_scratch:BI 5 "=c"))]
3515   "TARGET_INLINE_FLOAT_DIV_THR"
3516   "#"
3517   "&& reload_completed"
3518   [(parallel [(set (match_dup 6) (div:XF (const_int 1) (match_dup 8)))
3519               (set (match_dup 5) (unspec:BI [(match_dup 7) (match_dup 8)]
3520                                             UNSPEC_FR_RECIP_APPROX))
3521               (use (const_int 1))])
3522    (cond_exec (ne (match_dup 5) (const_int 0))
3523      (parallel [(set (match_dup 3)
3524                      (minus:XF (match_dup 10)
3525                                (mult:XF (match_dup 8) (match_dup 6))))
3526                 (use (const_int 1))]))
3527    (cond_exec (ne (match_dup 5) (const_int 0))
3528      (parallel [(set (match_dup 6)
3529                      (plus:XF (mult:XF (match_dup 3) (match_dup 6))
3530                               (match_dup 6)))
3531                 (use (const_int 1))]))
3532    (cond_exec (ne (match_dup 5) (const_int 0))
3533      (parallel [(set (match_dup 3)
3534                      (mult:XF (match_dup 3) (match_dup 3)))
3535                 (use (const_int 1))]))
3536    (cond_exec (ne (match_dup 5) (const_int 0))
3537      (parallel [(set (match_dup 6)
3538                      (plus:XF (mult:XF (match_dup 3) (match_dup 6))
3539                               (match_dup 6)))
3540                 (use (const_int 1))]))
3541    (cond_exec (ne (match_dup 5) (const_int 0))
3542      (parallel [(set (match_dup 3)
3543                      (mult:XF (match_dup 3) (match_dup 3)))
3544                 (use (const_int 1))]))
3545    (cond_exec (ne (match_dup 5) (const_int 0))
3546      (parallel [(set (match_dup 6)
3547                      (plus:XF (mult:XF (match_dup 3) (match_dup 6))
3548                               (match_dup 6)))
3549                 (use (const_int 1))]))
3550    (cond_exec (ne (match_dup 5) (const_int 0))
3551      (parallel [(set (match_dup 9)
3552                      (float_truncate:DF
3553                        (mult:XF (match_dup 7) (match_dup 6))))
3554                 (use (const_int 1))]))
3555    (cond_exec (ne (match_dup 5) (const_int 0))
3556      (parallel [(set (match_dup 4)
3557                      (minus:DF (match_dup 1)
3558                                (mult:DF (match_dup 2) (match_dup 9))))
3559                 (use (const_int 1))]))
3560    (cond_exec (ne (match_dup 5) (const_int 0))
3561      (set (match_dup 0)
3562           (plus:DF (mult:DF (match_dup 4) (match_dup 0))
3563                             (match_dup 9))))
3564   ] 
3565 {
3566   operands[6] = gen_rtx_REG (XFmode, REGNO (operands[0]));
3567   operands[7] = gen_rtx_REG (XFmode, REGNO (operands[1]));
3568   operands[8] = gen_rtx_REG (XFmode, REGNO (operands[2]));
3569   operands[9] = gen_rtx_REG (DFmode, REGNO (operands[3]));
3570   operands[10] = CONST1_RTX (XFmode);
3571 }
3572   [(set_attr "predicable" "no")])
3573
3574 ;; Inline square root.
3575
3576 (define_expand "sqrtdf2"
3577   [(set (match_operand:DF 0 "fr_register_operand" "=&f")
3578         (sqrt:DF (match_operand:DF 1 "fr_register_operand" "f")))]
3579   "TARGET_INLINE_SQRT"
3580 {
3581   rtx insn;
3582   if (TARGET_INLINE_SQRT_LAT)
3583 #if 0
3584     insn = gen_sqrtdf2_internal_lat (operands[0], operands[1]);
3585 #else
3586     abort ();
3587 #endif
3588   else
3589     insn = gen_sqrtdf2_internal_thr (operands[0], operands[1]);
3590   emit_insn (insn);
3591   DONE;
3592 })
3593
3594 ;; Latency-optimized square root.
3595 ;; FIXME: Implement.
3596
3597 ;; Throughput-optimized square root.
3598
3599 (define_insn_and_split "sqrtdf2_internal_thr"
3600   [(set (match_operand:DF 0 "fr_register_operand" "=&f")
3601         (sqrt:DF (match_operand:DF 1 "fr_register_operand" "f")))
3602    ;; Register r2 in optimization guide.
3603    (clobber (match_scratch:DI 2 "=r"))
3604    ;; Register f8 in optimization guide
3605    (clobber (match_scratch:XF 3 "=&f"))
3606    ;; Register f9 in optimization guide
3607    (clobber (match_scratch:XF 4 "=&f"))
3608    ;; Register f10 in optimization guide
3609    (clobber (match_scratch:XF 5 "=&f"))
3610    ;; Register p6 in optimization guide.
3611    (clobber (match_scratch:BI 6 "=c"))]
3612   "TARGET_INLINE_SQRT_THR"
3613   "#"
3614   "&& reload_completed"
3615   [ ;; exponent of +1/2 in r2
3616     (set (match_dup 2) (const_int 65534))
3617     ;; +1/2 in f10
3618     (set (match_dup 5) 
3619          (unspec:XF [(match_dup 2)] UNSPEC_SETF_EXP))
3620     ;; Step 1
3621     ;; y0 = 1/sqrt(a) in f7
3622     (parallel [(set (match_dup 7)
3623                     (div:XF (const_int 1)
3624                             (sqrt:XF (match_dup 8))))
3625                (set (match_dup 6)
3626                     (unspec:BI [(match_dup 8)]
3627                                  UNSPEC_FR_SQRT_RECIP_APPROX))
3628                (use (const_int 0))])
3629     ;; Step 2
3630     ;; H0 = 1/2 * y0 in f8
3631     (cond_exec (ne (match_dup 6) (const_int 0))
3632       (parallel [(set (match_dup 3)
3633                       (plus:XF (mult:XF (match_dup 5) (match_dup 7))
3634                                (match_dup 9)))
3635                  (use (const_int 1))]))
3636     ;; Step 3
3637     ;; G0 = a * y0 in f7
3638     (cond_exec (ne (match_dup 6) (const_int 0))
3639       (parallel [(set (match_dup 7)
3640                       (plus:XF (mult:XF (match_dup 8) (match_dup 7))
3641                                (match_dup 9)))
3642                  (use (const_int 1))]))
3643     ;; Step 4
3644     ;; r0 = 1/2 - G0 * H0 in f9
3645     (cond_exec (ne (match_dup 6) (const_int 0))
3646       (parallel [(set (match_dup 4)
3647                       (minus:XF (match_dup 5)
3648                                 (mult:XF (match_dup 7) (match_dup 3))))
3649                  (use (const_int 1))]))
3650     ;; Step 5
3651     ;; H1 = H0 + r0 * H0 in f8
3652     (cond_exec (ne (match_dup 6) (const_int 0))
3653        (parallel [(set (match_dup 3)
3654                        (plus:XF (mult:XF (match_dup 4) (match_dup 3))
3655                                 (match_dup 3)))
3656                   (use (const_int 1))]))
3657     ;; Step 6
3658     ;; G1 = G0 + r0 * G0 in f7
3659     (cond_exec (ne (match_dup 6) (const_int 0))
3660        (parallel [(set (match_dup 7)
3661                        (plus:XF (mult:XF (match_dup 4) (match_dup 7))
3662                                 (match_dup 7)))
3663                   (use (const_int 1))]))
3664     ;; Step 7
3665     ;; r1 = 1/2 - G1 * H1 in f9
3666     (cond_exec (ne (match_dup 6) (const_int 0))
3667       (parallel [(set (match_dup 4)
3668                       (minus:XF (match_dup 5)
3669                                 (mult:XF (match_dup 7) (match_dup 3))))
3670                  (use (const_int 1))]))
3671     ;; Step 8
3672     ;; H2 = H1 + r1 * H1 in f8
3673     (cond_exec (ne (match_dup 6) (const_int 0))
3674        (parallel [(set (match_dup 3)
3675                        (plus:XF (mult:XF (match_dup 4) (match_dup 3))
3676                                 (match_dup 3)))
3677                   (use (const_int 1))]))
3678     ;; Step 9 
3679     ;; G2 = G1 + r1 * G1 in f7
3680     (cond_exec (ne (match_dup 6) (const_int 0))
3681        (parallel [(set (match_dup 7)
3682                        (plus:XF (mult:XF (match_dup 4) (match_dup 7))
3683                                 (match_dup 7)))
3684                   (use (const_int 1))]))
3685     ;; Step 10
3686     ;; d2 = a - G2 * G2 in f9
3687     (cond_exec (ne (match_dup 6) (const_int 0))
3688        (parallel [(set (match_dup 4)
3689                        (minus:XF (match_dup 8)
3690                                  (mult:XF (match_dup 7) (match_dup 7))))
3691                   (use (const_int 1))]))
3692     ;; Step 11
3693     ;; G3 = G2 + d2 * H2 in f7
3694     (cond_exec (ne (match_dup 6) (const_int 0))
3695        (parallel [(set (match_dup 7)
3696                        (plus:XF (mult:XF (match_dup 4) (match_dup 3))
3697                                 (match_dup 7)))
3698                   (use (const_int 1))]))
3699     ;; Step 12
3700     ;; d3 = a - G3 * G3 in f9
3701     (cond_exec (ne (match_dup 6) (const_int 0))
3702        (parallel [(set (match_dup 4)
3703                        (minus:XF (match_dup 8)
3704                                  (mult:XF (match_dup 7) (match_dup 7))))
3705                   (use (const_int 1))]))
3706     ;; Step 13
3707     ;; S = G3 + d3 * H2 in f7
3708     (cond_exec (ne (match_dup 6) (const_int 0))
3709        (parallel [(set (match_dup 0)
3710                        (float_truncate:DF
3711                          (plus:XF (mult:XF (match_dup 4) (match_dup 3))
3712                                   (match_dup 7))))
3713                   (use (const_int 0))]))]
3714 {
3715   /* Generate 82-bit versions of the input and output operands.  */
3716   operands[7] = gen_rtx_REG (XFmode, REGNO (operands[0]));
3717   operands[8] = gen_rtx_REG (XFmode, REGNO (operands[1]));
3718   /* Generate required floating-point constants.  */
3719   operands[9] = CONST0_RTX (XFmode);
3720 }
3721   [(set_attr "predicable" "no")])
3722 \f
3723 ;; ::::::::::::::::::::
3724 ;; ::
3725 ;; :: 80 bit floating point arithmetic
3726 ;; ::
3727 ;; ::::::::::::::::::::
3728
3729 (define_insn "addxf3"
3730   [(set (match_operand:XF 0 "fr_register_operand" "=f")
3731         (plus:XF (match_operand:XF 1 "xfreg_or_fp01_operand" "fG")
3732                  (match_operand:XF 2 "xfreg_or_fp01_operand" "fG")))]
3733   ""
3734   "fadd %0 = %F1, %F2"
3735   [(set_attr "itanium_class" "fmac")])
3736
3737 (define_insn "*addxf3_truncsf"
3738   [(set (match_operand:SF 0 "fr_register_operand" "=f")
3739         (float_truncate:SF
3740           (plus:XF (match_operand:XF 1 "xfreg_or_fp01_operand" "fG")
3741                    (match_operand:XF 2 "xfreg_or_fp01_operand" "fG"))))]
3742   ""
3743   "fadd.s %0 = %F1, %F2"
3744   [(set_attr "itanium_class" "fmac")])
3745
3746 (define_insn "*addxf3_truncdf"
3747   [(set (match_operand:DF 0 "fr_register_operand" "=f")
3748         (float_truncate:DF
3749           (plus:XF (match_operand:XF 1 "xfreg_or_fp01_operand" "fG")
3750                    (match_operand:XF 2 "xfreg_or_fp01_operand" "fG"))))]
3751   ""
3752   "fadd.d %0 = %F1, %F2"
3753   [(set_attr "itanium_class" "fmac")])
3754
3755 (define_insn "subxf3"
3756   [(set (match_operand:XF 0 "fr_register_operand" "=f")
3757         (minus:XF (match_operand:XF 1 "xfreg_or_fp01_operand" "fG")
3758                   (match_operand:XF 2 "xfreg_or_fp01_operand" "fG")))]
3759   ""
3760   "fsub %0 = %F1, %F2"
3761   [(set_attr "itanium_class" "fmac")])
3762
3763 (define_insn "*subxf3_truncsf"
3764   [(set (match_operand:SF 0 "fr_register_operand" "=f")
3765         (float_truncate:SF
3766           (minus:XF (match_operand:XF 1 "xfreg_or_fp01_operand" "fG")
3767                     (match_operand:XF 2 "xfreg_or_fp01_operand" "fG"))))]
3768   ""
3769   "fsub.s %0 = %F1, %F2"
3770   [(set_attr "itanium_class" "fmac")])
3771
3772 (define_insn "*subxf3_truncdf"
3773   [(set (match_operand:DF 0 "fr_register_operand" "=f")
3774         (float_truncate:DF
3775           (minus:XF (match_operand:XF 1 "xfreg_or_fp01_operand" "fG")
3776                     (match_operand:XF 2 "xfreg_or_fp01_operand" "fG"))))]
3777   ""
3778   "fsub.d %0 = %F1, %F2"
3779   [(set_attr "itanium_class" "fmac")])
3780
3781 (define_insn "mulxf3"
3782   [(set (match_operand:XF 0 "fr_register_operand" "=f")
3783         (mult:XF (match_operand:XF 1 "xfreg_or_fp01_operand" "fG")
3784                  (match_operand:XF 2 "xfreg_or_fp01_operand" "fG")))]
3785   ""
3786   "fmpy %0 = %F1, %F2"
3787   [(set_attr "itanium_class" "fmac")])
3788
3789 (define_insn "*mulxf3_truncsf"
3790   [(set (match_operand:SF 0 "fr_register_operand" "=f")
3791         (float_truncate:SF
3792           (mult:XF (match_operand:XF 1 "xfreg_or_fp01_operand" "fG")
3793                    (match_operand:XF 2 "xfreg_or_fp01_operand" "fG"))))]
3794   ""
3795   "fmpy.s %0 = %F1, %F2"
3796   [(set_attr "itanium_class" "fmac")])
3797
3798 (define_insn "*mulxf3_truncdf"
3799   [(set (match_operand:DF 0 "fr_register_operand" "=f")
3800         (float_truncate:DF
3801           (mult:XF (match_operand:XF 1 "xfreg_or_fp01_operand" "fG")
3802                    (match_operand:XF 2 "xfreg_or_fp01_operand" "fG"))))]
3803   ""
3804   "fmpy.d %0 = %F1, %F2"
3805   [(set_attr "itanium_class" "fmac")])
3806
3807 (define_insn "*mulxf3_alts"
3808   [(set (match_operand:XF 0 "fr_register_operand" "=f")
3809         (mult:XF (match_operand:XF 1 "xfreg_or_fp01_operand" "fG")
3810                  (match_operand:XF 2 "xfreg_or_fp01_operand" "fG")))
3811    (use (match_operand:SI 3 "const_int_operand" ""))]
3812   ""
3813   "fmpy.s%3 %0 = %F1, %F2"
3814   [(set_attr "itanium_class" "fmac")])
3815
3816 (define_insn "*mulxf3_truncsf_alts"
3817   [(set (match_operand:SF 0 "fr_register_operand" "=f")
3818         (float_truncate:SF
3819           (mult:XF (match_operand:XF 1 "xfreg_or_fp01_operand" "fG")
3820                    (match_operand:XF 2 "xfreg_or_fp01_operand" "fG"))))
3821    (use (match_operand:SI 3 "const_int_operand" ""))]
3822   ""
3823   "fmpy.s.s%3 %0 = %F1, %F2"
3824   [(set_attr "itanium_class" "fmac")])
3825
3826 (define_insn "*mulxf3_truncdf_alts"
3827   [(set (match_operand:DF 0 "fr_register_operand" "=f")
3828         (float_truncate:DF
3829           (mult:XF (match_operand:XF 1 "xfreg_or_fp01_operand" "fG")
3830                    (match_operand:XF 2 "xfreg_or_fp01_operand" "fG"))))
3831    (use (match_operand:SI 3 "const_int_operand" ""))]
3832   ""
3833   "fmpy.d.s%3 %0 = %F1, %F2"
3834   [(set_attr "itanium_class" "fmac")])
3835
3836 (define_insn "absxf2"
3837   [(set (match_operand:XF 0 "fr_register_operand" "=f")
3838         (abs:XF (match_operand:XF 1 "xfreg_or_fp01_operand" "fG")))]
3839   ""
3840   "fabs %0 = %F1"
3841   [(set_attr "itanium_class" "fmisc")])
3842
3843 (define_insn "negxf2"
3844   [(set (match_operand:XF 0 "fr_register_operand" "=f")
3845         (neg:XF (match_operand:XF 1 "xfreg_or_fp01_operand" "fG")))]
3846   ""
3847   "fneg %0 = %F1"
3848   [(set_attr "itanium_class" "fmisc")])
3849
3850 (define_insn "*nabsxf2"
3851   [(set (match_operand:XF 0 "fr_register_operand" "=f")
3852         (neg:XF (abs:XF (match_operand:XF 1 "xfreg_or_fp01_operand" "fG"))))]
3853   ""
3854   "fnegabs %0 = %F1"
3855   [(set_attr "itanium_class" "fmisc")])
3856
3857 (define_insn "minxf3"
3858   [(set (match_operand:XF 0 "fr_register_operand" "=f")
3859         (smin:XF (match_operand:XF 1 "xfreg_or_fp01_operand" "fG")
3860                  (match_operand:XF 2 "xfreg_or_fp01_operand" "fG")))]
3861   ""
3862   "fmin %0 = %F1, %F2"
3863   [(set_attr "itanium_class" "fmisc")])
3864
3865 (define_insn "maxxf3"
3866   [(set (match_operand:XF 0 "fr_register_operand" "=f")
3867         (smax:XF (match_operand:XF 1 "xfreg_or_fp01_operand" "fG")
3868                  (match_operand:XF 2 "xfreg_or_fp01_operand" "fG")))]
3869   ""
3870   "fmax %0 = %F1, %F2"
3871   [(set_attr "itanium_class" "fmisc")])
3872
3873 (define_insn "*maddxf4"
3874   [(set (match_operand:XF 0 "fr_register_operand" "=f")
3875         (plus:XF (mult:XF (match_operand:XF 1 "xfreg_or_fp01_operand" "fG")
3876                           (match_operand:XF 2 "xfreg_or_fp01_operand" "fG"))
3877                  (match_operand:XF 3 "xfreg_or_fp01_operand" "fG")))]
3878   ""
3879   "fma %0 = %F1, %F2, %F3"
3880   [(set_attr "itanium_class" "fmac")])
3881
3882 (define_insn "*maddxf4_truncsf"
3883   [(set (match_operand:SF 0 "fr_register_operand" "=f")
3884         (float_truncate:SF
3885           (plus:XF (mult:XF (match_operand:XF 1 "xfreg_or_fp01_operand" "fG")
3886                             (match_operand:XF 2 "xfreg_or_fp01_operand" "fG"))
3887                    (match_operand:XF 3 "xfreg_or_fp01_operand" "fG"))))]
3888   ""
3889   "fma.s %0 = %F1, %F2, %F3"
3890   [(set_attr "itanium_class" "fmac")])
3891
3892 (define_insn "*maddxf4_truncdf"
3893   [(set (match_operand:DF 0 "fr_register_operand" "=f")
3894         (float_truncate:DF
3895           (plus:XF (mult:XF (match_operand:XF 1 "xfreg_or_fp01_operand" "fG")
3896                             (match_operand:XF 2 "xfreg_or_fp01_operand" "fG"))
3897                    (match_operand:XF 3 "xfreg_or_fp01_operand" "fG"))))]
3898   ""
3899   "fma.d %0 = %F1, %F2, %F3"
3900   [(set_attr "itanium_class" "fmac")])
3901
3902 (define_insn "*maddxf4_alts"
3903   [(set (match_operand:XF 0 "fr_register_operand" "=f")
3904         (plus:XF (mult:XF (match_operand:XF 1 "xfreg_or_fp01_operand" "fG")
3905                           (match_operand:XF 2 "xfreg_or_fp01_operand" "fG"))
3906                  (match_operand:XF 3 "xfreg_or_fp01_operand" "fG")))
3907    (use (match_operand:SI 4 "const_int_operand" ""))]
3908   ""
3909   "fma.s%4 %0 = %F1, %F2, %F3"
3910   [(set_attr "itanium_class" "fmac")])
3911
3912 (define_insn "*maddxf4_alts_truncsf"
3913   [(set (match_operand:SF 0 "fr_register_operand" "=f")
3914         (float_truncate:SF
3915           (plus:XF (mult:XF (match_operand:XF 1 "xfreg_or_fp01_operand" "fG")
3916                             (match_operand:XF 2 "xfreg_or_fp01_operand" "fG"))
3917                    (match_operand:XF 3 "xfreg_or_fp01_operand" "fG"))))
3918    (use (match_operand:SI 4 "const_int_operand" ""))]
3919   ""
3920   "fma.s.s%4 %0 = %F1, %F2, %F3"
3921   [(set_attr "itanium_class" "fmac")])
3922
3923 (define_insn "*maddxf4_alts_truncdf"
3924   [(set (match_operand:DF 0 "fr_register_operand" "=f")
3925         (float_truncate:DF
3926           (plus:XF (mult:XF (match_operand:XF 1 "xfreg_or_fp01_operand" "fG")
3927                             (match_operand:XF 2 "xfreg_or_fp01_operand" "fG"))
3928                    (match_operand:XF 3 "xfreg_or_fp01_operand" "fG"))))
3929    (use (match_operand:SI 4 "const_int_operand" ""))]
3930   ""
3931   "fma.d.s%4 %0 = %F1, %F2, %F3"
3932   [(set_attr "itanium_class" "fmac")])
3933
3934 (define_insn "*msubxf4"
3935   [(set (match_operand:XF 0 "fr_register_operand" "=f")
3936         (minus:XF (mult:XF (match_operand:XF 1 "xfreg_or_fp01_operand" "fG")
3937                            (match_operand:XF 2 "xfreg_or_fp01_operand" "fG"))
3938                   (match_operand:XF 3 "xfreg_or_fp01_operand" "fG")))]
3939   ""
3940   "fms %0 = %F1, %F2, %F3"
3941   [(set_attr "itanium_class" "fmac")])
3942
3943 (define_insn "*msubxf4_truncsf"
3944   [(set (match_operand:SF 0 "fr_register_operand" "=f")
3945         (float_truncate:SF
3946           (minus:XF (mult:XF (match_operand:XF 1 "xfreg_or_fp01_operand" "fG")
3947                              (match_operand:XF 2 "xfreg_or_fp01_operand" "fG"))
3948                     (match_operand:XF 3 "xfreg_or_fp01_operand" "fG"))))]
3949   ""
3950   "fms.s %0 = %F1, %F2, %F3"
3951   [(set_attr "itanium_class" "fmac")])
3952
3953 (define_insn "*msubxf4_truncdf"
3954   [(set (match_operand:DF 0 "fr_register_operand" "=f")
3955         (float_truncate:DF
3956           (minus:XF (mult:XF (match_operand:XF 1 "xfreg_or_fp01_operand" "fG")
3957                              (match_operand:XF 2 "xfreg_or_fp01_operand" "fG"))
3958                     (match_operand:XF 3 "xfreg_or_fp01_operand" "fG"))))]
3959   ""
3960   "fms.d %0 = %F1, %F2, %F3"
3961   [(set_attr "itanium_class" "fmac")])
3962
3963 (define_insn "*nmulxf3"
3964   [(set (match_operand:XF 0 "fr_register_operand" "=f")
3965         (neg:XF (mult:XF (match_operand:XF 1 "xfreg_or_fp01_operand" "fG")
3966                          (match_operand:XF 2 "xfreg_or_fp01_operand" "fG"))))]
3967   ""
3968   "fnmpy %0 = %F1, %F2"
3969   [(set_attr "itanium_class" "fmac")])
3970
3971 (define_insn "*nmulxf3_truncsf"
3972   [(set (match_operand:SF 0 "fr_register_operand" "=f")
3973         (float_truncate:SF
3974           (neg:XF (mult:XF
3975                     (match_operand:XF 1 "xfreg_or_fp01_operand" "fG")
3976                     (match_operand:XF 2 "xfreg_or_fp01_operand" "fG")))))]
3977   ""
3978   "fnmpy.s %0 = %F1, %F2"
3979   [(set_attr "itanium_class" "fmac")])
3980
3981 (define_insn "*nmulxf3_truncdf"
3982   [(set (match_operand:DF 0 "fr_register_operand" "=f")
3983         (float_truncate:DF
3984           (neg:XF (mult:XF
3985                     (match_operand:XF 1 "xfreg_or_fp01_operand" "fG")
3986                     (match_operand:XF 2 "xfreg_or_fp01_operand" "fG")))))]
3987   ""
3988   "fnmpy.d %0 = %F1, %F2"
3989   [(set_attr "itanium_class" "fmac")])
3990
3991 (define_insn "*nmaddxf4"
3992   [(set (match_operand:XF 0 "fr_register_operand" "=f")
3993         (minus:XF (match_operand:XF 3 "xfreg_or_fp01_operand" "fG")
3994                   (mult:XF (match_operand:XF 1 "xfreg_or_fp01_operand" "fG")
3995                            (match_operand:XF 2 "xfreg_or_fp01_operand" "fG")
3996    )))]
3997   ""
3998   "fnma %0 = %F1, %F2, %F3"
3999   [(set_attr "itanium_class" "fmac")])
4000
4001 (define_insn "*nmaddxf4_truncsf"
4002   [(set (match_operand:SF 0 "fr_register_operand" "=f")
4003         (float_truncate:SF
4004           (minus:XF (match_operand:XF 3 "xfreg_or_fp01_operand" "fG") 
4005                     (mult:XF (match_operand:XF 1 "xfreg_or_fp01_operand" "fG")
4006                              (match_operand:XF 2 "xfreg_or_fp01_operand" "fG")
4007    ))))]
4008   ""
4009   "fnma.s %0 = %F1, %F2, %F3"
4010   [(set_attr "itanium_class" "fmac")])
4011
4012 (define_insn "*nmaddxf4_truncdf"
4013   [(set (match_operand:DF 0 "fr_register_operand" "=f")
4014         (float_truncate:DF
4015           (minus:XF (match_operand:XF 3 "xfreg_or_fp01_operand" "fG") 
4016                     (mult:XF (match_operand:XF 1 "xfreg_or_fp01_operand" "fG")
4017                              (match_operand:XF 2 "xfreg_or_fp01_operand" "fG")
4018    ))))]
4019   ""
4020   "fnma.d %0 = %F1, %F2, %F3"
4021   [(set_attr "itanium_class" "fmac")])
4022
4023 (define_insn "*nmaddxf4_alts"
4024   [(set (match_operand:XF 0 "fr_register_operand" "=f")
4025         (minus:XF (match_operand:XF 3 "xfreg_or_fp01_operand" "fG")
4026                   (mult:XF (match_operand:XF 1 "xfreg_or_fp01_operand" "fG")
4027                            (match_operand:XF 2 "xfreg_or_fp01_operand" "fG")
4028    )))
4029    (use (match_operand:SI 4 "const_int_operand" ""))]
4030   ""
4031   "fnma.s%4 %0 = %F1, %F2, %F3"
4032   [(set_attr "itanium_class" "fmac")])
4033
4034 (define_insn "*nmaddxf4_truncsf_alts"
4035   [(set (match_operand:SF 0 "fr_register_operand" "=f")
4036         (float_truncate:SF
4037           (minus:XF (match_operand:XF 3 "xfreg_or_fp01_operand" "fG") 
4038                     (mult:XF (match_operand:XF 1 "xfreg_or_fp01_operand" "fG")
4039                              (match_operand:XF 2 "xfreg_or_fp01_operand" "fG")
4040    ))))
4041    (use (match_operand:SI 4 "const_int_operand" ""))]
4042   ""
4043   "fnma.s.s%4 %0 = %F1, %F2, %F3"
4044   [(set_attr "itanium_class" "fmac")])
4045
4046 (define_insn "*nmaddxf4_truncdf_alts"
4047   [(set (match_operand:DF 0 "fr_register_operand" "=f")
4048         (float_truncate:DF
4049           (minus:XF (match_operand:XF 3 "xfreg_or_fp01_operand" "fG") 
4050                     (mult:XF (match_operand:XF 1 "xfreg_or_fp01_operand" "fG")
4051                              (match_operand:XF 2 "xfreg_or_fp01_operand" "fG")
4052    ))))
4053    (use (match_operand:SI 4 "const_int_operand" ""))]
4054   ""
4055   "fnma.d.s%4 %0 = %F1, %F2, %F3"
4056   [(set_attr "itanium_class" "fmac")])
4057
4058 (define_expand "divxf3"
4059   [(set (match_operand:XF 0 "fr_register_operand" "")
4060         (div:XF (match_operand:XF 1 "fr_register_operand" "")
4061                 (match_operand:XF 2 "fr_register_operand" "")))]
4062   "TARGET_INLINE_FLOAT_DIV"
4063 {
4064   rtx insn;
4065   if (TARGET_INLINE_FLOAT_DIV_LAT)
4066     insn = gen_divxf3_internal_lat (operands[0], operands[1], operands[2]);
4067   else
4068     insn = gen_divxf3_internal_thr (operands[0], operands[1], operands[2]);
4069   emit_insn (insn);
4070   DONE;
4071 })
4072
4073 (define_insn_and_split "divxf3_internal_lat"
4074   [(set (match_operand:XF 0 "fr_register_operand" "=&f")
4075         (div:XF (match_operand:XF 1 "fr_register_operand" "f")
4076                 (match_operand:XF 2 "fr_register_operand" "f")))
4077    (clobber (match_scratch:XF 3 "=&f"))
4078    (clobber (match_scratch:XF 4 "=&f"))
4079    (clobber (match_scratch:XF 5 "=&f"))
4080    (clobber (match_scratch:XF 6 "=&f"))
4081    (clobber (match_scratch:BI 7 "=c"))]
4082   "TARGET_INLINE_FLOAT_DIV_LAT"
4083   "#"
4084   "&& reload_completed"
4085   [(parallel [(set (match_dup 0) (div:XF (const_int 1) (match_dup 2)))
4086               (set (match_dup 7) (unspec:BI [(match_dup 1) (match_dup 2)]
4087                                             UNSPEC_FR_RECIP_APPROX))
4088               (use (const_int 1))])
4089    (cond_exec (ne (match_dup 7) (const_int 0))
4090      (parallel [(set (match_dup 3)
4091                      (minus:XF (match_dup 8)
4092                                (mult:XF (match_dup 2) (match_dup 0))))
4093                 (use (const_int 1))]))
4094    (cond_exec (ne (match_dup 7) (const_int 0))
4095      (parallel [(set (match_dup 4) (mult:XF (match_dup 1) (match_dup 0)))
4096                 (use (const_int 1))]))
4097    (cond_exec (ne (match_dup 7) (const_int 0))
4098      (parallel [(set (match_dup 5) (mult:XF (match_dup 3) (match_dup 3)))
4099                 (use (const_int 1))]))
4100    (cond_exec (ne (match_dup 7) (const_int 0))
4101      (parallel [(set (match_dup 6)
4102                      (plus:XF (mult:XF (match_dup 3) (match_dup 3))
4103                               (match_dup 3)))
4104                 (use (const_int 1))]))
4105    (cond_exec (ne (match_dup 7) (const_int 0))
4106      (parallel [(set (match_dup 3)
4107                      (plus:XF (mult:XF (match_dup 5) (match_dup 5))
4108                               (match_dup 3)))
4109                 (use (const_int 1))]))
4110    (cond_exec (ne (match_dup 7) (const_int 0))
4111      (parallel [(set (match_dup 5)
4112                      (plus:XF (mult:XF (match_dup 6) (match_dup 0))
4113                               (match_dup 0)))
4114                 (use (const_int 1))]))
4115    (cond_exec (ne (match_dup 7) (const_int 0))
4116      (parallel [(set (match_dup 0)
4117                      (plus:XF (mult:XF (match_dup 5) (match_dup 3))
4118                               (match_dup 0)))
4119                 (use (const_int 1))]))
4120    (cond_exec (ne (match_dup 7) (const_int 0))
4121      (parallel [(set (match_dup 4)
4122                      (minus:XF (match_dup 1)
4123                                (mult:XF (match_dup 2) (match_dup 4))))
4124                 (use (const_int 1))]))
4125    (cond_exec (ne (match_dup 7) (const_int 0))
4126      (parallel [(set (match_dup 3)
4127                      (plus:XF (mult:XF (match_dup 3) (match_dup 0))
4128                               (match_dup 4)))
4129                 (use (const_int 1))]))
4130    (cond_exec (ne (match_dup 7) (const_int 0))
4131      (parallel [(set (match_dup 5)
4132                      (minus:XF (match_dup 8)
4133                                (mult:XF (match_dup 2) (match_dup 0))))
4134                 (use (const_int 1))]))
4135    (cond_exec (ne (match_dup 7) (const_int 0))
4136      (parallel [(set (match_dup 0)
4137                      (plus:XF (mult:XF (match_dup 4) (match_dup 0))
4138                               (match_dup 0)))
4139                 (use (const_int 1))]))
4140    (cond_exec (ne (match_dup 7) (const_int 0))
4141      (parallel [(set (match_dup 4)
4142                      (minus:XF (match_dup 1)
4143                                (mult:XF (match_dup 2) (match_dup 3))))
4144                 (use (const_int 1))]))
4145    (cond_exec (ne (match_dup 7) (const_int 0))
4146      (set (match_dup 0)
4147           (plus:XF (mult:XF (match_dup 4) (match_dup 0))
4148                    (match_dup 3))))
4149   ] 
4150   "operands[8] = CONST1_RTX (XFmode);"
4151   [(set_attr "predicable" "no")])
4152
4153 (define_insn_and_split "divxf3_internal_thr"
4154   [(set (match_operand:XF 0 "fr_register_operand" "=&f")
4155         (div:XF (match_operand:XF 1 "fr_register_operand" "f")
4156                 (match_operand:XF 2 "fr_register_operand" "f")))
4157    (clobber (match_scratch:XF 3 "=&f"))
4158    (clobber (match_scratch:XF 4 "=&f"))
4159    (clobber (match_scratch:BI 5 "=c"))]
4160   "TARGET_INLINE_FLOAT_DIV_THR"
4161   "#"
4162   "&& reload_completed"
4163   [(parallel [(set (match_dup 0) (div:XF (const_int 1) (match_dup 2)))
4164               (set (match_dup 5) (unspec:BI [(match_dup 1) (match_dup 2)]
4165                                             UNSPEC_FR_RECIP_APPROX))
4166               (use (const_int 1))])
4167    (cond_exec (ne (match_dup 5) (const_int 0))
4168      (parallel [(set (match_dup 3)
4169                      (minus:XF (match_dup 6)
4170                                (mult:XF (match_dup 2) (match_dup 0))))
4171                 (use (const_int 1))]))
4172    (cond_exec (ne (match_dup 5) (const_int 0))
4173      (parallel [(set (match_dup 4)
4174                      (plus:XF (mult:XF (match_dup 3) (match_dup 0))
4175                               (match_dup 0)))
4176                 (use (const_int 1))]))
4177    (cond_exec (ne (match_dup 5) (const_int 0))
4178      (parallel [(set (match_dup 3) (mult:XF (match_dup 3) (match_dup 3)))
4179                 (use (const_int 1))]))
4180    (cond_exec (ne (match_dup 5) (const_int 0))
4181      (parallel [(set (match_dup 3)
4182                      (plus:XF (mult:XF (match_dup 3) (match_dup 4))
4183                               (match_dup 4)))
4184                 (use (const_int 1))]))
4185    (cond_exec (ne (match_dup 5) (const_int 0))
4186      (parallel [(set (match_dup 4) (mult:XF (match_dup 1) (match_dup 0)))
4187                 (use (const_int 1))]))
4188    (cond_exec (ne (match_dup 5) (const_int 0))
4189      (parallel [(set (match_dup 0)
4190                      (minus:XF (match_dup 6)
4191                                (mult:XF (match_dup 2) (match_dup 3))))
4192                 (use (const_int 1))]))
4193    (cond_exec (ne (match_dup 5) (const_int 0))
4194      (parallel [(set (match_dup 0)
4195                      (plus:XF (mult:XF (match_dup 0) (match_dup 3))
4196                               (match_dup 3)))
4197                 (use (const_int 1))]))
4198    (cond_exec (ne (match_dup 5) (const_int 0))
4199      (parallel [(set (match_dup 3)
4200                      (minus:XF (match_dup 1)
4201                                (mult:XF (match_dup 2) (match_dup 4))))
4202                 (use (const_int 1))]))
4203    (cond_exec (ne (match_dup 5) (const_int 0))
4204      (parallel [(set (match_dup 3)
4205                      (plus:XF (mult:XF (match_dup 3) (match_dup 0))
4206                               (match_dup 4)))
4207                 (use (const_int 1))]))
4208    (cond_exec (ne (match_dup 5) (const_int 0))
4209      (parallel [(set (match_dup 4)
4210                      (minus:XF (match_dup 6)
4211                                (mult:XF (match_dup 2) (match_dup 0))))
4212                 (use (const_int 1))]))
4213    (cond_exec (ne (match_dup 5) (const_int 0))
4214      (parallel [(set (match_dup 0)
4215                      (plus:XF (mult:XF (match_dup 4) (match_dup 0))
4216                               (match_dup 0)))
4217                 (use (const_int 1))]))
4218    (cond_exec (ne (match_dup 5) (const_int 0))
4219      (parallel [(set (match_dup 4)
4220                      (minus:XF (match_dup 1)
4221                                (mult:XF (match_dup 2) (match_dup 3))))
4222                 (use (const_int 1))]))
4223    (cond_exec (ne (match_dup 5) (const_int 0))
4224      (set (match_dup 0)
4225           (plus:XF (mult:XF (match_dup 4) (match_dup 0))
4226                    (match_dup 3))))
4227   ] 
4228   "operands[6] = CONST1_RTX (XFmode);"
4229   [(set_attr "predicable" "no")])
4230
4231 ;; Inline square root.
4232
4233 (define_expand "sqrtxf2"
4234   [(set (match_operand:XF 0 "fr_register_operand" "=&f")
4235         (sqrt:XF (match_operand:XF 1 "fr_register_operand" "f")))]
4236   "TARGET_INLINE_SQRT"
4237 {
4238   rtx insn;
4239   if (TARGET_INLINE_SQRT_LAT)
4240 #if 0
4241     insn = gen_sqrtxf2_internal_lat (operands[0], operands[1]);
4242 #else
4243     abort ();
4244 #endif
4245   else
4246     insn = gen_sqrtxf2_internal_thr (operands[0], operands[1]);
4247   emit_insn (insn);
4248   DONE;
4249 })
4250
4251 ;; Latency-optimized square root.
4252 ;; FIXME: Implement.
4253
4254 ;; Throughput-optimized square root.
4255
4256 (define_insn_and_split "sqrtxf2_internal_thr"
4257   [(set (match_operand:XF 0 "fr_register_operand" "=&f")
4258         (sqrt:XF (match_operand:XF 1 "fr_register_operand" "f")))
4259    ;; Register r2 in optimization guide.
4260    (clobber (match_scratch:DI 2 "=r"))
4261    ;; Register f8 in optimization guide
4262    (clobber (match_scratch:XF 3 "=&f"))
4263    ;; Register f9 in optimization guide
4264    (clobber (match_scratch:XF 4 "=&f"))
4265    ;; Register f10 in optimization guide
4266    (clobber (match_scratch:XF 5 "=&f"))
4267    ;; Register f11 in optimization guide
4268    (clobber (match_scratch:XF 6 "=&f"))
4269    ;; Register p6 in optimization guide.
4270    (clobber (match_scratch:BI 7 "=c"))]
4271   "TARGET_INLINE_SQRT_THR"
4272   "#"
4273   "&& reload_completed"
4274   [ ;; exponent of +1/2 in r2
4275     (set (match_dup 2) (const_int 65534))
4276     ;; +1/2 in f8.  The Intel manual mistakenly specifies f10.
4277     (set (match_dup 3) 
4278          (unspec:XF [(match_dup 2)] UNSPEC_SETF_EXP))
4279     ;; Step 1
4280     ;; y0 = 1/sqrt(a) in f7
4281     (parallel [(set (match_dup 8)
4282                     (div:XF (const_int 1)
4283                             (sqrt:XF (match_dup 9))))
4284                (set (match_dup 7)
4285                     (unspec:BI [(match_dup 9)]
4286                                  UNSPEC_FR_SQRT_RECIP_APPROX))
4287                (use (const_int 0))])
4288     ;; Step 2
4289     ;; H0 = 1/2 * y0 in f9
4290     (cond_exec (ne (match_dup 7) (const_int 0))
4291       (parallel [(set (match_dup 4)
4292                       (plus:XF (mult:XF (match_dup 3) (match_dup 8))
4293                                (match_dup 10)))
4294                  (use (const_int 1))]))
4295     ;; Step 3
4296     ;; S0 = a * y0 in f7
4297     (cond_exec (ne (match_dup 7) (const_int 0))
4298       (parallel [(set (match_dup 8)
4299                       (plus:XF (mult:XF (match_dup 9) (match_dup 8))
4300                                (match_dup 10)))
4301                  (use (const_int 1))]))
4302     ;; Step 4
4303     ;; d0 = 1/2 - S0 * H0 in f10
4304     (cond_exec (ne (match_dup 7) (const_int 0))
4305       (parallel [(set (match_dup 5)
4306                       (minus:XF (match_dup 3)
4307                                 (mult:XF (match_dup 8) (match_dup 4))))
4308                  (use (const_int 1))]))
4309     ;; Step 5
4310     ;; H1 = H0 + d0 * H0 in f9
4311     (cond_exec (ne (match_dup 7) (const_int 0))
4312        (parallel [(set (match_dup 4)
4313                        (plus:XF (mult:XF (match_dup 5) (match_dup 4))
4314                                 (match_dup 4)))
4315                   (use (const_int 1))]))
4316     ;; Step 6
4317     ;; S1 = S0 + d0 * S0 in f7
4318     (cond_exec (ne (match_dup 7) (const_int 0))
4319        (parallel [(set (match_dup 8)
4320                        (plus:XF (mult:XF (match_dup 5) (match_dup 8))
4321                                 (match_dup 8)))
4322                   (use (const_int 1))]))
4323     ;; Step 7
4324     ;; d1 = 1/2 - S1 * H1 in f10
4325     (cond_exec (ne (match_dup 7) (const_int 0))
4326       (parallel [(set (match_dup 5)
4327                       (minus:XF (match_dup 3)
4328                                 (mult:XF (match_dup 8) (match_dup 4))))
4329                  (use (const_int 1))]))
4330     ;; Step 8
4331     ;; H2 = H1 + d1 * H1 in f9
4332     (cond_exec (ne (match_dup 7) (const_int 0))
4333        (parallel [(set (match_dup 4)
4334                        (plus:XF (mult:XF (match_dup 5) (match_dup 4))
4335                                 (match_dup 4)))
4336                   (use (const_int 1))]))
4337     ;; Step 9 
4338     ;; S2 = S1 + d1 * S1 in f7
4339     (cond_exec (ne (match_dup 7) (const_int 0))
4340        (parallel [(set (match_dup 8)
4341                        (plus:XF (mult:XF (match_dup 5) (match_dup 8))
4342                                 (match_dup 8)))
4343                   (use (const_int 1))]))
4344     ;; Step 10
4345     ;; d2 = 1/2 - S2 * H2 in f10
4346     (cond_exec (ne (match_dup 7) (const_int 0))
4347        (parallel [(set (match_dup 5)
4348                        (minus:XF (match_dup 3)
4349                                  (mult:XF (match_dup 8) (match_dup 4))))
4350                   (use (const_int 1))]))
4351     ;; Step 11
4352     ;; e2 = a - S2 * S2 in f8
4353     (cond_exec (ne (match_dup 7) (const_int 0))
4354        (parallel [(set (match_dup 3)
4355                        (minus:XF (match_dup 9)
4356                                  (mult:XF (match_dup 8) (match_dup 8))))
4357                   (use (const_int 1))]))
4358     ;; Step 12
4359     ;; S3 = S2 + e2 * H2 in f7
4360     (cond_exec (ne (match_dup 7) (const_int 0))
4361        (parallel [(set (match_dup 8)
4362                        (plus:XF (mult:XF (match_dup 3) (match_dup 4))
4363                                 (match_dup 8)))
4364                   (use (const_int 1))]))
4365     ;; Step 13
4366     ;; H3 = H2 + d2 * H2 in f9
4367     (cond_exec (ne (match_dup 7) (const_int 0))
4368        (parallel [(set (match_dup 4)
4369                        (plus:XF (mult:XF (match_dup 5) (match_dup 4))
4370                                 (match_dup 4)))
4371                   (use (const_int 1))]))
4372     ;; Step 14
4373     ;; e3 = a - S3 * S3 in f8
4374     (cond_exec (ne (match_dup 7) (const_int 0))
4375        (parallel [(set (match_dup 3)
4376                        (minus:XF (match_dup 9)
4377                                  (mult:XF (match_dup 8) (match_dup 8))))
4378                   (use (const_int 1))]))
4379     ;; Step 15
4380     ;; S = S3 + e3 * H3 in f7
4381     (cond_exec (ne (match_dup 7) (const_int 0))
4382        (parallel [(set (match_dup 0)
4383                        (plus:XF (mult:XF (match_dup 3) (match_dup 4))
4384                                 (match_dup 8)))
4385                   (use (const_int 0))]))]
4386 {
4387   /* Generate 82-bit versions of the input and output operands.  */
4388   operands[8] = gen_rtx_REG (XFmode, REGNO (operands[0]));
4389   operands[9] = gen_rtx_REG (XFmode, REGNO (operands[1]));
4390   /* Generate required floating-point constants.  */
4391   operands[10] = CONST0_RTX (XFmode);
4392 }
4393   [(set_attr "predicable" "no")])
4394
4395 ;; ??? frcpa works like cmp.foo.unc.
4396
4397 (define_insn "*recip_approx"
4398   [(set (match_operand:XF 0 "fr_register_operand" "=f")
4399         (div:XF (const_int 1)
4400                 (match_operand:XF 3 "fr_register_operand" "f")))
4401    (set (match_operand:BI 1 "register_operand" "=c")
4402         (unspec:BI [(match_operand:XF 2 "fr_register_operand" "f")
4403                     (match_dup 3)] UNSPEC_FR_RECIP_APPROX))
4404    (use (match_operand:SI 4 "const_int_operand" ""))]
4405   ""
4406   "frcpa.s%4 %0, %1 = %2, %3"
4407   [(set_attr "itanium_class" "fmisc")
4408    (set_attr "predicable" "no")])
4409 \f
4410 ;; ::::::::::::::::::::
4411 ;; ::
4412 ;; :: 32 bit Integer Shifts and Rotates
4413 ;; ::
4414 ;; ::::::::::::::::::::
4415
4416 (define_expand "ashlsi3"
4417   [(set (match_operand:SI 0 "gr_register_operand" "")
4418         (ashift:SI (match_operand:SI 1 "gr_register_operand" "")
4419                    (match_operand:SI 2 "gr_reg_or_5bit_operand" "")))]
4420   ""
4421 {
4422   if (GET_CODE (operands[2]) != CONST_INT)
4423     {
4424       /* Why oh why didn't Intel arrange for SHIFT_COUNT_TRUNCATED?  Now
4425          we've got to get rid of stray bits outside the SImode register.  */
4426       rtx subshift = gen_reg_rtx (DImode);
4427       emit_insn (gen_zero_extendsidi2 (subshift, operands[2]));
4428       operands[2] = subshift;
4429     }
4430 })
4431
4432 (define_insn "*ashlsi3_internal"
4433   [(set (match_operand:SI 0 "gr_register_operand" "=r,r,r")
4434         (ashift:SI (match_operand:SI 1 "gr_register_operand" "r,r,r")
4435                    (match_operand:DI 2 "gr_reg_or_5bit_operand" "R,n,r")))]
4436   ""
4437   "@
4438    shladd %0 = %1, %2, r0
4439    dep.z %0 = %1, %2, %E2
4440    shl %0 = %1, %2"
4441   [(set_attr "itanium_class" "ialu,ishf,mmshf")])
4442
4443 (define_expand "ashrsi3"
4444   [(set (match_operand:SI 0 "gr_register_operand" "")
4445         (ashiftrt:SI (match_operand:SI 1 "gr_register_operand" "")
4446                      (match_operand:SI 2 "gr_reg_or_5bit_operand" "")))]
4447   ""
4448 {
4449   rtx subtarget = gen_reg_rtx (DImode);
4450   if (GET_CODE (operands[2]) == CONST_INT)
4451     emit_insn (gen_extv (subtarget, gen_lowpart (DImode, operands[1]),
4452                          GEN_INT (32 - INTVAL (operands[2])), operands[2]));
4453   else
4454     {
4455       rtx subshift = gen_reg_rtx (DImode);
4456       emit_insn (gen_extendsidi2 (subtarget, operands[1]));
4457       emit_insn (gen_zero_extendsidi2 (subshift, operands[2]));
4458       emit_insn (gen_ashrdi3 (subtarget, subtarget, subshift));
4459     }
4460   emit_move_insn (gen_lowpart (DImode, operands[0]), subtarget);
4461   DONE;
4462 })
4463
4464 (define_expand "lshrsi3"
4465   [(set (match_operand:SI 0 "gr_register_operand" "")
4466         (lshiftrt:SI (match_operand:SI 1 "gr_register_operand" "")
4467                      (match_operand:SI 2 "gr_reg_or_5bit_operand" "")))]
4468   ""
4469 {
4470   rtx subtarget = gen_reg_rtx (DImode);
4471   if (GET_CODE (operands[2]) == CONST_INT)
4472     emit_insn (gen_extzv (subtarget, gen_lowpart (DImode, operands[1]),
4473                           GEN_INT (32 - INTVAL (operands[2])), operands[2]));
4474   else
4475     {
4476       rtx subshift = gen_reg_rtx (DImode);
4477       emit_insn (gen_zero_extendsidi2 (subtarget, operands[1]));
4478       emit_insn (gen_zero_extendsidi2 (subshift, operands[2]));
4479       emit_insn (gen_lshrdi3 (subtarget, subtarget, subshift));
4480     }
4481   emit_move_insn (gen_lowpart (DImode, operands[0]), subtarget);
4482   DONE;
4483 })
4484
4485 ;; Use mix4.r/shr to implement rotrsi3.  We only get 32 bits of valid result
4486 ;; here, instead of 64 like the patterns above.  Keep the pattern together
4487 ;; until after combine; otherwise it won't get matched often.
4488
4489 (define_expand "rotrsi3"
4490   [(set (match_operand:SI 0 "gr_register_operand" "")
4491         (rotatert:SI (match_operand:SI 1 "gr_register_operand" "")
4492                      (match_operand:SI 2 "gr_reg_or_5bit_operand" "")))]
4493   ""
4494 {
4495   if (GET_MODE (operands[2]) != VOIDmode)
4496     {
4497       rtx tmp = gen_reg_rtx (DImode);
4498       emit_insn (gen_zero_extendsidi2 (tmp, operands[2]));
4499       operands[2] = tmp;
4500     }
4501 })
4502
4503 (define_insn_and_split "*rotrsi3_internal"
4504   [(set (match_operand:SI 0 "gr_register_operand" "=&r")
4505         (rotatert:SI (match_operand:SI 1 "gr_register_operand" "r")
4506                      (match_operand:DI 2 "gr_reg_or_5bit_operand" "rM")))]
4507   ""
4508   "#"
4509   "reload_completed"
4510   [(set (match_dup 3)
4511         (ior:DI (zero_extend:DI (match_dup 1))
4512                 (ashift:DI (zero_extend:DI (match_dup 1)) (const_int 32))))
4513    (set (match_dup 3)
4514         (lshiftrt:DI (match_dup 3) (match_dup 2)))]
4515   "operands[3] = gen_rtx_REG (DImode, REGNO (operands[0]));")
4516
4517 (define_expand "rotlsi3"
4518   [(set (match_operand:SI 0 "gr_register_operand" "")
4519         (rotate:SI (match_operand:SI 1 "gr_register_operand" "")
4520                    (match_operand:SI 2 "gr_reg_or_5bit_operand" "")))]
4521   ""
4522 {
4523   if (! shift_32bit_count_operand (operands[2], SImode))
4524     {
4525       rtx tmp = gen_reg_rtx (SImode);
4526       emit_insn (gen_subsi3 (tmp, GEN_INT (32), operands[2]));
4527       emit_insn (gen_rotrsi3 (operands[0], operands[1], tmp));
4528       DONE;
4529     }
4530 })
4531
4532 (define_insn_and_split "*rotlsi3_internal"
4533   [(set (match_operand:SI 0 "gr_register_operand" "=r")
4534         (rotate:SI (match_operand:SI 1 "gr_register_operand" "r")
4535                    (match_operand:SI 2 "shift_32bit_count_operand" "n")))]
4536   ""
4537   "#"
4538   "reload_completed"
4539   [(set (match_dup 3)
4540         (ior:DI (zero_extend:DI (match_dup 1))
4541                 (ashift:DI (zero_extend:DI (match_dup 1)) (const_int 32))))
4542    (set (match_dup 3)
4543         (lshiftrt:DI (match_dup 3) (match_dup 2)))]
4544 {
4545   operands[3] = gen_rtx_REG (DImode, REGNO (operands[0]));
4546   operands[2] = GEN_INT (32 - INTVAL (operands[2]));
4547 })
4548 \f
4549 ;; ::::::::::::::::::::
4550 ;; ::
4551 ;; :: 64 bit Integer Shifts and Rotates
4552 ;; ::
4553 ;; ::::::::::::::::::::
4554
4555 (define_insn "ashldi3"
4556   [(set (match_operand:DI 0 "gr_register_operand" "=r,r,r")
4557         (ashift:DI (match_operand:DI 1 "gr_register_operand" "r,r,r")
4558                    (match_operand:DI 2 "gr_reg_or_6bit_operand" "R,r,rM")))]
4559   ""
4560   "@
4561    shladd %0 = %1, %2, r0
4562    shl %0 = %1, %2
4563    shl %0 = %1, %2"
4564   [(set_attr "itanium_class" "ialu,mmshf,mmshfi")])
4565
4566 ;; ??? Maybe combine this with the multiply and add instruction?
4567
4568 (define_insn "*shladd"
4569   [(set (match_operand:DI 0 "gr_register_operand" "=r")
4570         (plus:DI (mult:DI (match_operand:DI 1 "gr_register_operand" "r")
4571                           (match_operand:DI 2 "shladd_operand" "n"))
4572                  (match_operand:DI 3 "gr_register_operand" "r")))]
4573   ""
4574   "shladd %0 = %1, %S2, %3"
4575   [(set_attr "itanium_class" "ialu")])
4576
4577 ;; This can be created by register elimination if operand3 of shladd is an
4578 ;; eliminable register or has reg_equiv_constant set.
4579
4580 ;; We have to use nonmemory_operand for operand 4, to ensure that the
4581 ;; validate_changes call inside eliminate_regs will always succeed.  If it
4582 ;; doesn't succeed, then this remain a shladd pattern, and will be reloaded
4583 ;; incorrectly.
4584
4585 (define_insn_and_split "*shladd_elim"
4586   [(set (match_operand:DI 0 "gr_register_operand" "=&r")
4587         (plus:DI (plus:DI (mult:DI (match_operand:DI 1 "gr_register_operand" "r")
4588                                    (match_operand:DI 2 "shladd_operand" "n"))
4589                           (match_operand:DI 3 "nonmemory_operand" "r"))
4590                  (match_operand:DI 4 "nonmemory_operand" "rI")))]
4591   "reload_in_progress"
4592   "* abort ();"
4593   "reload_completed"
4594   [(set (match_dup 0) (plus:DI (mult:DI (match_dup 1) (match_dup 2))
4595                                (match_dup 3)))
4596    (set (match_dup 0) (plus:DI (match_dup 0) (match_dup 4)))]
4597   ""
4598   [(set_attr "itanium_class" "unknown")])
4599
4600 (define_insn "ashrdi3"
4601   [(set (match_operand:DI 0 "gr_register_operand" "=r,r")
4602         (ashiftrt:DI (match_operand:DI 1 "gr_register_operand" "r,r")
4603                      (match_operand:DI 2 "gr_reg_or_6bit_operand" "r,rM")))]
4604   ""
4605   "@
4606    shr %0 = %1, %2
4607    shr %0 = %1, %2"
4608   [(set_attr "itanium_class" "mmshf,mmshfi")])
4609
4610 (define_insn "lshrdi3"
4611   [(set (match_operand:DI 0 "gr_register_operand" "=r,r")
4612         (lshiftrt:DI (match_operand:DI 1 "gr_register_operand" "r,r")
4613                      (match_operand:DI 2 "gr_reg_or_6bit_operand" "r,rM")))]
4614   ""
4615   "@
4616    shr.u %0 = %1, %2
4617    shr.u %0 = %1, %2"
4618   [(set_attr "itanium_class" "mmshf,mmshfi")])
4619
4620 ;; Using a predicate that accepts only constants doesn't work, because optabs
4621 ;; will load the operand into a register and call the pattern if the predicate
4622 ;; did not accept it on the first try.  So we use nonmemory_operand and then
4623 ;; verify that we have an appropriate constant in the expander.
4624
4625 (define_expand "rotrdi3"
4626   [(set (match_operand:DI 0 "gr_register_operand" "")
4627         (rotatert:DI (match_operand:DI 1 "gr_register_operand" "")
4628                      (match_operand:DI 2 "nonmemory_operand" "")))]
4629   ""
4630 {
4631   if (! shift_count_operand (operands[2], DImode))
4632     FAIL;
4633 })
4634
4635 (define_insn "*rotrdi3_internal"
4636   [(set (match_operand:DI 0 "gr_register_operand" "=r")
4637         (rotatert:DI (match_operand:DI 1 "gr_register_operand" "r")
4638                      (match_operand:DI 2 "shift_count_operand" "M")))]
4639   ""
4640   "shrp %0 = %1, %1, %2"
4641   [(set_attr "itanium_class" "ishf")])
4642
4643 (define_expand "rotldi3"
4644   [(set (match_operand:DI 0 "gr_register_operand" "")
4645         (rotate:DI (match_operand:DI 1 "gr_register_operand" "")
4646                    (match_operand:DI 2 "nonmemory_operand" "")))]
4647   ""
4648 {
4649   if (! shift_count_operand (operands[2], DImode))
4650     FAIL;
4651 })
4652
4653 (define_insn "*rotldi3_internal"
4654   [(set (match_operand:DI 0 "gr_register_operand" "=r")
4655         (rotate:DI (match_operand:DI 1 "gr_register_operand" "r")
4656                    (match_operand:DI 2 "shift_count_operand" "M")))]
4657   ""
4658   "shrp %0 = %1, %1, %e2"
4659   [(set_attr "itanium_class" "ishf")])
4660 \f
4661 ;; ::::::::::::::::::::
4662 ;; ::
4663 ;; :: 128 bit Integer Shifts and Rotates
4664 ;; ::
4665 ;; ::::::::::::::::::::
4666
4667 (define_expand "ashrti3"
4668   [(set (match_operand:TI 0 "gr_register_operand" "")
4669         (ashiftrt:TI (match_operand:TI 1 "gr_register_operand" "")
4670                      (match_operand:DI 2 "nonmemory_operand" "")))]
4671   ""
4672 {
4673   if (!dshift_count_operand (operands[2], DImode))
4674     FAIL;
4675 })
4676
4677 (define_insn_and_split "*ashrti3_internal"
4678   [(set (match_operand:TI 0 "gr_register_operand" "=r")
4679         (ashiftrt:TI (match_operand:TI 1 "gr_register_operand" "r")
4680                      (match_operand:DI 2 "dshift_count_operand" "n")))]
4681   ""
4682   "#"
4683   "reload_completed"
4684   [(const_int 0)]
4685 {
4686   HOST_WIDE_INT shift = INTVAL (operands[2]);
4687   rtx lo = gen_lowpart (DImode, operands[1]);
4688   rtx hi = gen_highpart (DImode, operands[1]);
4689   rtx shiftlo = GEN_INT (shift & 63);
4690
4691   if (shift & 64)
4692     {
4693       emit_insn (gen_ashrdi3 (lo, hi, shiftlo));
4694       emit_insn (gen_ashrdi3 (hi, hi, GEN_INT (63)));
4695     }
4696   else
4697     {
4698       emit_insn (gen_shrp (lo, hi, lo, shiftlo));
4699       emit_insn (gen_ashrdi3 (hi, hi, shiftlo));
4700     }
4701   DONE;
4702 })
4703
4704 (define_expand "lshrti3"
4705   [(set (match_operand:TI 0 "gr_register_operand" "")
4706         (lshiftrt:TI (match_operand:TI 1 "gr_register_operand" "")
4707                      (match_operand:DI 2 "nonmemory_operand" "")))]
4708   ""
4709
4710   if (!dshift_count_operand (operands[2], DImode))
4711     FAIL;
4712 }) 
4713
4714 (define_insn_and_split "*lshrti3_internal"
4715   [(set (match_operand:TI 0 "gr_register_operand" "=r")
4716         (lshiftrt:TI (match_operand:TI 1 "gr_register_operand" "r")
4717                      (match_operand:DI 2 "dshift_count_operand" "n")))]
4718   ""
4719   "#"
4720   "reload_completed"
4721   [(const_int 0)]
4722 {
4723   HOST_WIDE_INT shift = INTVAL (operands[2]);
4724   rtx lo = gen_lowpart (DImode, operands[1]);
4725   rtx hi = gen_highpart (DImode, operands[1]);
4726   rtx shiftlo = GEN_INT (shift & 63);
4727
4728   if (shift & 64)
4729     {
4730       emit_insn (gen_lshrdi3 (lo, hi, shiftlo));
4731       emit_move_insn (hi, const0_rtx);
4732     }
4733   else
4734     {
4735       emit_insn (gen_shrp (lo, hi, lo, shiftlo));
4736       emit_insn (gen_lshrdi3 (hi, hi, shiftlo));
4737     }
4738   DONE;
4739 })
4740
4741 (define_insn "shrp"
4742   [(set (match_operand:DI 0 "gr_register_operand" "=r")
4743         (unspec:DI [(match_operand:DI 1 "gr_register_operand" "r")
4744                     (match_operand:DI 2 "gr_register_operand" "r")
4745                     (match_operand:DI 3 "shift_count_operand" "M")]
4746                    UNSPEC_SHRP))]
4747   ""
4748   "shrp %0 = %1, %2, %3"
4749   [(set_attr "itanium_class" "ishf")])
4750 \f
4751 ;; ::::::::::::::::::::
4752 ;; ::
4753 ;; :: 32 bit Integer Logical operations
4754 ;; ::
4755 ;; ::::::::::::::::::::
4756
4757 ;; We don't seem to need any other 32-bit logical operations, because gcc
4758 ;; generates zero-extend;zero-extend;DImode-op, which combine optimizes to
4759 ;; DImode-op;zero-extend, and then we can optimize away the zero-extend.
4760 ;; This doesn't work for unary logical operations, because we don't call
4761 ;; apply_distributive_law for them.
4762
4763 ;; ??? Likewise, this doesn't work for andnot, which isn't handled by
4764 ;; apply_distributive_law.  We get inefficient code for
4765 ;; int sub4 (int i, int j) { return i & ~j; }
4766 ;; We could convert (and (not (sign_extend A)) (sign_extend B)) to
4767 ;; (zero_extend (and (not A) B)) in combine.
4768 ;; Or maybe fix this by adding andsi3/iorsi3/xorsi3 patterns like the
4769 ;; one_cmplsi2 pattern.
4770
4771 (define_insn "one_cmplsi2"
4772   [(set (match_operand:SI 0 "gr_register_operand" "=r")
4773         (not:SI (match_operand:SI 1 "gr_register_operand" "r")))]
4774   ""
4775   "andcm %0 = -1, %1"
4776   [(set_attr "itanium_class" "ilog")])
4777 \f
4778 ;; ::::::::::::::::::::
4779 ;; ::
4780 ;; :: 64 bit Integer Logical operations
4781 ;; ::
4782 ;; ::::::::::::::::::::
4783
4784 (define_insn "anddi3"
4785   [(set (match_operand:DI 0 "grfr_register_operand" "=r,*f")
4786         (and:DI (match_operand:DI 1 "grfr_register_operand" "%r,*f")
4787                 (match_operand:DI 2 "grfr_reg_or_8bit_operand" "rK,*f")))]
4788   ""
4789   "@
4790    and %0 = %2, %1
4791    fand %0 = %2, %1"
4792   [(set_attr "itanium_class" "ilog,fmisc")])
4793
4794 (define_insn "*andnot"
4795   [(set (match_operand:DI 0 "grfr_register_operand" "=r,*f")
4796         (and:DI (not:DI (match_operand:DI 1 "grfr_register_operand" "r,*f"))
4797                 (match_operand:DI 2 "grfr_reg_or_8bit_operand" "rK,*f")))]
4798   ""
4799   "@
4800    andcm %0 = %2, %1
4801    fandcm %0 = %2, %1"
4802   [(set_attr "itanium_class" "ilog,fmisc")])
4803
4804 (define_insn "iordi3"
4805   [(set (match_operand:DI 0 "grfr_register_operand" "=r,*f")
4806         (ior:DI (match_operand:DI 1 "grfr_register_operand" "%r,*f")
4807                 (match_operand:DI 2 "grfr_reg_or_8bit_operand" "rK,*f")))]
4808   ""
4809   "@
4810    or %0 = %2, %1
4811    for %0 = %2, %1"
4812   [(set_attr "itanium_class" "ilog,fmisc")])
4813
4814 (define_insn "xordi3"
4815   [(set (match_operand:DI 0 "grfr_register_operand" "=r,*f")
4816         (xor:DI (match_operand:DI 1 "grfr_register_operand" "%r,*f")
4817                 (match_operand:DI 2 "grfr_reg_or_8bit_operand" "rK,*f")))]
4818   ""
4819   "@
4820    xor %0 = %2, %1
4821    fxor %0 = %2, %1"
4822   [(set_attr "itanium_class" "ilog,fmisc")])
4823
4824 (define_insn "one_cmpldi2"
4825   [(set (match_operand:DI 0 "gr_register_operand" "=r")
4826         (not:DI (match_operand:DI 1 "gr_register_operand" "r")))]
4827   ""
4828   "andcm %0 = -1, %1"
4829   [(set_attr "itanium_class" "ilog")])
4830 \f
4831 ;; ::::::::::::::::::::
4832 ;; ::
4833 ;; :: Comparisons
4834 ;; ::
4835 ;; ::::::::::::::::::::
4836
4837 (define_expand "cmpbi"
4838   [(set (cc0)
4839         (compare (match_operand:BI 0 "register_operand" "")
4840                  (match_operand:BI 1 "const_int_operand" "")))]
4841   ""
4842 {
4843   ia64_compare_op0 = operands[0];
4844   ia64_compare_op1 = operands[1];
4845   DONE;
4846 })
4847
4848 (define_expand "cmpsi"
4849   [(set (cc0)
4850         (compare (match_operand:SI 0 "gr_register_operand" "")
4851                  (match_operand:SI 1 "gr_reg_or_8bit_and_adjusted_operand" "")))]
4852   ""
4853 {
4854   ia64_compare_op0 = operands[0];
4855   ia64_compare_op1 = operands[1];
4856   DONE;
4857 })
4858
4859 (define_expand "cmpdi"
4860   [(set (cc0)
4861         (compare (match_operand:DI 0 "gr_register_operand" "")
4862                  (match_operand:DI 1 "gr_reg_or_8bit_and_adjusted_operand" "")))]
4863   ""
4864 {
4865   ia64_compare_op0 = operands[0];
4866   ia64_compare_op1 = operands[1];
4867   DONE;
4868 })
4869
4870 (define_expand "cmpsf"
4871   [(set (cc0)
4872         (compare (match_operand:SF 0 "fr_reg_or_fp01_operand" "")
4873                  (match_operand:SF 1 "fr_reg_or_fp01_operand" "")))]
4874   ""
4875 {
4876   ia64_compare_op0 = operands[0];
4877   ia64_compare_op1 = operands[1];
4878   DONE;
4879 })
4880
4881 (define_expand "cmpdf"
4882   [(set (cc0)
4883         (compare (match_operand:DF 0 "fr_reg_or_fp01_operand" "")
4884                  (match_operand:DF 1 "fr_reg_or_fp01_operand" "")))]
4885   ""
4886 {
4887   ia64_compare_op0 = operands[0];
4888   ia64_compare_op1 = operands[1];
4889   DONE;
4890 })
4891
4892 (define_expand "cmpxf"
4893   [(set (cc0)
4894         (compare (match_operand:XF 0 "xfreg_or_fp01_operand" "")
4895                  (match_operand:XF 1 "xfreg_or_fp01_operand" "")))]
4896   ""
4897 {
4898   ia64_compare_op0 = operands[0];
4899   ia64_compare_op1 = operands[1];
4900   DONE;
4901 })
4902
4903 (define_expand "cmptf"
4904   [(set (cc0)
4905         (compare (match_operand:TF 0 "gr_register_operand" "")
4906                  (match_operand:TF 1 "gr_register_operand" "")))]
4907   "TARGET_HPUX"
4908 {
4909   ia64_compare_op0 = operands[0];
4910   ia64_compare_op1 = operands[1];
4911   DONE;
4912 })
4913
4914 (define_insn "*cmpsi_normal"
4915   [(set (match_operand:BI 0 "register_operand" "=c")
4916         (match_operator:BI 1 "normal_comparison_operator"
4917            [(match_operand:SI 2 "gr_register_operand" "r")
4918             (match_operand:SI 3 "gr_reg_or_8bit_operand" "rK")]))]
4919   ""
4920   "cmp4.%C1 %0, %I0 = %3, %2"
4921   [(set_attr "itanium_class" "icmp")])
4922
4923 ;; We use %r3 because it is possible for us to match a 0, and two of the
4924 ;; unsigned comparisons don't accept immediate operands of zero.
4925
4926 (define_insn "*cmpsi_adjusted"
4927   [(set (match_operand:BI 0 "register_operand" "=c")
4928         (match_operator:BI 1 "adjusted_comparison_operator"
4929            [(match_operand:SI 2 "gr_register_operand" "r")
4930             (match_operand:SI 3 "gr_reg_or_8bit_adjusted_operand" "rL")]))]
4931   ""
4932   "cmp4.%C1 %0, %I0 = %r3, %2"
4933   [(set_attr "itanium_class" "icmp")])
4934
4935 (define_insn "*cmpdi_normal"
4936   [(set (match_operand:BI 0 "register_operand" "=c")
4937         (match_operator:BI 1 "normal_comparison_operator"
4938            [(match_operand:DI 2 "gr_reg_or_0_operand" "rO")
4939             (match_operand:DI 3 "gr_reg_or_8bit_operand" "rK")]))]
4940   ""
4941   "cmp.%C1 %0, %I0 = %3, %r2"
4942   [(set_attr "itanium_class" "icmp")])
4943
4944 ;; We use %r3 because it is possible for us to match a 0, and two of the
4945 ;; unsigned comparisons don't accept immediate operands of zero.
4946
4947 (define_insn "*cmpdi_adjusted"
4948   [(set (match_operand:BI 0 "register_operand" "=c")
4949         (match_operator:BI 1 "adjusted_comparison_operator"
4950            [(match_operand:DI 2 "gr_register_operand" "r")
4951             (match_operand:DI 3 "gr_reg_or_8bit_adjusted_operand" "rL")]))]
4952   ""
4953   "cmp.%C1 %0, %I0 = %r3, %2"
4954   [(set_attr "itanium_class" "icmp")])
4955
4956 (define_insn "*cmpsf_internal"
4957   [(set (match_operand:BI 0 "register_operand" "=c")
4958         (match_operator:BI 1 "comparison_operator"
4959            [(match_operand:SF 2 "fr_reg_or_fp01_operand" "fG")
4960             (match_operand:SF 3 "fr_reg_or_fp01_operand" "fG")]))]
4961   ""
4962   "fcmp.%D1 %0, %I0 = %F2, %F3"
4963   [(set_attr "itanium_class" "fcmp")])
4964
4965 (define_insn "*cmpdf_internal"
4966   [(set (match_operand:BI 0 "register_operand" "=c")
4967         (match_operator:BI 1 "comparison_operator"
4968            [(match_operand:DF 2 "fr_reg_or_fp01_operand" "fG")
4969             (match_operand:DF 3 "fr_reg_or_fp01_operand" "fG")]))]
4970   ""
4971   "fcmp.%D1 %0, %I0 = %F2, %F3"
4972   [(set_attr "itanium_class" "fcmp")])
4973
4974 (define_insn "*cmpxf_internal"
4975   [(set (match_operand:BI 0 "register_operand" "=c")
4976         (match_operator:BI 1 "comparison_operator"
4977                    [(match_operand:XF 2 "xfreg_or_fp01_operand" "fG")
4978                     (match_operand:XF 3 "xfreg_or_fp01_operand" "fG")]))]
4979   ""
4980   "fcmp.%D1 %0, %I0 = %F2, %F3"
4981   [(set_attr "itanium_class" "fcmp")])
4982
4983 ;; ??? Can this pattern be generated?
4984
4985 (define_insn "*bit_zero"
4986   [(set (match_operand:BI 0 "register_operand" "=c")
4987         (eq:BI (zero_extract:DI (match_operand:DI 1 "gr_register_operand" "r")
4988                                 (const_int 1)
4989                                 (match_operand:DI 2 "immediate_operand" "n"))
4990                (const_int 0)))]
4991   ""
4992   "tbit.z %0, %I0 = %1, %2"
4993   [(set_attr "itanium_class" "tbit")])
4994
4995 (define_insn "*bit_one"
4996   [(set (match_operand:BI 0 "register_operand" "=c")
4997         (ne:BI (zero_extract:DI (match_operand:DI 1 "gr_register_operand" "r")
4998                                 (const_int 1)
4999                                 (match_operand:DI 2 "immediate_operand" "n"))
5000                (const_int 0)))]
5001   ""
5002   "tbit.nz %0, %I0 = %1, %2"
5003   [(set_attr "itanium_class" "tbit")])
5004 \f
5005 ;; ::::::::::::::::::::
5006 ;; ::
5007 ;; :: Branches
5008 ;; ::
5009 ;; ::::::::::::::::::::
5010
5011 (define_expand "beq"
5012   [(set (pc)
5013         (if_then_else (match_dup 1)
5014                       (label_ref (match_operand 0 "" ""))
5015                       (pc)))]
5016   ""
5017   "operands[1] = ia64_expand_compare (EQ, VOIDmode);")
5018
5019 (define_expand "bne"
5020   [(set (pc)
5021         (if_then_else (match_dup 1)
5022                       (label_ref (match_operand 0 "" ""))
5023                       (pc)))]
5024   ""
5025   "operands[1] = ia64_expand_compare (NE, VOIDmode);")
5026
5027 (define_expand "blt"
5028   [(set (pc)
5029         (if_then_else (match_dup 1)
5030                       (label_ref (match_operand 0 "" ""))
5031                       (pc)))]
5032   ""
5033   "operands[1] = ia64_expand_compare (LT, VOIDmode);")
5034
5035 (define_expand "ble"
5036   [(set (pc)
5037         (if_then_else (match_dup 1)
5038                       (label_ref (match_operand 0 "" ""))
5039                       (pc)))]
5040   ""
5041   "operands[1] = ia64_expand_compare (LE, VOIDmode);")
5042
5043 (define_expand "bgt"
5044   [(set (pc)
5045         (if_then_else (match_dup 1)
5046                       (label_ref (match_operand 0 "" ""))
5047                       (pc)))]
5048   ""
5049   "operands[1] = ia64_expand_compare (GT, VOIDmode);")
5050
5051 (define_expand "bge"
5052   [(set (pc)
5053         (if_then_else (match_dup 1)
5054                       (label_ref (match_operand 0 "" ""))
5055                       (pc)))]
5056   ""
5057   "operands[1] = ia64_expand_compare (GE, VOIDmode);")
5058
5059 (define_expand "bltu"
5060   [(set (pc)
5061         (if_then_else (match_dup 1)
5062                       (label_ref (match_operand 0 "" ""))
5063                       (pc)))]
5064   ""
5065   "operands[1] = ia64_expand_compare (LTU, VOIDmode);")
5066
5067 (define_expand "bleu"
5068   [(set (pc)
5069         (if_then_else (match_dup 1)
5070                       (label_ref (match_operand 0 "" ""))
5071                       (pc)))]
5072   ""
5073   "operands[1] = ia64_expand_compare (LEU, VOIDmode);")
5074
5075 (define_expand "bgtu"
5076   [(set (pc)
5077         (if_then_else (match_dup 1)
5078                       (label_ref (match_operand 0 "" ""))
5079                       (pc)))]
5080   ""
5081   "operands[1] = ia64_expand_compare (GTU, VOIDmode);")
5082
5083 (define_expand "bgeu"
5084   [(set (pc)
5085         (if_then_else (match_dup 1)
5086                       (label_ref (match_operand 0 "" ""))
5087                       (pc)))]
5088   ""
5089   "operands[1] = ia64_expand_compare (GEU, VOIDmode);")
5090
5091 (define_expand "bunordered"
5092   [(set (pc)
5093         (if_then_else (match_dup 1)
5094                       (label_ref (match_operand 0 "" ""))
5095                       (pc)))]
5096   ""
5097   "operands[1] = ia64_expand_compare (UNORDERED, VOIDmode);")
5098
5099 (define_expand "bordered"
5100   [(set (pc)
5101         (if_then_else (match_dup 1)
5102                       (label_ref (match_operand 0 "" ""))
5103                       (pc)))]
5104   ""
5105   "operands[1] = ia64_expand_compare (ORDERED, VOIDmode);")
5106
5107 (define_insn "*br_true"
5108   [(set (pc)
5109         (if_then_else (match_operator 0 "predicate_operator"
5110                         [(match_operand:BI 1 "register_operand" "c")
5111                          (const_int 0)])
5112                       (label_ref (match_operand 2 "" ""))
5113                       (pc)))]
5114   ""
5115   "(%J0) br.cond%+ %l2"
5116   [(set_attr "itanium_class" "br")
5117    (set_attr "predicable" "no")])
5118
5119 (define_insn "*br_false"
5120   [(set (pc)
5121         (if_then_else (match_operator 0 "predicate_operator"
5122                         [(match_operand:BI 1 "register_operand" "c")
5123                          (const_int 0)])
5124                       (pc)
5125                       (label_ref (match_operand 2 "" ""))))]
5126   ""
5127   "(%j0) br.cond%+ %l2"
5128   [(set_attr "itanium_class" "br")
5129    (set_attr "predicable" "no")])
5130 \f
5131 ;; ::::::::::::::::::::
5132 ;; ::
5133 ;; :: Counted loop operations
5134 ;; ::
5135 ;; ::::::::::::::::::::
5136
5137 (define_expand "doloop_end"
5138   [(use (match_operand 0 "" ""))        ; loop pseudo
5139    (use (match_operand 1 "" ""))        ; iterations; zero if unknown
5140    (use (match_operand 2 "" ""))        ; max iterations
5141    (use (match_operand 3 "" ""))        ; loop level
5142    (use (match_operand 4 "" ""))]       ; label
5143   ""
5144 {
5145   /* Only use cloop on innermost loops.  */
5146   if (INTVAL (operands[3]) > 1)
5147     FAIL;
5148   emit_jump_insn (gen_doloop_end_internal (gen_rtx_REG (DImode, AR_LC_REGNUM),
5149                                            operands[4]));
5150   DONE;
5151 })
5152
5153 (define_insn "doloop_end_internal"
5154   [(set (pc) (if_then_else (ne (match_operand:DI 0 "ar_lc_reg_operand" "")
5155                                (const_int 0))
5156                 (label_ref (match_operand 1 "" ""))
5157                 (pc)))
5158    (set (match_dup 0) (if_then_else:DI (ne (match_dup 0) (const_int 0))
5159                          (plus:DI (match_dup 0) (const_int -1))
5160                          (match_dup 0)))]
5161   ""
5162   "br.cloop.sptk.few %l1"
5163   [(set_attr "itanium_class" "br")
5164    (set_attr "predicable" "no")])
5165 \f
5166 ;; ::::::::::::::::::::
5167 ;; ::
5168 ;; :: Set flag operations
5169 ;; ::
5170 ;; ::::::::::::::::::::
5171
5172 (define_expand "seq"
5173   [(set (match_operand:DI 0 "gr_register_operand" "") (match_dup 1))]
5174   ""
5175   "operands[1] = ia64_expand_compare (EQ, DImode);")
5176
5177 (define_expand "sne"
5178   [(set (match_operand:DI 0 "gr_register_operand" "") (match_dup 1))]
5179   ""
5180   "operands[1] = ia64_expand_compare (NE, DImode);")
5181
5182 (define_expand "slt"
5183   [(set (match_operand:DI 0 "gr_register_operand" "") (match_dup 1))]
5184   ""
5185   "operands[1] = ia64_expand_compare (LT, DImode);")
5186
5187 (define_expand "sle"
5188   [(set (match_operand:DI 0 "gr_register_operand" "") (match_dup 1))]
5189   ""
5190   "operands[1] = ia64_expand_compare (LE, DImode);")
5191
5192 (define_expand "sgt"
5193   [(set (match_operand:DI 0 "gr_register_operand" "") (match_dup 1))]
5194   ""
5195   "operands[1] = ia64_expand_compare (GT, DImode);")
5196
5197 (define_expand "sge"
5198   [(set (match_operand:DI 0 "gr_register_operand" "") (match_dup 1))]
5199   ""
5200   "operands[1] = ia64_expand_compare (GE, DImode);")
5201
5202 (define_expand "sltu"
5203   [(set (match_operand:DI 0 "gr_register_operand" "") (match_dup 1))]
5204   ""
5205   "operands[1] = ia64_expand_compare (LTU, DImode);")
5206
5207 (define_expand "sleu"
5208   [(set (match_operand:DI 0 "gr_register_operand" "") (match_dup 1))]
5209   ""
5210   "operands[1] = ia64_expand_compare (LEU, DImode);")
5211
5212 (define_expand "sgtu"
5213   [(set (match_operand:DI 0 "gr_register_operand" "") (match_dup 1))]
5214   ""
5215   "operands[1] = ia64_expand_compare (GTU, DImode);")
5216
5217 (define_expand "sgeu"
5218   [(set (match_operand:DI 0 "gr_register_operand" "") (match_dup 1))]
5219   ""
5220   "operands[1] = ia64_expand_compare (GEU, DImode);")
5221
5222 (define_expand "sunordered"
5223   [(set (match_operand:DI 0 "gr_register_operand" "") (match_dup 1))]
5224   ""
5225   "operands[1] = ia64_expand_compare (UNORDERED, DImode);")
5226
5227 (define_expand "sordered"
5228   [(set (match_operand:DI 0 "gr_register_operand" "") (match_dup 1))]
5229   ""
5230   "operands[1] = ia64_expand_compare (ORDERED, DImode);")
5231
5232 ;; Don't allow memory as destination here, because cmov/cmov/st is more
5233 ;; efficient than mov/mov/cst/cst.
5234
5235 (define_insn_and_split "*sne_internal"
5236   [(set (match_operand:DI 0 "gr_register_operand" "=r")
5237         (ne:DI (match_operand:BI 1 "register_operand" "c")
5238                (const_int 0)))]
5239   ""
5240   "#"
5241   "reload_completed"
5242   [(cond_exec (ne (match_dup 1) (const_int 0))
5243      (set (match_dup 0) (const_int 1)))
5244    (cond_exec (eq (match_dup 1) (const_int 0))
5245      (set (match_dup 0) (const_int 0)))]
5246   ""
5247   [(set_attr "itanium_class" "unknown")])
5248
5249 (define_insn_and_split "*seq_internal"
5250   [(set (match_operand:DI 0 "gr_register_operand" "=r")
5251         (eq:DI (match_operand:BI 1 "register_operand" "c")
5252                (const_int 0)))]
5253   ""
5254   "#"
5255   "reload_completed"
5256   [(cond_exec (ne (match_dup 1) (const_int 0))
5257      (set (match_dup 0) (const_int 0)))
5258    (cond_exec (eq (match_dup 1) (const_int 0))
5259      (set (match_dup 0) (const_int 1)))]
5260   ""
5261   [(set_attr "itanium_class" "unknown")])
5262 \f
5263 ;; ::::::::::::::::::::
5264 ;; ::
5265 ;; :: Conditional move instructions.
5266 ;; ::
5267 ;; ::::::::::::::::::::
5268
5269 ;; ??? Add movXXcc patterns?
5270
5271 ;;
5272 ;; DImode if_then_else patterns.
5273 ;;
5274
5275 (define_insn "*cmovdi_internal"
5276   [(set (match_operand:DI 0 "destination_operand"
5277            "= r,  r,  r,   r,  r,  r,   r, r, r,   r, m, Q, *f,*b,*d*e")
5278         (if_then_else:DI
5279           (match_operator 4 "predicate_operator"
5280             [(match_operand:BI 1 "register_operand"
5281                 "c,c,c,c,c,c,c,c,c,c,c,c,c,c,c")
5282              (const_int 0)])
5283           (match_operand:DI 2 "move_operand"
5284            "rim, *f, *b,*d*e,rim,rim, rim,*f,*b,*d*e,rO,*f,rOQ,rO,  rK")
5285           (match_operand:DI 3 "move_operand"
5286            "rim,rim,rim, rim, *f, *b,*d*e,*f,*b,*d*e,rO,*f,rOQ,rO,  rK")))]
5287   "ia64_move_ok (operands[0], operands[2])
5288    && ia64_move_ok (operands[0], operands[3])"
5289   { abort (); }
5290   [(set_attr "predicable" "no")])
5291
5292 (define_split
5293   [(set (match_operand 0 "destination_operand" "")
5294         (if_then_else
5295           (match_operator 4 "predicate_operator"
5296             [(match_operand:BI 1 "register_operand" "")
5297              (const_int 0)])
5298           (match_operand 2 "move_operand" "")
5299           (match_operand 3 "move_operand" "")))]
5300   "reload_completed"
5301   [(const_int 0)]
5302 {
5303   bool emitted_something = false;
5304   rtx dest = operands[0];
5305   rtx srct = operands[2];
5306   rtx srcf = operands[3];
5307   rtx cond = operands[4];
5308
5309   if (! rtx_equal_p (dest, srct))
5310     {
5311       ia64_emit_cond_move (dest, srct, cond);
5312       emitted_something = true;
5313     }
5314   if (! rtx_equal_p (dest, srcf))
5315     {
5316       cond = gen_rtx_fmt_ee (GET_CODE (cond) == NE ? EQ : NE,
5317                              VOIDmode, operands[1], const0_rtx);
5318       ia64_emit_cond_move (dest, srcf, cond);
5319       emitted_something = true;
5320     }
5321   if (! emitted_something)
5322     emit_note (NOTE_INSN_DELETED);
5323   DONE;
5324 })
5325
5326 ;; Absolute value pattern.
5327
5328 (define_insn "*absdi2_internal"
5329   [(set (match_operand:DI 0 "gr_register_operand" "=r,r")
5330         (if_then_else:DI
5331           (match_operator 4 "predicate_operator"
5332             [(match_operand:BI 1 "register_operand" "c,c")
5333              (const_int 0)])
5334           (neg:DI (match_operand:DI 2 "gr_reg_or_22bit_operand" "rI,rI"))
5335           (match_operand:DI 3 "gr_reg_or_22bit_operand" "0,rI")))]
5336   ""
5337   "#"
5338   [(set_attr "itanium_class" "ialu,unknown")
5339    (set_attr "predicable" "no")])
5340
5341 (define_split
5342   [(set (match_operand:DI 0 "register_operand" "")
5343         (if_then_else:DI
5344           (match_operator 4 "predicate_operator"
5345             [(match_operand:BI 1 "register_operand" "c,c")
5346              (const_int 0)])
5347           (neg:DI (match_operand:DI 2 "gr_reg_or_22bit_operand" ""))
5348           (match_operand:DI 3 "gr_reg_or_22bit_operand" "")))]
5349   "reload_completed && rtx_equal_p (operands[0], operands[3])"
5350   [(cond_exec
5351      (match_dup 4)
5352      (set (match_dup 0)
5353           (neg:DI (match_dup 2))))]
5354   "")
5355
5356 (define_split
5357   [(set (match_operand:DI 0 "register_operand" "")
5358         (if_then_else:DI
5359           (match_operator 4 "predicate_operator"
5360             [(match_operand:BI 1 "register_operand" "c,c")
5361              (const_int 0)])
5362           (neg:DI (match_operand:DI 2 "gr_reg_or_22bit_operand" ""))
5363           (match_operand:DI 3 "gr_reg_or_22bit_operand" "")))]
5364   "reload_completed"
5365   [(cond_exec
5366      (match_dup 4)
5367      (set (match_dup 0) (neg:DI (match_dup 2))))
5368    (cond_exec
5369      (match_dup 5)
5370      (set (match_dup 0) (match_dup 3)))]
5371 {
5372   operands[5] = gen_rtx_fmt_ee (GET_CODE (operands[4]) == NE ? EQ : NE,
5373                                 VOIDmode, operands[1], const0_rtx);
5374 })
5375
5376 ;;
5377 ;; SImode if_then_else patterns.
5378 ;;
5379
5380 (define_insn "*cmovsi_internal"
5381   [(set (match_operand:SI 0 "destination_operand" "=r,m,*f,r,m,*f,r,m,*f")
5382         (if_then_else:SI
5383           (match_operator 4 "predicate_operator"
5384             [(match_operand:BI 1 "register_operand" "c,c,c,c,c,c,c,c,c")
5385              (const_int 0)])
5386           (match_operand:SI 2 "move_operand"
5387                     "0,0,0,rim*f,rO,rO,rim*f,rO,rO")
5388           (match_operand:SI 3 "move_operand"
5389                     "rim*f,rO,rO,0,0,0,rim*f,rO,rO")))]
5390   "ia64_move_ok (operands[0], operands[2])
5391    && ia64_move_ok (operands[0], operands[3])"
5392   { abort (); }
5393   [(set_attr "predicable" "no")])
5394
5395 (define_insn "*abssi2_internal"
5396   [(set (match_operand:SI 0 "gr_register_operand" "=r,r")
5397         (if_then_else:SI
5398           (match_operator 4 "predicate_operator"
5399             [(match_operand:BI 1 "register_operand" "c,c")
5400              (const_int 0)])
5401           (neg:SI (match_operand:SI 3 "gr_reg_or_22bit_operand" "rI,rI"))
5402           (match_operand:SI 2 "gr_reg_or_22bit_operand" "0,rI")))]
5403   ""
5404   "#"
5405   [(set_attr "itanium_class" "ialu,unknown")
5406    (set_attr "predicable" "no")])
5407
5408 (define_split
5409   [(set (match_operand:SI 0 "register_operand" "")
5410         (if_then_else:SI
5411           (match_operator 4 "predicate_operator"
5412             [(match_operand:BI 1 "register_operand" "c,c")
5413              (const_int 0)])
5414           (neg:SI (match_operand:SI 2 "gr_reg_or_22bit_operand" ""))
5415           (match_operand:SI 3 "gr_reg_or_22bit_operand" "")))]
5416   "reload_completed && rtx_equal_p (operands[0], operands[3])"
5417   [(cond_exec
5418      (match_dup 4)
5419      (set (match_dup 0)
5420           (neg:SI (match_dup 2))))]
5421   "")
5422
5423 (define_split
5424   [(set (match_operand:SI 0 "register_operand" "")
5425         (if_then_else:SI
5426           (match_operator 4 "predicate_operator"
5427             [(match_operand:BI 1 "register_operand" "c,c")
5428              (const_int 0)])
5429           (neg:SI (match_operand:SI 2 "gr_reg_or_22bit_operand" ""))
5430           (match_operand:SI 3 "gr_reg_or_22bit_operand" "")))]
5431   "reload_completed"
5432   [(cond_exec
5433      (match_dup 4)
5434      (set (match_dup 0) (neg:SI (match_dup 2))))
5435    (cond_exec
5436      (match_dup 5)
5437      (set (match_dup 0) (match_dup 3)))]
5438 {
5439   operands[5] = gen_rtx_fmt_ee (GET_CODE (operands[4]) == NE ? EQ : NE,
5440                                 VOIDmode, operands[1], const0_rtx);
5441 })
5442
5443 (define_insn_and_split "*cond_opsi2_internal"
5444   [(set (match_operand:SI 0 "gr_register_operand" "=r")
5445         (match_operator:SI 5 "condop_operator"
5446           [(if_then_else:SI
5447              (match_operator 6 "predicate_operator"
5448                [(match_operand:BI 1 "register_operand" "c")
5449                 (const_int 0)])
5450              (match_operand:SI 2 "gr_register_operand" "r")
5451              (match_operand:SI 3 "gr_register_operand" "r"))
5452            (match_operand:SI 4 "gr_register_operand" "r")]))]
5453   ""
5454   "#"
5455   "reload_completed"
5456   [(cond_exec
5457      (match_dup 6)
5458      (set (match_dup 0) (match_op_dup:SI 5 [(match_dup 2) (match_dup 4)])))
5459    (cond_exec
5460      (match_dup 7)
5461      (set (match_dup 0) (match_op_dup:SI 5 [(match_dup 3) (match_dup 4)])))]
5462 {
5463   operands[7] = gen_rtx_fmt_ee (GET_CODE (operands[6]) == NE ? EQ : NE,
5464                                 VOIDmode, operands[1], const0_rtx);
5465 }
5466   [(set_attr "itanium_class" "ialu")
5467    (set_attr "predicable" "no")])
5468
5469
5470 (define_insn_and_split "*cond_opsi2_internal_b"
5471   [(set (match_operand:SI 0 "gr_register_operand" "=r")
5472         (match_operator:SI 5 "condop_operator"
5473           [(match_operand:SI 4 "gr_register_operand" "r")
5474            (if_then_else:SI
5475              (match_operator 6 "predicate_operator"
5476                [(match_operand:BI 1 "register_operand" "c")
5477                 (const_int 0)])
5478              (match_operand:SI 2 "gr_register_operand" "r")
5479              (match_operand:SI 3 "gr_register_operand" "r"))]))]
5480   ""
5481   "#"
5482   "reload_completed"
5483   [(cond_exec
5484      (match_dup 6)
5485      (set (match_dup 0) (match_op_dup:SI 5 [(match_dup 4) (match_dup 2)])))
5486    (cond_exec
5487      (match_dup 7)
5488      (set (match_dup 0) (match_op_dup:SI 5 [(match_dup 4) (match_dup 3)])))]
5489 {
5490   operands[7] = gen_rtx_fmt_ee (GET_CODE (operands[6]) == NE ? EQ : NE,
5491                                 VOIDmode, operands[1], const0_rtx);
5492 }
5493   [(set_attr "itanium_class" "ialu")
5494    (set_attr "predicable" "no")])
5495
5496 \f
5497 ;; ::::::::::::::::::::
5498 ;; ::
5499 ;; :: Call and branch instructions
5500 ;; ::
5501 ;; ::::::::::::::::::::
5502
5503 ;; Subroutine call instruction returning no value.  Operand 0 is the function
5504 ;; to call; operand 1 is the number of bytes of arguments pushed (in mode
5505 ;; `SImode', except it is normally a `const_int'); operand 2 is the number of
5506 ;; registers used as operands.
5507
5508 ;; On most machines, operand 2 is not actually stored into the RTL pattern.  It
5509 ;; is supplied for the sake of some RISC machines which need to put this
5510 ;; information into the assembler code; they can put it in the RTL instead of
5511 ;; operand 1.
5512
5513 (define_expand "call"
5514   [(use (match_operand:DI 0 "" ""))
5515    (use (match_operand 1 "" ""))
5516    (use (match_operand 2 "" ""))
5517    (use (match_operand 3 "" ""))]
5518   ""
5519 {
5520   ia64_expand_call (NULL_RTX, operands[0], operands[2], false);
5521   DONE;
5522 })
5523
5524 (define_expand "sibcall"
5525   [(use (match_operand:DI 0 "" ""))
5526    (use (match_operand 1 "" ""))
5527    (use (match_operand 2 "" ""))
5528    (use (match_operand 3 "" ""))]
5529   ""
5530 {
5531   ia64_expand_call (NULL_RTX, operands[0], operands[2], true);
5532   DONE;
5533 })
5534
5535 ;; Subroutine call instruction returning a value.  Operand 0 is the hard
5536 ;; register in which the value is returned.  There are three more operands,
5537 ;; the same as the three operands of the `call' instruction (but with numbers
5538 ;; increased by one).
5539 ;;
5540 ;; Subroutines that return `BLKmode' objects use the `call' insn.
5541
5542 (define_expand "call_value"
5543   [(use (match_operand 0 "" ""))
5544    (use (match_operand:DI 1 "" ""))
5545    (use (match_operand 2 "" ""))
5546    (use (match_operand 3 "" ""))
5547    (use (match_operand 4 "" ""))]
5548   ""
5549 {
5550   ia64_expand_call (operands[0], operands[1], operands[3], false);
5551   DONE;
5552 })
5553
5554 (define_expand "sibcall_value"
5555   [(use (match_operand 0 "" ""))
5556    (use (match_operand:DI 1 "" ""))
5557    (use (match_operand 2 "" ""))
5558    (use (match_operand 3 "" ""))
5559    (use (match_operand 4 "" ""))]
5560   ""
5561 {
5562   ia64_expand_call (operands[0], operands[1], operands[3], true);
5563   DONE;
5564 })
5565
5566 ;; Call subroutine returning any type.
5567
5568 (define_expand "untyped_call"
5569   [(parallel [(call (match_operand 0 "" "")
5570                     (const_int 0))
5571               (match_operand 1 "" "")
5572               (match_operand 2 "" "")])]
5573   ""
5574 {
5575   int i;
5576
5577   emit_call_insn (gen_call (operands[0], const0_rtx, NULL, const0_rtx));
5578
5579   for (i = 0; i < XVECLEN (operands[2], 0); i++)
5580     {
5581       rtx set = XVECEXP (operands[2], 0, i);
5582       emit_move_insn (SET_DEST (set), SET_SRC (set));
5583     }
5584
5585   /* The optimizer does not know that the call sets the function value
5586      registers we stored in the result block.  We avoid problems by
5587      claiming that all hard registers are used and clobbered at this
5588      point.  */
5589   emit_insn (gen_blockage ());
5590
5591   DONE;
5592 })
5593
5594 (define_insn "call_nogp"
5595   [(call (mem:DI (match_operand:DI 0 "call_operand" "?b,i"))
5596          (const_int 0))
5597    (clobber (match_operand:DI 1 "register_operand" "=b,b"))]
5598   ""
5599   "br.call%+.many %1 = %0"
5600   [(set_attr "itanium_class" "br,scall")])
5601
5602 (define_insn "call_value_nogp"
5603   [(set (match_operand 0 "" "=X,X")
5604         (call (mem:DI (match_operand:DI 1 "call_operand" "?b,i"))
5605               (const_int 0)))
5606    (clobber (match_operand:DI 2 "register_operand" "=b,b"))]
5607   ""
5608   "br.call%+.many %2 = %1"
5609   [(set_attr "itanium_class" "br,scall")])
5610
5611 (define_insn "sibcall_nogp"
5612   [(call (mem:DI (match_operand:DI 0 "call_operand" "?b,i"))
5613          (const_int 0))]
5614   ""
5615   "br%+.many %0"
5616   [(set_attr "itanium_class" "br,scall")])
5617
5618 (define_insn "call_gp"
5619   [(call (mem:DI (match_operand:DI 0 "call_operand" "?r,i"))
5620          (const_int 1))
5621    (clobber (match_operand:DI 1 "register_operand" "=b,b"))
5622    (clobber (match_scratch:DI 2 "=&r,X"))
5623    (clobber (match_scratch:DI 3 "=b,X"))]
5624   ""
5625   "#"
5626   [(set_attr "itanium_class" "br,scall")])
5627
5628 ;; Irritatingly, we don't have access to INSN within the split body.
5629 ;; See commentary in ia64_split_call as to why these aren't peep2.
5630 (define_split
5631   [(call (mem (match_operand 0 "call_operand" ""))
5632          (const_int 1))
5633    (clobber (match_operand:DI 1 "register_operand" ""))
5634    (clobber (match_scratch:DI 2 ""))
5635    (clobber (match_scratch:DI 3 ""))]
5636   "reload_completed && find_reg_note (insn, REG_NORETURN, NULL_RTX)"
5637   [(const_int 0)]
5638 {
5639   ia64_split_call (NULL_RTX, operands[0], operands[1], operands[2],
5640                    operands[3], true, false);
5641   DONE;
5642 })
5643
5644 (define_split
5645   [(call (mem (match_operand 0 "call_operand" ""))
5646          (const_int 1))
5647    (clobber (match_operand:DI 1 "register_operand" ""))
5648    (clobber (match_scratch:DI 2 ""))
5649    (clobber (match_scratch:DI 3 ""))]
5650   "reload_completed"
5651   [(const_int 0)]
5652 {
5653   ia64_split_call (NULL_RTX, operands[0], operands[1], operands[2],
5654                    operands[3], false, false);
5655   DONE;
5656 })
5657
5658 (define_insn "call_value_gp"
5659   [(set (match_operand 0 "" "=X,X")
5660         (call (mem:DI (match_operand:DI 1 "call_operand" "?r,i"))
5661               (const_int 1)))
5662    (clobber (match_operand:DI 2 "register_operand" "=b,b"))
5663    (clobber (match_scratch:DI 3 "=&r,X"))
5664    (clobber (match_scratch:DI 4 "=b,X"))]
5665   ""
5666   "#"
5667   [(set_attr "itanium_class" "br,scall")])
5668
5669 (define_split
5670   [(set (match_operand 0 "" "")
5671         (call (mem:DI (match_operand:DI 1 "call_operand" ""))
5672               (const_int 1)))
5673    (clobber (match_operand:DI 2 "register_operand" ""))
5674    (clobber (match_scratch:DI 3 ""))
5675    (clobber (match_scratch:DI 4 ""))]
5676   "reload_completed && find_reg_note (insn, REG_NORETURN, NULL_RTX)"
5677   [(const_int 0)]
5678 {
5679   ia64_split_call (operands[0], operands[1], operands[2], operands[3],
5680                    operands[4], true, false);
5681   DONE;
5682 })
5683
5684 (define_split
5685   [(set (match_operand 0 "" "")
5686         (call (mem:DI (match_operand:DI 1 "call_operand" ""))
5687               (const_int 1)))
5688    (clobber (match_operand:DI 2 "register_operand" ""))
5689    (clobber (match_scratch:DI 3 ""))
5690    (clobber (match_scratch:DI 4 ""))]
5691   "reload_completed"
5692   [(const_int 0)]
5693 {
5694   ia64_split_call (operands[0], operands[1], operands[2], operands[3],
5695                    operands[4], false, false);
5696   DONE;
5697 })
5698
5699 (define_insn_and_split "sibcall_gp"
5700   [(call (mem:DI (match_operand:DI 0 "call_operand" "?r,i"))
5701          (const_int 1))
5702    (clobber (match_scratch:DI 1 "=&r,X"))
5703    (clobber (match_scratch:DI 2 "=b,X"))]
5704   ""
5705   "#"
5706   "reload_completed"
5707   [(const_int 0)]
5708 {
5709   ia64_split_call (NULL_RTX, operands[0], NULL_RTX, operands[1],
5710                    operands[2], true, true);
5711   DONE;
5712 }
5713   [(set_attr "itanium_class" "br")])
5714
5715 (define_insn "return_internal"
5716   [(return)
5717    (use (match_operand:DI 0 "register_operand" "b"))]
5718   ""
5719   "br.ret.sptk.many %0"
5720   [(set_attr "itanium_class" "br")])
5721
5722 (define_insn "return"
5723   [(return)]
5724   "ia64_direct_return ()"
5725   "br.ret.sptk.many rp"
5726   [(set_attr "itanium_class" "br")])
5727
5728 (define_insn "*return_true"
5729   [(set (pc)
5730         (if_then_else (match_operator 0 "predicate_operator"
5731                         [(match_operand:BI 1 "register_operand" "c")
5732                          (const_int 0)])
5733                       (return)
5734                       (pc)))]
5735   "ia64_direct_return ()"
5736   "(%J0) br.ret%+.many rp"
5737   [(set_attr "itanium_class" "br")
5738    (set_attr "predicable" "no")])
5739
5740 (define_insn "*return_false"
5741   [(set (pc)
5742         (if_then_else (match_operator 0 "predicate_operator"
5743                         [(match_operand:BI 1 "register_operand" "c")
5744                          (const_int 0)])
5745                       (pc)
5746                       (return)))]
5747   "ia64_direct_return ()"
5748   "(%j0) br.ret%+.many rp"
5749   [(set_attr "itanium_class" "br")
5750    (set_attr "predicable" "no")])
5751
5752 (define_insn "jump"
5753   [(set (pc) (label_ref (match_operand 0 "" "")))]
5754   ""
5755   "br %l0"
5756   [(set_attr "itanium_class" "br")])
5757
5758 (define_insn "indirect_jump"
5759   [(set (pc) (match_operand:DI 0 "register_operand" "b"))]
5760   ""
5761   "br %0"
5762   [(set_attr "itanium_class" "br")])
5763
5764 (define_expand "tablejump"
5765   [(parallel [(set (pc) (match_operand:DI 0 "memory_operand" ""))
5766               (use (label_ref (match_operand 1 "" "")))])]
5767   ""
5768 {
5769   rtx op0 = operands[0];
5770   rtx addr;
5771
5772   /* ??? Bother -- do_tablejump is "helpful" and pulls the table
5773      element into a register without bothering to see whether that
5774      is necessary given the operand predicate.  Check for MEM just
5775      in case someone fixes this.  */
5776   if (GET_CODE (op0) == MEM)
5777     addr = XEXP (op0, 0);
5778   else
5779     {
5780       /* Otherwise, cheat and guess that the previous insn in the
5781          stream was the memory load.  Grab the address from that.
5782          Note we have to momentarily pop out of the sequence started
5783          by the insn-emit wrapper in order to grab the last insn.  */
5784       rtx last, set;
5785
5786       end_sequence ();
5787       last = get_last_insn ();
5788       start_sequence ();
5789       set = single_set (last);
5790
5791       if (! rtx_equal_p (SET_DEST (set), op0)
5792           || GET_CODE (SET_SRC (set)) != MEM)
5793         abort ();
5794       addr = XEXP (SET_SRC (set), 0);
5795       if (rtx_equal_p (addr, op0))
5796         abort ();
5797     }
5798
5799   /* Jump table elements are stored pc-relative.  That is, a displacement
5800      from the entry to the label.  Thus to convert to an absolute address
5801      we add the address of the memory from which the value is loaded.  */
5802   operands[0] = expand_simple_binop (DImode, PLUS, op0, addr,
5803                                      NULL_RTX, 1, OPTAB_DIRECT);
5804 })
5805
5806 (define_insn "*tablejump_internal"
5807   [(set (pc) (match_operand:DI 0 "register_operand" "b"))
5808    (use (label_ref (match_operand 1 "" "")))]
5809   ""
5810   "br %0"
5811   [(set_attr "itanium_class" "br")])
5812
5813 \f
5814 ;; ::::::::::::::::::::
5815 ;; ::
5816 ;; :: Prologue and Epilogue instructions
5817 ;; ::
5818 ;; ::::::::::::::::::::
5819
5820 (define_expand "prologue"
5821   [(const_int 1)]
5822   ""
5823 {
5824   ia64_expand_prologue ();
5825   DONE;
5826 })
5827
5828 (define_expand "epilogue"
5829   [(return)]
5830   ""
5831 {
5832   ia64_expand_epilogue (0);
5833   DONE;
5834 })
5835
5836 (define_expand "sibcall_epilogue"
5837   [(return)]
5838   ""
5839 {
5840   ia64_expand_epilogue (1);
5841   DONE;
5842 })
5843
5844 ;; This prevents the scheduler from moving the SP decrement past FP-relative
5845 ;; stack accesses.  This is the same as adddi3 plus the extra set.
5846
5847 (define_insn "prologue_allocate_stack"
5848   [(set (match_operand:DI 0 "register_operand" "=r,r,r")
5849         (plus:DI (match_operand:DI 1 "register_operand" "%r,r,a")
5850                  (match_operand:DI 2 "gr_reg_or_22bit_operand" "r,I,J")))
5851    (set (match_operand:DI 3 "register_operand" "+r,r,r")
5852         (match_dup 3))]
5853   ""
5854   "@
5855    add %0 = %1, %2
5856    adds %0 = %2, %1
5857    addl %0 = %2, %1"
5858   [(set_attr "itanium_class" "ialu")])
5859
5860 ;; This prevents the scheduler from moving the SP restore past FP-relative
5861 ;; stack accesses.  This is similar to movdi plus the extra set.
5862
5863 (define_insn "epilogue_deallocate_stack"
5864   [(set (match_operand:DI 0 "register_operand" "=r")
5865         (match_operand:DI 1 "register_operand" "+r"))
5866    (set (match_dup 1) (match_dup 1))]
5867   ""
5868   "mov %0 = %1"
5869   [(set_attr "itanium_class" "ialu")])
5870
5871 ;; As USE insns aren't meaningful after reload, this is used instead
5872 ;; to prevent deleting instructions setting registers for EH handling
5873 (define_insn "prologue_use"
5874   [(unspec:DI [(match_operand:DI 0 "register_operand" "")]
5875               UNSPEC_PROLOGUE_USE)]
5876   ""
5877   ""
5878   [(set_attr "itanium_class" "ignore")
5879    (set_attr "predicable" "no")
5880    (set_attr "empty" "yes")])
5881
5882 ;; Allocate a new register frame.
5883
5884 (define_insn "alloc"
5885   [(set (match_operand:DI 0 "register_operand" "=r")
5886         (unspec_volatile:DI [(const_int 0)] UNSPECV_ALLOC))
5887    (use (match_operand:DI 1 "const_int_operand" "i"))
5888    (use (match_operand:DI 2 "const_int_operand" "i"))
5889    (use (match_operand:DI 3 "const_int_operand" "i"))
5890    (use (match_operand:DI 4 "const_int_operand" "i"))]
5891   ""
5892   "alloc %0 = ar.pfs, %1, %2, %3, %4"
5893   [(set_attr "itanium_class" "syst_m0")
5894    (set_attr "predicable" "no")])
5895
5896 ;; Modifies ar.unat
5897 (define_expand "gr_spill"
5898   [(parallel [(set (match_operand:DI 0 "memory_operand" "=m")
5899                    (unspec:DI [(match_operand:DI 1 "register_operand" "r")
5900                                (match_operand:DI 2 "const_int_operand" "")]
5901                               UNSPEC_GR_SPILL))
5902               (clobber (match_dup 3))])]
5903   ""
5904   "operands[3] = gen_rtx_REG (DImode, AR_UNAT_REGNUM);")
5905
5906 (define_insn "gr_spill_internal"
5907   [(set (match_operand:DI 0 "memory_operand" "=m")
5908         (unspec:DI [(match_operand:DI 1 "register_operand" "r")
5909                     (match_operand:DI 2 "const_int_operand" "")]
5910                    UNSPEC_GR_SPILL))
5911    (clobber (match_operand:DI 3 "register_operand" ""))]
5912   ""
5913 {
5914   /* Note that we use a C output pattern here to avoid the predicate
5915      being automatically added before the .mem.offset directive.  */
5916   return ".mem.offset %2, 0\;%,st8.spill %0 = %1%P0";
5917 }
5918   [(set_attr "itanium_class" "st")])
5919
5920 ;; Reads ar.unat
5921 (define_expand "gr_restore"
5922   [(parallel [(set (match_operand:DI 0 "register_operand" "=r")
5923                    (unspec:DI [(match_operand:DI 1 "memory_operand" "m")
5924                                (match_operand:DI 2 "const_int_operand" "")]
5925                               UNSPEC_GR_RESTORE))
5926               (use (match_dup 3))])]
5927   ""
5928   "operands[3] = gen_rtx_REG (DImode, AR_UNAT_REGNUM);")
5929
5930 (define_insn "gr_restore_internal"
5931   [(set (match_operand:DI 0 "register_operand" "=r")
5932         (unspec:DI [(match_operand:DI 1 "memory_operand" "m")
5933                     (match_operand:DI 2 "const_int_operand" "")]
5934                    UNSPEC_GR_RESTORE))
5935    (use (match_operand:DI 3 "register_operand" ""))]
5936   ""
5937   { return ".mem.offset %2, 0\;%,ld8.fill %0 = %1%P1"; }
5938   [(set_attr "itanium_class" "ld")])
5939
5940 (define_insn "fr_spill"
5941   [(set (match_operand:XF 0 "memory_operand" "=m")
5942         (unspec:XF [(match_operand:XF 1 "register_operand" "f")]
5943                    UNSPEC_FR_SPILL))]
5944   ""
5945   "stf.spill %0 = %1%P0"
5946   [(set_attr "itanium_class" "stf")])
5947
5948 (define_insn "fr_restore"
5949   [(set (match_operand:XF 0 "register_operand" "=f")
5950         (unspec:XF [(match_operand:XF 1 "memory_operand" "m")]
5951                    UNSPEC_FR_RESTORE))]
5952   ""
5953   "ldf.fill %0 = %1%P1"
5954   [(set_attr "itanium_class" "fld")])
5955
5956 ;; ??? The explicit stop is not ideal.  It would be better if
5957 ;; rtx_needs_barrier took care of this, but this is something that can be
5958 ;; fixed later.  This avoids an RSE DV.
5959
5960 (define_insn "bsp_value"
5961   [(set (match_operand:DI 0 "register_operand" "=r")
5962         (unspec:DI [(const_int 0)] UNSPEC_BSP_VALUE))]
5963   ""
5964   "*
5965 {
5966   return \";;\;%,mov %0 = ar.bsp\";
5967 }"
5968   [(set_attr "itanium_class" "frar_i")])
5969
5970 (define_insn "set_bsp"
5971   [(unspec_volatile [(match_operand:DI 0 "register_operand" "r")]
5972                     UNSPECV_SET_BSP)]
5973   ""
5974   "flushrs
5975         mov r19=ar.rsc
5976         ;;
5977         and r19=0x1c,r19
5978         ;;
5979         mov ar.rsc=r19
5980         ;;
5981         mov ar.bspstore=%0
5982         ;;
5983         or r19=0x3,r19
5984         ;;
5985         loadrs
5986         invala
5987         ;;
5988         mov ar.rsc=r19"
5989   [(set_attr "itanium_class" "unknown")
5990    (set_attr "predicable" "no")])
5991
5992 ;; ??? The explicit stops are not ideal.  It would be better if
5993 ;; rtx_needs_barrier took care of this, but this is something that can be
5994 ;; fixed later.  This avoids an RSE DV.
5995
5996 (define_insn "flushrs"
5997   [(unspec [(const_int 0)] UNSPEC_FLUSHRS)]
5998   ""
5999   ";;\;flushrs\;;;"
6000   [(set_attr "itanium_class" "rse_m")
6001    (set_attr "predicable" "no")])
6002 \f
6003 ;; ::::::::::::::::::::
6004 ;; ::
6005 ;; :: Miscellaneous instructions
6006 ;; ::
6007 ;; ::::::::::::::::::::
6008
6009 ;; ??? Emitting a NOP instruction isn't very useful.  This should probably
6010 ;; be emitting ";;" to force a break in the instruction packing.
6011
6012 ;; No operation, needed in case the user uses -g but not -O.
6013 (define_insn "nop"
6014   [(const_int 0)]
6015   ""
6016   "nop 0"
6017   [(set_attr "itanium_class" "nop")])
6018
6019 (define_insn "nop_m"
6020   [(const_int 1)]
6021   ""
6022   "nop.m 0"
6023   [(set_attr "itanium_class" "nop_m")])
6024
6025 (define_insn "nop_i"
6026   [(const_int 2)]
6027   ""
6028   "nop.i 0"
6029   [(set_attr "itanium_class" "nop_i")])
6030
6031 (define_insn "nop_f"
6032   [(const_int 3)]
6033   ""
6034   "nop.f 0"
6035   [(set_attr "itanium_class" "nop_f")])
6036
6037 (define_insn "nop_b"
6038   [(const_int 4)]
6039   ""
6040   "nop.b 0"
6041   [(set_attr "itanium_class" "nop_b")])
6042
6043 (define_insn "nop_x"
6044   [(const_int 5)]
6045   ""
6046   ""
6047   [(set_attr "itanium_class" "nop_x")
6048    (set_attr "empty" "yes")])
6049
6050 ;; The following insn will be never generated.  It is used only by
6051 ;; insn scheduler to change state before advancing cycle.
6052 (define_insn "pre_cycle"
6053   [(const_int 6)]
6054   ""
6055   ""
6056   [(set_attr "itanium_class" "pre_cycle")])
6057
6058 (define_insn "bundle_selector"
6059   [(unspec [(match_operand 0 "const_int_operand" "")] UNSPEC_BUNDLE_SELECTOR)]
6060   ""
6061   { return get_bundle_name (INTVAL (operands[0])); }
6062   [(set_attr "itanium_class" "ignore")
6063    (set_attr "predicable" "no")])
6064
6065 ;; Pseudo instruction that prevents the scheduler from moving code above this
6066 ;; point.
6067 (define_insn "blockage"
6068   [(unspec_volatile [(const_int 0)] UNSPECV_BLOCKAGE)]
6069   ""
6070   ""
6071   [(set_attr "itanium_class" "ignore")
6072    (set_attr "predicable" "no")])
6073
6074 (define_insn "insn_group_barrier"
6075   [(unspec_volatile [(match_operand 0 "const_int_operand" "")]
6076                     UNSPECV_INSN_GROUP_BARRIER)]
6077   ""
6078   ";;"
6079   [(set_attr "itanium_class" "stop_bit")
6080    (set_attr "predicable" "no")
6081    (set_attr "empty" "yes")])
6082
6083 (define_expand "trap"
6084   [(trap_if (const_int 1) (const_int 0))]
6085   ""
6086   "")
6087
6088 ;; ??? We don't have a match-any slot type.  Setting the type to unknown
6089 ;; produces worse code that setting the slot type to A.
6090
6091 (define_insn "*trap"
6092   [(trap_if (const_int 1) (match_operand 0 "const_int_operand" ""))]
6093   ""
6094   "break %0"
6095   [(set_attr "itanium_class" "chk_s")])
6096
6097 (define_expand "conditional_trap"
6098   [(trap_if (match_operand 0 "" "") (match_operand 1 "" ""))]
6099   ""
6100 {
6101   operands[0] = ia64_expand_compare (GET_CODE (operands[0]), VOIDmode);
6102 })
6103
6104 (define_insn "*conditional_trap"
6105   [(trap_if (match_operator 0 "predicate_operator"
6106               [(match_operand:BI 1 "register_operand" "c")
6107                (const_int 0)])  
6108             (match_operand 2 "const_int_operand" ""))]
6109   ""
6110   "(%J0) break %2"
6111   [(set_attr "itanium_class" "chk_s")
6112    (set_attr "predicable" "no")])
6113
6114 (define_insn "break_f"
6115   [(unspec_volatile [(const_int 0)] UNSPECV_BREAK)]
6116   ""
6117   "break.f 0"
6118   [(set_attr "itanium_class" "nop_f")])
6119
6120 (define_insn "prefetch"
6121   [(prefetch (match_operand:DI 0 "address_operand" "p")
6122              (match_operand:DI 1 "const_int_operand" "n")
6123              (match_operand:DI 2 "const_int_operand" "n"))]
6124   ""
6125 {
6126   static const char * const alt[2][4] = {
6127     {
6128       "%,lfetch.nta [%0]",
6129       "%,lfetch.nt1 [%0]",
6130       "%,lfetch.nt2 [%0]",
6131       "%,lfetch [%0]"
6132     },
6133     {
6134       "%,lfetch.excl.nta [%0]",
6135       "%,lfetch.excl.nt1 [%0]",
6136       "%,lfetch.excl.nt2 [%0]",
6137       "%,lfetch.excl [%0]"
6138     }
6139   };
6140   int i = (INTVAL (operands[1]));
6141   int j = (INTVAL (operands[2]));
6142
6143   if (i != 0 && i != 1)
6144     abort ();
6145   if (j < 0 || j > 3)
6146     abort ();
6147   return alt[i][j];
6148 }
6149   [(set_attr "itanium_class" "lfetch")])
6150 \f
6151 ;; Non-local goto support.
6152
6153 (define_expand "save_stack_nonlocal"
6154   [(use (match_operand:OI 0 "memory_operand" ""))
6155    (use (match_operand:DI 1 "register_operand" ""))]
6156   ""
6157 {
6158   emit_library_call (gen_rtx_SYMBOL_REF (Pmode,
6159                                          \"__ia64_save_stack_nonlocal\"),
6160                      0, VOIDmode, 2, XEXP (operands[0], 0), Pmode,
6161                      operands[1], Pmode);
6162   DONE;
6163 })
6164
6165 (define_expand "nonlocal_goto"
6166   [(use (match_operand 0 "general_operand" ""))
6167    (use (match_operand 1 "general_operand" ""))
6168    (use (match_operand 2 "general_operand" ""))
6169    (use (match_operand 3 "general_operand" ""))]
6170   ""
6171 {
6172   emit_library_call (gen_rtx_SYMBOL_REF (Pmode, \"__ia64_nonlocal_goto\"),
6173                      LCT_NORETURN, VOIDmode, 3,
6174                      operands[1], Pmode,
6175                      copy_to_reg (XEXP (operands[2], 0)), Pmode,
6176                      operands[3], Pmode);
6177   emit_barrier ();
6178   DONE;
6179 })
6180
6181 (define_insn_and_split "builtin_setjmp_receiver"
6182   [(unspec_volatile [(match_operand:DI 0 "" "")] UNSPECV_SETJMP_RECEIVER)]
6183   ""
6184   "#"
6185   "reload_completed"
6186   [(const_int 0)]
6187 {
6188   ia64_reload_gp ();
6189   DONE;
6190 })
6191
6192 (define_expand "eh_epilogue"
6193   [(use (match_operand:DI 0 "register_operand" "r"))
6194    (use (match_operand:DI 1 "register_operand" "r"))
6195    (use (match_operand:DI 2 "register_operand" "r"))]
6196   ""
6197 {
6198   rtx bsp = gen_rtx_REG (Pmode, 10);
6199   rtx sp = gen_rtx_REG (Pmode, 9);
6200
6201   if (GET_CODE (operands[0]) != REG || REGNO (operands[0]) != 10)
6202     {
6203       emit_move_insn (bsp, operands[0]);
6204       operands[0] = bsp;
6205     }
6206   if (GET_CODE (operands[2]) != REG || REGNO (operands[2]) != 9)
6207     {
6208       emit_move_insn (sp, operands[2]);
6209       operands[2] = sp;
6210     }
6211   emit_insn (gen_rtx_USE (VOIDmode, sp));
6212   emit_insn (gen_rtx_USE (VOIDmode, bsp));
6213
6214   cfun->machine->ia64_eh_epilogue_sp = sp;
6215   cfun->machine->ia64_eh_epilogue_bsp = bsp;
6216 })
6217 \f
6218 ;; Builtin apply support.
6219
6220 (define_expand "restore_stack_nonlocal"
6221   [(use (match_operand:DI 0 "register_operand" ""))
6222    (use (match_operand:OI 1 "memory_operand" ""))]
6223   ""
6224 {
6225   emit_library_call (gen_rtx_SYMBOL_REF (Pmode,
6226                                          "__ia64_restore_stack_nonlocal"),
6227                      0, VOIDmode, 1,
6228                      copy_to_reg (XEXP (operands[1], 0)), Pmode);
6229   DONE;
6230 })
6231
6232 \f
6233 ;;; Intrinsics support.
6234
6235 (define_expand "mf"
6236   [(set (mem:BLK (match_dup 0))
6237         (unspec:BLK [(mem:BLK (match_dup 0))] UNSPEC_MF))]
6238   ""
6239 {
6240   operands[0] = gen_rtx_MEM (BLKmode, gen_rtx_SCRATCH (DImode));
6241   MEM_VOLATILE_P (operands[0]) = 1;
6242 })
6243
6244 (define_insn "*mf_internal"
6245   [(set (match_operand:BLK 0 "" "")
6246         (unspec:BLK [(match_operand:BLK 1 "" "")] UNSPEC_MF))]
6247   ""
6248   "mf"
6249   [(set_attr "itanium_class" "syst_m")])
6250
6251 (define_insn "fetchadd_acq_si"
6252   [(set (match_operand:SI 0 "gr_register_operand" "=r")
6253         (match_operand:SI 1 "not_postinc_memory_operand" "+S"))
6254    (set (match_dup 1)
6255         (unspec:SI [(match_dup 1)
6256                     (match_operand:SI 2 "fetchadd_operand" "n")]
6257                    UNSPEC_FETCHADD_ACQ))]
6258   ""
6259   "fetchadd4.acq %0 = %1, %2"
6260   [(set_attr "itanium_class" "sem")])
6261
6262 (define_insn "fetchadd_acq_di"
6263   [(set (match_operand:DI 0 "gr_register_operand" "=r")
6264         (match_operand:DI 1 "not_postinc_memory_operand" "+S"))
6265    (set (match_dup 1)
6266         (unspec:DI [(match_dup 1)
6267                     (match_operand:DI 2 "fetchadd_operand" "n")]
6268                    UNSPEC_FETCHADD_ACQ))]
6269   ""
6270   "fetchadd8.acq %0 = %1, %2"
6271   [(set_attr "itanium_class" "sem")])
6272
6273 (define_insn "cmpxchg_acq_si"
6274   [(set (match_operand:SI 0 "gr_register_operand" "=r")
6275         (match_operand:SI 1 "not_postinc_memory_operand" "+S"))
6276    (set (match_dup 1)
6277         (unspec:SI [(match_dup 1)
6278                     (match_operand:SI 2 "gr_register_operand" "r")
6279                     (match_operand:DI 3 "ar_ccv_reg_operand" "")]
6280                    UNSPEC_CMPXCHG_ACQ))]
6281   ""
6282   "cmpxchg4.acq %0 = %1, %2, %3"
6283   [(set_attr "itanium_class" "sem")])
6284
6285 (define_insn "cmpxchg_acq_di"
6286   [(set (match_operand:DI 0 "gr_register_operand" "=r")
6287         (match_operand:DI 1 "not_postinc_memory_operand" "+S"))
6288    (set (match_dup 1)
6289         (unspec:DI [(match_dup 1)
6290                     (match_operand:DI 2 "gr_register_operand" "r")
6291                     (match_operand:DI 3 "ar_ccv_reg_operand" "")]
6292                    UNSPEC_CMPXCHG_ACQ))]
6293   ""
6294   "cmpxchg8.acq %0 = %1, %2, %3"
6295   [(set_attr "itanium_class" "sem")])
6296
6297 (define_insn "xchgsi"
6298   [(set (match_operand:SI 0 "gr_register_operand" "=r")
6299         (match_operand:SI 1 "not_postinc_memory_operand" "+S"))
6300    (set (match_dup 1)
6301         (match_operand:SI 2 "gr_register_operand" "r"))]
6302   ""
6303   "xchg4 %0 = %1, %2"
6304   [(set_attr "itanium_class" "sem")])
6305
6306 (define_insn "xchgdi"
6307   [(set (match_operand:DI 0 "gr_register_operand" "=r")
6308         (match_operand:DI 1 "not_postinc_memory_operand" "+S"))
6309    (set (match_dup 1)
6310         (match_operand:DI 2 "gr_register_operand" "r"))]
6311   ""
6312   "xchg8 %0 = %1, %2"
6313   [(set_attr "itanium_class" "sem")])
6314 \f
6315 ;; Predication.
6316
6317 (define_cond_exec
6318   [(match_operator 0 "predicate_operator"
6319      [(match_operand:BI 1 "register_operand" "c")
6320       (const_int 0)])]
6321   ""
6322   "(%J0)")
6323
6324 (define_insn "pred_rel_mutex"
6325   [(set (match_operand:BI 0 "register_operand" "+c")
6326        (unspec:BI [(match_dup 0)] UNSPEC_PRED_REL_MUTEX))]
6327   ""
6328   ".pred.rel.mutex %0, %I0"
6329   [(set_attr "itanium_class" "ignore")
6330    (set_attr "predicable" "no")])
6331
6332 (define_insn "safe_across_calls_all"
6333   [(unspec_volatile [(const_int 0)] UNSPECV_PSAC_ALL)]
6334   ""
6335   ".pred.safe_across_calls p1-p63"
6336   [(set_attr "itanium_class" "ignore")
6337    (set_attr "predicable" "no")])
6338
6339 (define_insn "safe_across_calls_normal"
6340   [(unspec_volatile [(const_int 0)] UNSPECV_PSAC_NORMAL)]
6341   ""
6342 {
6343   emit_safe_across_calls ();
6344   return "";
6345 }
6346   [(set_attr "itanium_class" "ignore")
6347    (set_attr "predicable" "no")])
6348
6349 ;; UNSPEC instruction definition to "swizzle" 32 bit pointer into 64 bit
6350 ;; pointer.  This is used by the HP-UX 32 bit mode.
6351
6352 (define_insn "ptr_extend"
6353   [(set (match_operand:DI 0 "gr_register_operand" "=r")
6354         (unspec:DI [(match_operand:SI 1 "gr_register_operand" "r")]
6355                    UNSPEC_ADDP4))]
6356   ""
6357   "addp4 %0 = 0,%1"
6358   [(set_attr "itanium_class" "ialu")])
6359
6360 ;;
6361 ;; Optimizations for ptr_extend
6362
6363 (define_insn "ptr_extend_plus_imm"
6364   [(set (match_operand:DI 0 "gr_register_operand" "=r")
6365         (unspec:DI
6366          [(plus:SI (match_operand:SI 1 "basereg_operand" "r")
6367                    (match_operand:SI 2 "gr_reg_or_14bit_operand" "rI"))]
6368          UNSPEC_ADDP4))]
6369   "addp4_optimize_ok (operands[1], operands[2])"
6370   "addp4 %0 = %2, %1"
6371   [(set_attr "itanium_class" "ialu")])
6372
6373 (define_insn "*ptr_extend_plus_2"
6374   [(set (match_operand:DI 0 "gr_register_operand" "=r")
6375         (unspec:DI
6376          [(plus:SI (match_operand:SI 1 "gr_register_operand" "r")
6377                    (match_operand:SI 2 "basereg_operand" "r"))]
6378          UNSPEC_ADDP4))]
6379   "addp4_optimize_ok (operands[1], operands[2])"
6380   "addp4 %0 = %1, %2"
6381   [(set_attr "itanium_class" "ialu")])