OSDN Git Service

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