OSDN Git Service

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