This commit was manufactured by cvs2svn to create branch
[official-gcc.git] / gcc / config / cris / cris.md
blob7e96d22b65e21c4a462e4f0ad7c78cbf12f79509
1 ;; GCC machine description for CRIS cpu cores.
2 ;; Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003 Free Software Foundation, Inc.
3 ;; Contributed by Axis Communications.
5 ;; This file is part of GCC.
6 ;;
7 ;; GCC is free software; you can redistribute it and/or modify
8 ;; it under the terms of the GNU General Public License as published by
9 ;; the Free Software Foundation; either version 2, or (at your option)
10 ;; any later version.
12 ;; GCC is distributed in the hope that it will be useful,
13 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
14 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 ;; GNU General Public License for more details.
17 ;; You should have received a copy of the GNU General Public License
18 ;; along with GCC; see the file COPYING.  If not, write to
19 ;; the Free Software Foundation, 59 Temple Place - Suite 330,
20 ;; Boston, MA 02111-1307, USA.
22 ;; The original PO technology requires these to be ordered by speed,
23 ;; so that assigner will pick the fastest.
25 ;; See files "md.texi" and "rtl.def" for documentation on define_insn,
26 ;; match_*, et. al.
28 ;; The function cris_notice_update_cc in cris.c handles condition code
29 ;; updates for most instructions, helped by the "cc" attribute.
31 ;; There are several instructions that are orthogonal in size, and seems
32 ;; they could be matched by a single pattern without a specified size
33 ;; for the operand that is orthogonal.  However, this did not work on
34 ;; gcc-2.7.2 (and probably not on gcc-2.8.1), relating to that when a
35 ;; constant is substituted into an operand, the actual mode must be
36 ;; deduced from the pattern.  There is reasonable hope that that has been
37 ;; fixed, so FIXME: try again.
39 ;; You will notice that three-operand alternatives ("=r", "r", "!To")
40 ;; are marked with a "!" constraint modifier to avoid being reloaded
41 ;; into.  This is because gcc would otherwise prefer to use the constant
42 ;; pool and its offsettable address instead of reloading to an
43 ;; ("=r", "0", "i") alternative.  Also, the constant-pool support was not
44 ;; only suboptimal but also buggy in 2.7.2, ??? maybe only in 2.6.3.
46 ;; All insns that look like (set (...) (plus (...) (reg:SI 8)))
47 ;; get problems when reloading r8 (frame pointer) to r14 + offs (stack
48 ;; pointer).  Thus the instructions that get into trouble have specific
49 ;; checks against matching frame_pointer_rtx.
50 ;; ??? But it should be re-checked for gcc > 2.7.2
51 ;; FIXME: This changed some time ago (from 2000-03-16) for gcc-2.9x.
53 ;; FIXME: When PIC, all [rX=rY+S] could be enabled to match
54 ;; [rX=gotless_symbol].
55 ;; The movsi for a gotless symbol could be split (post reload).
57 ;; UNSPEC Usage:
58 ;; 0 PLT reference from call expansion: operand 0 is the address,
59 ;;   the mode is VOIDmode.  Always wrapped in CONST.
61 ;; We need an attribute to define whether an instruction can be put in
62 ;; a branch-delay slot or not, and whether it has a delay slot.
64 ;; Branches and return instructions have a delay slot, and cannot
65 ;; themselves be put in a delay slot.  This has changed *for short
66 ;; branches only* between architecture variants, but the possible win
67 ;; is presumed negligible compared to the added complexity of the machine
68 ;; description: one would have to add always-correct infrastructure to
69 ;; distinguish short branches.
71 ;; Whether an instruction can be put in a delay slot depends on the
72 ;; instruction (all short instructions except jumps and branches)
73 ;; and the addressing mode (must not be prefixed or referring to pc).
74 ;; In short, any "slottable" instruction must be 16 bit and not refer
75 ;; to pc, or alter it.
77 ;; The possible values are "yes", "no" and "has_slot".  Yes/no means if
78 ;; the insn is slottable or not.  Has_slot means that the insn is a
79 ;; return insn or branch insn (which are not considered slottable since
80 ;; that is generally true).  Having the seemingly illogical value
81 ;; "has_slot" means we do not have to add another attribute just to say
82 ;; that an insn has a delay-slot, since it also infers that it is not
83 ;; slottable.  Better names for the attribute were found to be longer and
84 ;; not add readability to the machine description.
86 ;; The default that is defined here for this attribute is "no", not
87 ;; slottable, not having a delay-slot, so there's no need to worry about
88 ;; it being wrong for non-branch and return instructions.
89 ;;  The default could depend on the kind of insn and the addressing
90 ;; mode, but that would need more attributes and hairier, more error
91 ;; prone code.
93 ;;  There is an extra constraint, 'Q', which recognizes indirect reg,
94 ;; except when the reg is pc.  The constraints 'Q' and '>' together match
95 ;; all possible memory operands that are slottable.
96 ;;  For other operands, you need to check if it has a valid "slottable"
97 ;; quick-immediate operand, where the particular signedness-variation
98 ;; may match the constraints 'I' or 'J'.), and include it in the
99 ;; constraint pattern for the slottable pattern.  An alternative using
100 ;; only "r" constraints is most often slottable.
102 (define_attr "slottable" "no,yes,has_slot" (const_string "no"))
104 ;; We also need attributes to sanely determine the condition code
105 ;; state.  See cris_notice_update_cc for how this is used.
107 (define_attr "cc" "none,clobber,normal" (const_string "normal"))
109 ;; A branch or return has one delay-slot.  The instruction in the
110 ;; delay-slot is always executed, independent of whether the branch is
111 ;; taken or not.  Note that besides setting "slottable" to "has_slot",
112 ;; there also has to be a "%#" at the end of a "delayed" instruction
113 ;; output pattern (for "jump" this means "ba %l0%#"), so print_operand can
114 ;; catch it and print a "nop" if necessary.  This method was stolen from
115 ;; sparc.md.
117 (define_delay (eq_attr "slottable" "has_slot")
118   [(eq_attr "slottable" "yes") (nil) (nil)])
120 ;; Test insns.
122 ;; DImode
124 ;; Allow register and offsettable mem operands only; post-increment is
125 ;; not worth the trouble.
127 (define_insn "tstdi"
128   [(set (cc0)
129         (match_operand:DI 0 "nonimmediate_operand" "r,o"))]
130   ""
131   "test.d %M0\;ax\;test.d %H0")
133 ;; No test insns with side-effect on the mem addressing.
135 ;; See note on cmp-insns with side-effects (or lack of them)
137 ;; Normal named test patterns from SI on.
138 ;; FIXME: Seems they should change to be in order smallest..largest.
140 (define_insn "tstsi"
141   [(set (cc0)
142         (match_operand:SI 0 "nonimmediate_operand" "r,Q>,m"))]
143   ""
144   "test.d %0"
145   [(set_attr "slottable" "yes,yes,no")])
147 (define_insn "tsthi"
148   [(set (cc0)
149         (match_operand:HI 0 "nonimmediate_operand" "r,Q>,m"))]
150   ""
151   "test.w %0"
152   [(set_attr "slottable" "yes,yes,no")])
154 (define_insn "tstqi"
155   [(set (cc0)
156         (match_operand:QI 0 "nonimmediate_operand" "r,Q>,m"))]
157   ""
158   "test.b %0"
159   [(set_attr "slottable" "yes,yes,no")])
161 ;; It seems that the position of the sign-bit and the fact that 0.0 is
162 ;; all 0-bits would make "tstsf" a straight-forward implementation;
163 ;; either "test.d" it for positive/negative or "btstq 30,r" it for
164 ;; zeroness.
166 ;; FIXME: Do that some time; check next_cc0_user to determine if
167 ;; zero or negative is tested for.
169 ;; Compare insns.
171 ;; We could optimize the sizes of the immediate operands for various
172 ;; cases, but that is not worth it because of the very little usage of
173 ;; DImode for anything else but a structure/block-mode.  Just do the
174 ;; obvious stuff for the straight-forward constraint letters.
176 (define_insn "cmpdi"
177   [(set (cc0)
178         (compare (match_operand:DI 0 "nonimmediate_operand" "r,r,r,r,r,r,o")
179                  (match_operand:DI 1 "general_operand" "K,I,P,n,r,o,r")))]
180   ""
181   "@
182    cmpq %1,%M0\;ax\;cmpq 0,%H0
183    cmpq %1,%M0\;ax\;cmpq -1,%H0
184    cmp%e1.%z1 %1,%M0\;ax\;cmpq %H1,%H0
185    cmp.d %M1,%M0\;ax\;cmp.d %H1,%H0
186    cmp.d %M1,%M0\;ax\;cmp.d %H1,%H0
187    cmp.d %M1,%M0\;ax\;cmp.d %H1,%H0
188    cmp.d %M0,%M1\;ax\;cmp.d %H0,%H1")
190 ;; Note that compare insns with side effect addressing mode (e.g.):
192 ;; cmp.S [rx=ry+i],rz;
193 ;; cmp.S [%3=%1+%2],%0
195 ;; are *not* usable for gcc since the reloader *does not accept*
196 ;; cc0-changing insns with side-effects other than setting the condition
197 ;; codes.  The reason is that the reload stage *may* cause another insn to
198 ;; be output after the main instruction, in turn invalidating cc0 for the
199 ;; insn using the test.  (This does not apply to the CRIS case, since a
200 ;; reload for output -- move to memory -- does not change the condition
201 ;; code.  Unfortunately we have no way to describe that at the moment.  I
202 ;; think code would improve being in the order of one percent faster.
204 ;; We have cmps and cmpu (compare reg w. sign/zero extended mem).
205 ;; These are mostly useful for compares in SImode, using 8 or 16-bit
206 ;; constants, but sometimes gcc will find its way to use it for other
207 ;; (memory) operands.  Avoid side-effect patterns, though (see above).
209 ;; FIXME: These could have an anonymous mode for operand 1.
211 ;; QImode
213 (define_insn "*cmp_extsi"
214   [(set (cc0)
215         (compare
216          (match_operand:SI 0 "register_operand" "r,r")
217          (match_operator:SI 2 "cris_extend_operator"
218                          [(match_operand:QI 1 "memory_operand" "Q>,m")])))]
219   ""
220   "cmp%e2.%s1 %1,%0"
221   [(set_attr "slottable" "yes,no")])
223 ;; HImode
224 (define_insn "*cmp_exthi"
225   [(set (cc0)
226         (compare
227          (match_operand:SI 0 "register_operand" "r,r")
228          (match_operator:SI 2 "cris_extend_operator"
229                          [(match_operand:HI 1 "memory_operand" "Q>,m")])))]
230   ""
231   "cmp%e2.%s1 %1,%0"
232   [(set_attr "slottable" "yes,no")])
234 ;; Swap operands; it seems the canonical look (if any) is not enforced.
236 ;; FIXME: Investigate that.
237 ;; FIXME: These could have an anonymous mode for operand 1.
239 ;; QImode
241 (define_insn "*cmp_swapextqi"
242   [(set (cc0)
243         (compare
244          (match_operator:SI 2 "cris_extend_operator"
245                             [(match_operand:QI 0 "memory_operand" "Q>,m")])
246          (match_operand:SI 1 "register_operand" "r,r")))]
247   ""
248   "cmp%e2.%s0 %0,%1" ; The function cris_notice_update_cc knows about
249                      ; swapped operands to compares.
250   [(set_attr "slottable" "yes,no")])
252 ;; HImode
254 (define_insn "*cmp_swapexthi"
255   [(set (cc0)
256         (compare
257          (match_operator:SI 2 "cris_extend_operator"
258                             [(match_operand:HI 0 "memory_operand" "Q>,m")])
259          (match_operand:SI 1 "register_operand" "r,r")))]
260   ""
261   "cmp%e2.%s0 %0,%1" ; The function cris_notice_update_cc knows about
262                      ; swapped operands to compares.
263   [(set_attr "slottable" "yes,no")])
265 ;; The "normal" compare patterns, from SI on.
267 (define_insn "cmpsi"
268   [(set (cc0)
269         (compare
270          (match_operand:SI 0 "nonimmediate_operand" "r,r,r,r,Q>,Q>,r,r,m,m")
271          (match_operand:SI 1 "general_operand" "I,r,Q>,M,M,r,P,g,M,r")))]
272   ""
273   "@
274    cmpq %1,%0
275    cmp.d %1,%0
276    cmp.d %1,%0
277    test.d %0
278    test.d %0
279    cmp.d %0,%1
280    cmp%e1.%z1 %1,%0
281    cmp.d %1,%0
282    test.d %0
283    cmp.d %0,%1"
284   [(set_attr "slottable" "yes,yes,yes,yes,yes,yes,no,no,no,no")])
286 (define_insn "cmphi"
287   [(set (cc0)
288         (compare (match_operand:HI 0 "nonimmediate_operand" "r,r,Q>,Q>,r,m,m")
289                  (match_operand:HI 1 "general_operand" "r,Q>,M,r,g,M,r")))]
290   ""
291   "@
292    cmp.w %1,%0
293    cmp.w %1,%0
294    test.w %0
295    cmp.w %0,%1
296    cmp.w %1,%0
297    test.w %0
298    cmp.w %0,%1"
299   [(set_attr "slottable" "yes,yes,yes,yes,no,no,no")])
301 (define_insn "cmpqi"
302   [(set (cc0)
303         (compare
304          (match_operand:QI 0 "nonimmediate_operand" "r,r,r,Q>,Q>,r,m,m")
305          (match_operand:QI 1 "general_operand" "r,Q>,M,M,r,g,M,r")))]
306   ""
307   "@
308    cmp.b %1,%0
309    cmp.b %1,%0
310    test.b %0
311    test.b %0
312    cmp.b %0,%1
313    cmp.b %1,%0
314    test.b %0
315    cmp.b %0,%1"
316   [(set_attr "slottable" "yes,yes,yes,yes,yes,no,no,no")])
318 ;; Pattern matching the BTST insn.
319 ;; It is useful for "if (i & val)" constructs, where val is an exact
320 ;; power of 2, or if val + 1 is a power of two, where we check for a bunch
321 ;; of zeros starting at bit 0).
323 ;; SImode.  This mode is the only one needed, since gcc automatically
324 ;; extends subregs for lower-size modes.  FIXME: Add testcase.
325 (define_insn "*btst"
326   [(set (cc0)
327         (zero_extract
328          (match_operand:SI 0 "nonmemory_operand" "r,r,r,r,r,r,n")
329          (match_operand:SI 1 "const_int_operand" "K,n,K,n,K,n,n")
330          (match_operand:SI 2 "nonmemory_operand" "M,M,K,n,r,r,r")))]
331   ;; Either it is a single bit, or consecutive ones starting at 0.
332   "GET_CODE (operands[1]) == CONST_INT
333    && (operands[1] == const1_rtx || operands[2] == const0_rtx)
334    && (REG_S_P (operands[0])
335        || (operands[1] == const1_rtx
336            && REG_S_P (operands[2])
337            && GET_CODE (operands[0]) == CONST_INT
338            && exact_log2 (INTVAL (operands[0])) >= 0))"
340 ;; The last "&&" condition above should be caught by some kind of
341 ;; canonicalization in gcc, but we can easily help with it here.
342 ;;  It results from expressions of the type
343 ;; "power_of_2_value & (1 << y)".
345 ;; Since there may be codes with tests in on bits (in constant position)
346 ;; beyond the size of a word, handle that by assuming those bits are 0.
347 ;; GCC should handle that, but it's a matter of easily-added belts while
348 ;; having suspenders.
350   "@
351    btstq (%1-1),%0
352    test.d %0
353    btstq %2,%0
354    clearf nz
355    btst %2,%0
356    clearf nz
357    cmpq %p0,%2"
358  [(set_attr "slottable" "yes")])
360 ;; Move insns.
362 ;; The whole mandatory movdi family is here; expander, "anonymous"
363 ;; recognizer and splitter.  We're forced to have a movdi pattern,
364 ;; although GCC should be able to split it up itself.  Normally it can,
365 ;; but if other insns have DI operands (as is the case here), reload
366 ;; must be able to generate or match a movdi.  many testcases fail at
367 ;; -O3 or -fssa if we don't have this.  FIXME: Fix GCC...  See
368 ;; <URL:http://gcc.gnu.org/ml/gcc-patches/2000-04/msg00104.html>.
369 ;; However, a patch from Richard Kenner (similar to the cause of
370 ;; discussion at the URL above), indicates otherwise.  See
371 ;; <URL:http://gcc.gnu.org/ml/gcc-patches/2000-04/msg00554.html>.
372 ;; The truth has IMO is not been decided yet, so check from time to
373 ;; time by disabling the movdi patterns.
375 (define_expand "movdi"
376   [(set (match_operand:DI 0 "nonimmediate_operand" "")
377         (match_operand:DI 1 "general_operand" ""))]
378   ""
379   "
381   if (GET_CODE (operands[0]) == MEM && operands[1] != const0_rtx)
382     operands[1] = copy_to_mode_reg (DImode, operands[1]);
384   /* Some other ports (as of 2001-09-10 for example mcore and romp) also
385      prefer to split up constants early, like this.  The testcase in
386      gcc.c-torture/execute/961213-1.c shows that CSE2 gets confused by the
387      resulting subreg sets when using the construct from mcore (as of FSF
388      CVS, version -r 1.5), and it believes that the high part (the last one
389      emitted) is the final value.  This construct from romp seems more
390      robust, especially considering the head comments from
391      emit_no_conflict_block.  */
392   if ((GET_CODE (operands[1]) == CONST_INT
393        || GET_CODE (operands[1]) == CONST_DOUBLE)
394       && ! reload_completed
395       && ! reload_in_progress)
396     {
397       rtx insns;
398       rtx op0 = operands[0];
399       rtx op1 = operands[1];
401       start_sequence ();
402       emit_move_insn (operand_subword (op0, 0, 1, DImode),
403                       operand_subword (op1, 0, 1, DImode));
404       emit_move_insn (operand_subword (op0, 1, 1, DImode),
405                       operand_subword (op1, 1, 1, DImode));
406       insns = get_insns ();
407       end_sequence ();
409       emit_no_conflict_block (insns, op0, op1, 0, op1);
410       DONE;
411     }
414 (define_insn "*movdi_insn"
415   [(set (match_operand:DI 0 "nonimmediate_operand" "=r,r,m")
416         (match_operand:DI 1 "general_operand" "r,g,rM"))]
417   "register_operand (operands[0], DImode)
418    || register_operand (operands[1], DImode)
419    || operands[1] == const0_rtx"
420   "#")
422 (define_split
423   [(set (match_operand:DI 0 "nonimmediate_operand" "")
424         (match_operand:DI 1 "general_operand" ""))]
425   "reload_completed"
426   [(match_dup 2)]
427   "operands[2] = cris_split_movdx (operands);")
429 ;; Side-effect patterns for move.S1 [rx=ry+rx.S2],rw
430 ;; and move.S1 [rx=ry+i],rz
431 ;;  Then movs.S1 and movu.S1 for both modes.
433 ;; move.S1 [rx=ry+rz.S],rw avoiding when rx is ry, or rw is rx
434 ;; FIXME: These could have anonymous mode for operand 0.
436 ;; QImode
438 (define_insn "*mov_sideqi_biap"
439   [(set (match_operand:QI 0 "register_operand" "=r,r")
440         (mem:QI (plus:SI
441                  (mult:SI (match_operand:SI 1 "register_operand" "r,r")
442                           (match_operand:SI 2 "const_int_operand" "n,n"))
443                  (match_operand:SI 3 "register_operand" "r,r"))))
444    (set (match_operand:SI 4 "register_operand" "=*3,r")
445         (plus:SI (mult:SI (match_dup 1)
446                           (match_dup 2))
447                  (match_dup 3)))]
448   "cris_side_effect_mode_ok (MULT, operands, 4, 3, 1, 2, 0)"
449   "@
450    #
451    move.%s0 [%4=%3+%1%T2],%0")
453 ;; HImode
455 (define_insn "*mov_sidehi_biap"
456   [(set (match_operand:HI 0 "register_operand" "=r,r")
457         (mem:HI (plus:SI
458                  (mult:SI (match_operand:SI 1 "register_operand" "r,r")
459                           (match_operand:SI 2 "const_int_operand" "n,n"))
460                  (match_operand:SI 3 "register_operand" "r,r"))))
461    (set (match_operand:SI 4 "register_operand" "=*3,r")
462         (plus:SI (mult:SI (match_dup 1)
463                           (match_dup 2))
464                  (match_dup 3)))]
465   "cris_side_effect_mode_ok (MULT, operands, 4, 3, 1, 2, 0)"
466   "@
467    #
468    move.%s0 [%4=%3+%1%T2],%0")
470 ;; SImode
472 (define_insn "*mov_sidesi_biap"
473   [(set (match_operand:SI 0 "register_operand" "=r,r")
474         (mem:SI (plus:SI
475                  (mult:SI (match_operand:SI 1 "register_operand" "r,r")
476                           (match_operand:SI 2 "const_int_operand" "n,n"))
477                  (match_operand:SI 3 "register_operand" "r,r"))))
478    (set (match_operand:SI 4 "register_operand" "=*3,r")
479         (plus:SI (mult:SI (match_dup 1)
480                           (match_dup 2))
481                  (match_dup 3)))]
482   "cris_side_effect_mode_ok (MULT, operands, 4, 3, 1, 2, 0)"
483   "@
484    #
485    move.%s0 [%4=%3+%1%T2],%0")
487 ;; move.S1 [rx=ry+i],rz
488 ;; avoiding move.S1 [ry=ry+i],rz
489 ;; and      move.S1 [rz=ry+i],rz
490 ;; Note that "i" is allowed to be a register.
491 ;; FIXME: These could have anonymous mode for operand 0.
493 ;; QImode
495 (define_insn "*mov_sideqi"
496   [(set (match_operand:QI 0 "register_operand" "=r,r,r")
497         (mem:QI
498          (plus:SI (match_operand:SI 1 "cris_bdap_operand" "%r,r,r")
499                   (match_operand:SI 2 "cris_bdap_operand" "r>Rn,r,>Rn"))))
500    (set (match_operand:SI 3 "register_operand" "=*1,r,r")
501         (plus:SI (match_dup 1)
502                  (match_dup 2)))]
503   "cris_side_effect_mode_ok (PLUS, operands, 3, 1, 2, -1, 0)"
504   "*
506   if (which_alternative == 0
507       && (GET_CODE (operands[2]) != CONST_INT
508           || INTVAL (operands[2]) > 127
509           || INTVAL (operands[2]) < -128
510           || CONST_OK_FOR_LETTER_P (INTVAL (operands[2]), 'N')
511           || CONST_OK_FOR_LETTER_P (INTVAL (operands[2]), 'J')))
512     return \"#\";
513   return \"move.%s0 [%3=%1%S2],%0\";
516 ;; HImode
518 (define_insn "*mov_sidehi"
519   [(set (match_operand:HI 0 "register_operand" "=r,r,r")
520         (mem:HI
521          (plus:SI (match_operand:SI 1 "cris_bdap_operand" "%r,r,r")
522                   (match_operand:SI 2 "cris_bdap_operand" "r>Rn,r,>Rn"))))
523    (set (match_operand:SI 3 "register_operand" "=*1,r,r")
524         (plus:SI (match_dup 1)
525                  (match_dup 2)))]
526   "cris_side_effect_mode_ok (PLUS, operands, 3, 1, 2, -1, 0)"
527   "*
529   if (which_alternative == 0
530       && (GET_CODE (operands[2]) != CONST_INT
531           || INTVAL (operands[2]) > 127
532           || INTVAL (operands[2]) < -128
533           || CONST_OK_FOR_LETTER_P (INTVAL (operands[2]), 'N')
534           || CONST_OK_FOR_LETTER_P (INTVAL (operands[2]), 'J')))
535     return \"#\";
536   return \"move.%s0 [%3=%1%S2],%0\";
539 ;; SImode
541 (define_insn "*mov_sidesi"
542   [(set (match_operand:SI 0 "register_operand" "=r,r,r")
543         (mem:SI
544          (plus:SI (match_operand:SI 1 "cris_bdap_operand" "%r,r,r")
545                   (match_operand:SI 2 "cris_bdap_operand" "r>Rn,r,>Rn"))))
546    (set (match_operand:SI 3 "register_operand" "=*1,r,r")
547         (plus:SI (match_dup 1)
548                  (match_dup 2)))]
549   "cris_side_effect_mode_ok (PLUS, operands, 3, 1, 2, -1, 0)"
550   "*
552   if (which_alternative == 0
553       && (GET_CODE (operands[2]) != CONST_INT
554           || INTVAL (operands[2]) > 127
555           || INTVAL (operands[2]) < -128
556           || CONST_OK_FOR_LETTER_P (INTVAL (operands[2]), 'N')
557           || CONST_OK_FOR_LETTER_P (INTVAL (operands[2]), 'J')))
558     return \"#\";
559   return \"move.%s0 [%3=%1%S2],%0\";
562 ;; Other way around; move to memory.
564 ;; Note that the condition (which for side-effect patterns is usually a
565 ;; call to cris_side_effect_mode_ok), isn't consulted for register
566 ;; allocation preferences -- constraints is the method for that.  The
567 ;; drawback is that we can't exclude register allocation to cause
568 ;; "move.s rw,[rx=ry+rz.S]" when rw==rx without also excluding rx==ry or
569 ;; rx==rz if we use an earlyclobber modifier for the constraint for rx.
570 ;; Instead of that, we recognize and split the cases where dangerous
571 ;; register combinations are spotted: where a register is set in the
572 ;; side-effect, and used in the main insn.  We don't handle the case where
573 ;; the set in the main insn overlaps the set in the side-effect; that case
574 ;; must be handled in gcc.  We handle just the case where the set in the
575 ;; side-effect overlaps the input operand of the main insn (i.e. just
576 ;; moves to memory).
579 ;; move.s rz,[ry=rx+rw.S]
580 ;; FIXME: These could have anonymous mode for operand 3.
582 ;; QImode
584 (define_insn "*mov_sideqi_biap_mem"
585   [(set (mem:QI (plus:SI
586                  (mult:SI (match_operand:SI 0 "register_operand" "r,r,r")
587                           (match_operand:SI 1 "const_int_operand" "n,n,n"))
588                  (match_operand:SI 2 "register_operand" "r,r,r")))
589         (match_operand:QI 3 "register_operand" "r,r,r"))
590    (set (match_operand:SI 4 "register_operand" "=*2,!3,r")
591         (plus:SI (mult:SI (match_dup 0)
592                           (match_dup 1))
593                  (match_dup 2)))]
594   "cris_side_effect_mode_ok (MULT, operands, 4, 2, 0, 1, 3)"
595   "@
596    #
597    #
598    move.%s3 %3,[%4=%2+%0%T1]")
600 ;; HImode
602 (define_insn "*mov_sidehi_biap_mem"
603   [(set (mem:HI (plus:SI
604                  (mult:SI (match_operand:SI 0 "register_operand" "r,r,r")
605                           (match_operand:SI 1 "const_int_operand" "n,n,n"))
606                  (match_operand:SI 2 "register_operand" "r,r,r")))
607         (match_operand:HI 3 "register_operand" "r,r,r"))
608    (set (match_operand:SI 4 "register_operand" "=*2,!3,r")
609         (plus:SI (mult:SI (match_dup 0)
610                           (match_dup 1))
611                  (match_dup 2)))]
612   "cris_side_effect_mode_ok (MULT, operands, 4, 2, 0, 1, 3)"
613   "@
614    #
615    #
616    move.%s3 %3,[%4=%2+%0%T1]")
618 ;; SImode
620 (define_insn "*mov_sidesi_biap_mem"
621   [(set (mem:SI (plus:SI
622                  (mult:SI (match_operand:SI 0 "register_operand" "r,r,r")
623                           (match_operand:SI 1 "const_int_operand" "n,n,n"))
624                  (match_operand:SI 2 "register_operand" "r,r,r")))
625         (match_operand:SI 3 "register_operand" "r,r,r"))
626    (set (match_operand:SI 4 "register_operand" "=*2,!3,r")
627         (plus:SI (mult:SI (match_dup 0)
628                           (match_dup 1))
629                  (match_dup 2)))]
630   "cris_side_effect_mode_ok (MULT, operands, 4, 2, 0, 1, 3)"
631   "@
632    #
633    #
634    move.%s3 %3,[%4=%2+%0%T1]")
636 ;; Split for the case above where we're out of luck with register
637 ;; allocation (again, the condition isn't checked for that), and we end up
638 ;; with the set in the side-effect getting the same register as the input
639 ;; register.
641 (define_split
642   [(parallel
643     [(set (match_operator
644            6 "cris_mem_op"
645            [(plus:SI
646              (mult:SI (match_operand:SI 0 "register_operand" "")
647                       (match_operand:SI 1 "const_int_operand" ""))
648              (match_operand:SI 2 "register_operand" ""))])
649           (match_operand 3 "register_operand" ""))
650      (set (match_operand:SI 4 "register_operand" "")
651           (plus:SI (mult:SI (match_dup 0)
652                             (match_dup 1))
653                    (match_dup 2)))])]
654   "reload_completed && reg_overlap_mentioned_p (operands[4], operands[3])"
655   [(set (match_dup 5) (match_dup 3))
656    (set (match_dup 4) (match_dup 2))
657    (set (match_dup 4)
658         (plus:SI (mult:SI (match_dup 0)
659                           (match_dup 1))
660                  (match_dup 4)))]
661   "operands[5]
662      = replace_equiv_address (operands[6],
663                               gen_rtx_PLUS (SImode,
664                                             gen_rtx_MULT (SImode,
665                                                           operands[0],
666                                                           operands[1]),
667                                             operands[2]));")
669 ;; move.s rx,[ry=rz+i]
670 ;; FIXME: These could have anonymous mode for operand 2.
672 ;; QImode
674 (define_insn "*mov_sideqi_mem"
675   [(set (mem:QI
676          (plus:SI (match_operand:SI 0 "cris_bdap_operand" "%r,r,r,r")
677                   (match_operand:SI 1 "cris_bdap_operand" "r>Rn,r>Rn,r,>Rn")))
678         (match_operand:QI 2 "register_operand" "r,r,r,r"))
679    (set (match_operand:SI 3 "register_operand" "=*0,!2,r,r")
680         (plus:SI (match_dup 0)
681                  (match_dup 1)))]
682   "cris_side_effect_mode_ok (PLUS, operands, 3, 0, 1, -1, 2)"
683   "*
685   if (which_alternative == 0
686       && (GET_CODE (operands[1]) != CONST_INT
687           || INTVAL (operands[1]) > 127
688           || INTVAL (operands[1]) < -128
689           || CONST_OK_FOR_LETTER_P (INTVAL (operands[1]), 'N')
690           || CONST_OK_FOR_LETTER_P (INTVAL (operands[1]), 'J')))
691     return \"#\";
692   if (which_alternative == 1)
693     return \"#\";
694   return \"move.%s2 %2,[%3=%0%S1]\";
697 ;; HImode
699 (define_insn "*mov_sidehi_mem"
700   [(set (mem:HI
701          (plus:SI (match_operand:SI 0 "cris_bdap_operand" "%r,r,r,r")
702                   (match_operand:SI 1 "cris_bdap_operand" "r>Rn,r>Rn,r,>Rn")))
703         (match_operand:HI 2 "register_operand" "r,r,r,r"))
704    (set (match_operand:SI 3 "register_operand" "=*0,!2,r,r")
705         (plus:SI (match_dup 0)
706                  (match_dup 1)))]
707   "cris_side_effect_mode_ok (PLUS, operands, 3, 0, 1, -1, 2)"
708   "*
710   if (which_alternative == 0
711       && (GET_CODE (operands[1]) != CONST_INT
712           || INTVAL (operands[1]) > 127
713           || INTVAL (operands[1]) < -128
714           || CONST_OK_FOR_LETTER_P (INTVAL (operands[1]), 'N')
715           || CONST_OK_FOR_LETTER_P (INTVAL (operands[1]), 'J')))
716     return \"#\";
717   if (which_alternative == 1)
718     return \"#\";
719   return \"move.%s2 %2,[%3=%0%S1]\";
722 ;; SImode
724 (define_insn "*mov_sidesi_mem"
725   [(set (mem:SI
726          (plus:SI (match_operand:SI 0 "cris_bdap_operand" "%r,r,r,r")
727                   (match_operand:SI 1 "cris_bdap_operand" "r>Rn,r>Rn,r,>Rn")))
728         (match_operand:SI 2 "register_operand" "r,r,r,r"))
729    (set (match_operand:SI 3 "register_operand" "=*0,!2,r,r")
730         (plus:SI (match_dup 0)
731                  (match_dup 1)))]
732   "cris_side_effect_mode_ok (PLUS, operands, 3, 0, 1, -1, 2)"
733   "*
735   if (which_alternative == 0
736       && (GET_CODE (operands[1]) != CONST_INT
737           || INTVAL (operands[1]) > 127
738           || INTVAL (operands[1]) < -128
739           || CONST_OK_FOR_LETTER_P (INTVAL (operands[1]), 'N')
740           || CONST_OK_FOR_LETTER_P (INTVAL (operands[1]), 'J')))
741     return \"#\";
742   if (which_alternative == 1)
743     return \"#\";
744   return \"move.%s2 %2,[%3=%0%S1]\";
747 ;; Like the biap case, a split where the set in the side-effect gets the
748 ;; same register as the input register to the main insn, since the
749 ;; condition isn't checked at register allocation.
751 (define_split
752   [(parallel
753     [(set (match_operator
754            4 "cris_mem_op"
755            [(plus:SI
756              (match_operand:SI 0 "cris_bdap_operand" "")
757              (match_operand:SI 1 "cris_bdap_operand" ""))])
758           (match_operand 2 "register_operand" ""))
759      (set (match_operand:SI 3 "register_operand" "")
760           (plus:SI (match_dup 0) (match_dup 1)))])]
761   "reload_completed && reg_overlap_mentioned_p (operands[3], operands[2])"
762   [(set (match_dup 4) (match_dup 2))
763    (set (match_dup 3) (match_dup 0))
764    (set (match_dup 3) (plus:SI (match_dup 3) (match_dup 1)))]
765   "")
767 ;; Clear memory side-effect patterns.  It is hard to get to the mode if
768 ;; the MEM was anonymous, so there will be one for each mode.
770 ;; clear.d [ry=rx+rw.s2]
772 (define_insn "*clear_sidesi_biap"
773   [(set (mem:SI (plus:SI
774                  (mult:SI (match_operand:SI 0 "register_operand" "r,r")
775                           (match_operand:SI 1 "const_int_operand" "n,n"))
776                  (match_operand:SI 2 "register_operand" "r,r")))
777         (const_int 0))
778    (set (match_operand:SI 3 "register_operand" "=*2,r")
779         (plus:SI (mult:SI (match_dup 0)
780                           (match_dup 1))
781                  (match_dup 2)))]
782   "cris_side_effect_mode_ok (MULT, operands, 3, 2, 0, 1, -1)"
783   "@
784    #
785    clear.d [%3=%2+%0%T1]")
787 ;; clear.d [ry=rz+i]
789 (define_insn "*clear_sidesi"
790   [(set (mem:SI
791          (plus:SI (match_operand:SI 0 "cris_bdap_operand" "%r,r,r")
792                   (match_operand:SI 1 "cris_bdap_operand" "r>Rn,r,>Rn")))
793         (const_int 0))
794    (set (match_operand:SI 2 "register_operand" "=*0,r,r")
795         (plus:SI (match_dup 0)
796                  (match_dup 1)))]
797   "cris_side_effect_mode_ok (PLUS, operands, 2, 0, 1, -1, -1)"
798   "*
800   if (which_alternative == 0
801       && (GET_CODE (operands[1]) != CONST_INT
802           || INTVAL (operands[1]) > 127
803           || INTVAL (operands[1]) < -128
804           || CONST_OK_FOR_LETTER_P (INTVAL (operands[1]), 'N')
805           || CONST_OK_FOR_LETTER_P (INTVAL (operands[1]), 'J')))
806     return \"#\";
807   return \"clear.d [%2=%0%S1]\";
810 ;;  clear.w [ry=rx+rw.s2]
812 (define_insn "*clear_sidehi_biap"
813   [(set (mem:HI (plus:SI
814                  (mult:SI (match_operand:SI 0 "register_operand" "r,r")
815                           (match_operand:SI 1 "const_int_operand" "n,n"))
816                  (match_operand:SI 2 "register_operand" "r,r")))
817         (const_int 0))
818    (set (match_operand:SI 3 "register_operand" "=*2,r")
819         (plus:SI (mult:SI (match_dup 0)
820                           (match_dup 1))
821                  (match_dup 2)))]
822   "cris_side_effect_mode_ok (MULT, operands, 3, 2, 0, 1, -1)"
823   "@
824    #
825    clear.w [%3=%2+%0%T1]")
827 ;; clear.w [ry=rz+i]
829 (define_insn "*clear_sidehi"
830   [(set (mem:HI
831          (plus:SI (match_operand:SI 0 "cris_bdap_operand" "%r,r,r")
832                   (match_operand:SI 1 "cris_bdap_operand" "r>Rn,r,>Rn")))
833         (const_int 0))
834    (set (match_operand:SI 2 "register_operand" "=*0,r,r")
835         (plus:SI (match_dup 0)
836                  (match_dup 1)))]
837   "cris_side_effect_mode_ok (PLUS, operands, 2, 0, 1, -1, -1)"
838   "*
840   if (which_alternative == 0
841       && (GET_CODE (operands[1]) != CONST_INT
842           || INTVAL (operands[1]) > 127
843           || INTVAL (operands[1]) < -128
844           || CONST_OK_FOR_LETTER_P (INTVAL (operands[1]), 'N')
845           || CONST_OK_FOR_LETTER_P (INTVAL (operands[1]), 'J')))
846     return \"#\";
847   return \"clear.w [%2=%0%S1]\";
850 ;;  clear.b [ry=rx+rw.s2]
852 (define_insn "*clear_sideqi_biap"
853   [(set (mem:QI (plus:SI
854                  (mult:SI (match_operand:SI 0 "register_operand" "r,r")
855                           (match_operand:SI 1 "const_int_operand" "n,n"))
856                  (match_operand:SI 2 "register_operand" "r,r")))
857         (const_int 0))
858    (set (match_operand:SI 3 "register_operand" "=*2,r")
859         (plus:SI (mult:SI (match_dup 0)
860                           (match_dup 1))
861                  (match_dup 2)))]
862   "cris_side_effect_mode_ok (MULT, operands, 3, 2, 0, 1, -1)"
863   "@
864    #
865    clear.b [%3=%2+%0%T1]")
867 ;; clear.b [ry=rz+i]
869 (define_insn "*clear_sideqi"
870   [(set (mem:QI
871          (plus:SI (match_operand:SI 0 "cris_bdap_operand" "%r,r,r")
872                   (match_operand:SI 1 "cris_bdap_operand" "r>Rn,r,>Rn")))
873         (const_int 0))
874    (set (match_operand:SI 2 "register_operand" "=*0,r,r")
875         (plus:SI (match_dup 0)
876                  (match_dup 1)))]
877   "cris_side_effect_mode_ok (PLUS, operands, 2, 0, 1, -1, -1)"
878   "*
880   if (which_alternative == 0
881       && (GET_CODE (operands[1]) != CONST_INT
882           || INTVAL (operands[1]) > 127
883           || INTVAL (operands[1]) < -128
884           || CONST_OK_FOR_LETTER_P (INTVAL (operands[1]), 'N')
885           || CONST_OK_FOR_LETTER_P (INTVAL (operands[1]), 'J')))
886     return \"#\";
887   return \"clear.b [%2=%0%S1]\";
890 ;; To appease testcase gcc.c-torture/execute/920501-2.c (and others) at
891 ;; -O0, we need a movdi as a temporary measure.  Here's how things fail:
892 ;;  A cmpdi RTX needs reloading (global):
893 ;;    (insn 185 326 186 (set (cc0)
894 ;;          (compare (mem/f:DI (reg/v:SI 22) 0)
895 ;;              (const_int 1 [0x1]))) 4 {cmpdi} (nil)
896 ;;      (nil))
897 ;; Now, reg 22 is reloaded for input address, and the mem is also moved
898 ;; out of the instruction (into a register), since one of the operands
899 ;; must be a register.  Reg 22 is reloaded (into reg 10), and the mem is
900 ;; moved out and synthesized in SImode parts (reg 9, reg 10 - should be ok
901 ;; wrt. overlap).  The bad things happen with the synthesis in
902 ;; emit_move_insn_1; the location where to substitute reg 10 is lost into
903 ;; two new RTX:es, both still having reg 22.  Later on, the left-over reg
904 ;; 22 is recognized to have an equivalent in memory which is substituted
905 ;; straight in, and we end up with an unrecognizable insn:
906 ;;    (insn 325 324 326 (set (reg:SI 9 r9)
907 ;;            (mem/f:SI (mem:SI (plus:SI (reg:SI 8 r8)
908 ;;                        (const_int -84 [0xffffffac])) 0) 0)) -1 (nil)
909 ;;        (nil))
910 ;; which is the first part of the reloaded synthesized "movdi".
911 ;;  The right thing would be to add equivalent replacement locations for
912 ;; insn with pseudos that need more reloading.  The question is where.
914 ;; Normal move patterns from SI on.
916 (define_expand "movsi"
917   [(set
918     (match_operand:SI 0 "nonimmediate_operand" "")
919     (match_operand:SI 1 "cris_general_operand_or_symbol" ""))]
920   ""
921   "
923   /* If the output goes to a MEM, make sure we have zero or a register as
924      input.  */
925   if (GET_CODE (operands[0]) == MEM
926       && ! REG_S_P (operands[1])
927       && operands[1] != const0_rtx
928       && ! no_new_pseudos)
929     operands[1] = force_reg (SImode, operands[1]);
931   /* If we're generating PIC and have an incoming symbol, validize it to a
932      general operand or something that will match a special pattern.
934      FIXME: Do we *have* to recognize anything that would normally be a
935      valid symbol?  Can we exclude global PIC addresses with an added
936      offset?  */
937   if (flag_pic
938       && CONSTANT_ADDRESS_P (operands[1])
939       && cris_symbol (operands[1]))
940     {
941       /* We must have a register as destination for what we're about to
942          do, and for the patterns we generate.  */
943       if (! REG_S_P (operands[0]))
944         {
945           if (no_new_pseudos)
946             abort ();
947           operands[1] = force_reg (SImode, operands[1]);
948         }
949       else
950         {
951           /* Mark a needed PIC setup for a LABEL_REF:s coming in here:
952              they are so rare not-being-branch-targets that we don't mark
953              a function as needing PIC setup just because we have
954              inspected LABEL_REF:s as operands.  It is only in
955              __builtin_setjmp and such that we can get a LABEL_REF
956              assigned to a register.  */
957           if (GET_CODE (operands[1]) == LABEL_REF)
958             current_function_uses_pic_offset_table = 1;
960           /* We don't have to do anything for global PIC operands; they
961              look just like ``[rPIC+sym]''.  */
962           if (! cris_got_symbol (operands[1])
963               /* We don't do anything for local PIC operands; we match
964                  that with a special alternative.  */
965               && ! cris_gotless_symbol (operands[1]))
966             {
967               /* We get here when we have to change something that would
968                  be recognizable if it wasn't PIC.  A ``sym'' is ok for
969                  PIC symbols both with and without a GOT entry.  And ``sym
970                  + offset'' is ok for local symbols, so the only thing it
971                  could be, is a global symbol with an offset.  Check and
972                  abort if not.  */
973               rtx sym = get_related_value (operands[1]);
974               HOST_WIDE_INT offs = get_integer_term (operands[1]);
976               if (sym == NULL_RTX || offs == 0)
977                 abort ();
978               emit_move_insn (operands[0], sym);
979               if (expand_binop (SImode, add_optab, operands[0],
980                                 GEN_INT (offs), operands[0], 0,
981                                 OPTAB_LIB_WIDEN) != operands[0])
982                 abort ();
983               DONE;
984             }
985         }
986     }
989 (define_insn "*movsi_internal"
990   [(set
991     (match_operand:SI 0 "nonimmediate_operand" "=r,r,r,Q>,r,Q>,g,r,r,r,g")
992     (match_operand:SI 1
993     ;; FIXME: We want to put S last, but apparently g matches S.
994     ;; It's a bug: an S is not a general_operand and shouldn't match g.
995      "cris_general_operand_or_gotless_symbol" "r,Q>,M,M,I,r,M,n,!S,g,r"))]
996   ""
997   "*
999   /* Better to have c-switch here; it is worth it to optimize the size of
1000      move insns.  The alternative would be to try to find more constraint
1001      letters.  FIXME: Check again.  It seems this could shrink a bit.  */
1002   switch (which_alternative)
1003     {
1004     case 0:
1005     case 1:
1006     case 5:
1007     case 9:
1008     case 10:
1009       return \"move.d %1,%0\";
1011     case 2:
1012     case 3:
1013     case 6:
1014       return \"clear.d %0\";
1016       /* Constants -32..31 except 0.  */
1017     case 4:
1018       return \"moveq %1,%0\";
1020       /* We can win a little on constants -32768..-33, 32..65535.  */
1021     case 7:
1022       if (INTVAL (operands[1]) > 0 && INTVAL (operands[1]) < 65536)
1023         {
1024           if (INTVAL (operands[1]) < 256)
1025             return \"movu.b %1,%0\";
1026           return \"movu.w %1,%0\";
1027         }
1028       else if (INTVAL (operands[1]) >= -32768 && INTVAL (operands[1]) < 32768)
1029         {
1030           if (INTVAL (operands[1]) >= -128 && INTVAL (operands[1]) < 128)
1031             return \"movs.b %1,%0\";
1032           return \"movs.w %1,%0\";
1033         }
1034       return \"move.d %1,%0\";
1036       case 8:
1037         /* FIXME: Try and split this into pieces GCC makes better code of,
1038            than this multi-insn pattern.  Synopsis: wrap the GOT-relative
1039            symbol into an unspec, and when PIC, recognize the unspec
1040            everywhere a symbol is normally recognized.  (The PIC register
1041            should be recognized by GCC as pic_offset_table_rtx when needed
1042            and similar for PC.)  Each component can then be optimized with
1043            the rest of the code; it should be possible to have a constant
1044            term added on an unspec.  Don't forget to add a REG_EQUAL (or
1045            is it REG_EQUIV) note to the destination.  It might not be
1046            worth it.  Measure.
1048            Note that the 'v' modifier makes PLT references be output as
1049            sym:PLT rather than [rPIC+sym:GOTPLT].  */
1050         return \"move.d %v1,%0\;add.d %P1,%0\";
1052     default:
1053       return \"BOGUS: %1 to %0\";
1054     }
1056   [(set_attr "slottable" "yes,yes,yes,yes,yes,yes,no,no,no,no,no")])
1058 ;; Extend operations with side-effect from mem to register, using
1059 ;; MOVS/MOVU.  These are from mem to register only.
1061 ;; [rx=ry+rz.S]
1063 ;; QImode to HImode
1065 ;; FIXME: Can we omit extend to HImode, since GCC should truncate for
1066 ;; HImode by itself?  Perhaps use only anonymous modes?
1068 (define_insn "*ext_sideqihi_biap"
1069   [(set (match_operand:HI 0 "register_operand" "=r,r")
1070         (match_operator:HI
1071          5 "cris_extend_operator"
1072          [(mem:QI (plus:SI
1073                    (mult:SI (match_operand:SI 1 "register_operand" "r,r")
1074                             (match_operand:SI 2 "const_int_operand" "n,n"))
1075                    (match_operand:SI 3 "register_operand" "r,r")))]))
1076    (set (match_operand:SI 4 "register_operand" "=*3,r")
1077         (plus:SI (mult:SI (match_dup 1)
1078                           (match_dup 2))
1079                  (match_dup 3)))]
1080   "cris_side_effect_mode_ok (MULT, operands, 4, 3, 1, 2, 0)"
1081   "@
1082    #
1083    mov%e5.%m5 [%4=%3+%1%T2],%0")
1085 ;; QImode to SImode
1087 (define_insn "*ext_sideqisi_biap"
1088   [(set (match_operand:SI 0 "register_operand" "=r,r")
1089         (match_operator:SI
1090          5 "cris_extend_operator"
1091          [(mem:QI (plus:SI
1092                    (mult:SI (match_operand:SI 1 "register_operand" "r,r")
1093                             (match_operand:SI 2 "const_int_operand" "n,n"))
1094                    (match_operand:SI 3 "register_operand" "r,r")))]))
1095    (set (match_operand:SI 4 "register_operand" "=*3,r")
1096         (plus:SI (mult:SI (match_dup 1)
1097                           (match_dup 2))
1098                  (match_dup 3)))]
1099   "cris_side_effect_mode_ok (MULT, operands, 4, 3, 1, 2, 0)"
1100   "@
1101    #
1102    mov%e5.%m5 [%4=%3+%1%T2],%0")
1104 ;; HImode to SImode
1106 (define_insn "*ext_sidehisi_biap"
1107   [(set (match_operand:SI 0 "register_operand" "=r,r")
1108         (match_operator:SI
1109          5 "cris_extend_operator"
1110          [(mem:HI (plus:SI
1111                    (mult:SI (match_operand:SI 1 "register_operand" "r,r")
1112                             (match_operand:SI 2 "const_int_operand" "n,n"))
1113                    (match_operand:SI 3 "register_operand" "r,r")))]))
1114    (set (match_operand:SI 4 "register_operand" "=*3,r")
1115         (plus:SI (mult:SI (match_dup 1)
1116                           (match_dup 2))
1117                  (match_dup 3)))]
1118   "cris_side_effect_mode_ok (MULT, operands, 4, 3, 1, 2, 0)"
1119   "@
1120    #
1121    mov%e5.%m5 [%4=%3+%1%T2],%0")
1123 ;; Same but [rx=ry+i]
1125 ;; QImode to HImode
1127 (define_insn "*ext_sideqihi"
1128   [(set (match_operand:HI 0 "register_operand" "=r,r,r")
1129         (match_operator:HI
1130          4 "cris_extend_operator"
1131          [(mem:QI (plus:SI
1132                    (match_operand:SI 1 "cris_bdap_operand" "%r,r,r")
1133                    (match_operand:SI 2 "cris_bdap_operand" "r>Rn,r,>Rn")))]))
1134    (set (match_operand:SI 3 "register_operand" "=*1,r,r")
1135         (plus:SI (match_dup 1)
1136                  (match_dup 2)))]
1137   "cris_side_effect_mode_ok (PLUS, operands, 3, 1, 2, -1, 0)"
1138   "*
1140   if (which_alternative == 0
1141       && (GET_CODE (operands[2]) != CONST_INT
1142           || INTVAL (operands[2]) > 127
1143           || INTVAL (operands[2]) < -128
1144           || CONST_OK_FOR_LETTER_P (INTVAL (operands[2]), 'N')
1145           || CONST_OK_FOR_LETTER_P (INTVAL (operands[2]), 'J')))
1146     return \"#\";
1147   return \"mov%e4.%m4 [%3=%1%S2],%0\";
1150 ;; QImode to SImode
1152 (define_insn "*ext_sideqisi"
1153   [(set (match_operand:SI 0 "register_operand" "=r,r,r")
1154         (match_operator:SI
1155          4 "cris_extend_operator"
1156          [(mem:QI (plus:SI
1157                    (match_operand:SI 1 "cris_bdap_operand" "%r,r,r")
1158                    (match_operand:SI 2 "cris_bdap_operand" "r>Rn,r,>Rn")))]))
1159    (set (match_operand:SI 3 "register_operand" "=*1,r,r")
1160         (plus:SI (match_dup 1)
1161                  (match_dup 2)))]
1162   "cris_side_effect_mode_ok (PLUS, operands, 3, 1, 2, -1, 0)"
1163   "*
1165   if (which_alternative == 0
1166       && (GET_CODE (operands[2]) != CONST_INT
1167           || INTVAL (operands[2]) > 127
1168           || INTVAL (operands[2]) < -128
1169           || CONST_OK_FOR_LETTER_P (INTVAL (operands[2]), 'N')
1170           || CONST_OK_FOR_LETTER_P (INTVAL (operands[2]), 'J')))
1171     return \"#\";
1172   return \"mov%e4.%m4 [%3=%1%S2],%0\";
1175 ;; HImode to SImode
1177 (define_insn "*ext_sidehisi"
1178   [(set (match_operand:SI 0 "register_operand" "=r,r,r")
1179         (match_operator:SI
1180          4 "cris_extend_operator"
1181          [(mem:HI (plus:SI
1182                    (match_operand:SI 1 "cris_bdap_operand" "%r,r,r")
1183                    (match_operand:SI 2 "cris_bdap_operand" "r>Rn,r,>Rn")))]))
1184    (set (match_operand:SI 3 "register_operand" "=*1,r,r")
1185         (plus:SI (match_dup 1)
1186                  (match_dup 2)))]
1187   "cris_side_effect_mode_ok (PLUS, operands, 3, 1, 2, -1, 0)"
1188   "*
1190   if (which_alternative == 0
1191       && (GET_CODE (operands[2]) != CONST_INT
1192           || INTVAL (operands[2]) > 127
1193           || INTVAL (operands[2]) < -128
1194           || CONST_OK_FOR_LETTER_P (INTVAL (operands[2]), 'N')
1195           || CONST_OK_FOR_LETTER_P (INTVAL (operands[2]), 'J')))
1196     return \"#\";
1197   return \"mov%e4.%m4 [%3=%1%S2],%0\";
1200 ;; FIXME: See movsi.
1202 (define_insn "movhi"
1203   [(set
1204     (match_operand:HI 0 "nonimmediate_operand" "=r,r,r,Q>,r,Q>,r,r,r,g,g,r")
1205     (match_operand:HI 1 "general_operand" "r,Q>,M,M,I,r,L,O,n,M,r,g"))]
1206   ""
1207   "*
1209   switch (which_alternative)
1210     {
1211     case 0:
1212     case 1:
1213     case 5:
1214     case 10:
1215     case 11:
1216       return \"move.w %1,%0\";
1217     case 2:
1218     case 3:
1219     case 9:
1220       return \"clear.w %0\";
1221     case 4:
1222       return \"moveq %1,%0\";
1223     case 6:
1224     case 8:
1225       if (INTVAL (operands[1]) < 256 && INTVAL (operands[1]) >= -128)
1226         {
1227           if (INTVAL (operands[1]) > 0)
1228             return \"movu.b %1,%0\";
1229           return \"movs.b %1,%0\";
1230         }
1231       return \"move.w %1,%0\";
1232     case 7:
1233       return \"movEq %b1,%0\";
1234     default:
1235       return \"BOGUS: %1 to %0\";
1236   }
1238   [(set_attr "slottable" "yes,yes,yes,yes,yes,yes,no,yes,no,no,no,no")
1239    (set (attr "cc")
1240         (if_then_else (eq_attr "alternative" "7")
1241                       (const_string "clobber")
1242                       (const_string "normal")))])
1244 (define_insn "movstricthi"
1245   [(set
1246     (strict_low_part
1247      (match_operand:HI 0 "nonimmediate_operand" "+r,r,r,Q>,Q>,g,r,g"))
1248     (match_operand:HI 1 "general_operand" "r,Q>,M,M,r,M,g,r"))]
1249   ""
1250   "@
1251    move.w %1,%0
1252    move.w %1,%0
1253    clear.w %0
1254    clear.w %0
1255    move.w %1,%0
1256    clear.w %0
1257    move.w %1,%0
1258    move.w %1,%0"
1259   [(set_attr "slottable" "yes,yes,yes,yes,yes,no,no,no")])
1261 (define_insn "movqi"
1262   [(set (match_operand:QI 0 "nonimmediate_operand" "=r,Q>,r,r,Q>,r,g,g,r,r")
1263         (match_operand:QI 1 "general_operand" "r,r,Q>,M,M,I,M,r,O,g"))]
1264   ""
1265   "@
1266    move.b %1,%0
1267    move.b %1,%0
1268    move.b %1,%0
1269    clear.b %0
1270    clear.b %0
1271    moveq %1,%0
1272    clear.b %0
1273    move.b %1,%0
1274    moveq %b1,%0
1275    move.b %1,%0"
1276   [(set_attr "slottable" "yes,yes,yes,yes,yes,yes,no,no,yes,no")
1277    (set (attr "cc")
1278         (if_then_else (eq_attr "alternative" "8")
1279                       (const_string "clobber")
1280                       (const_string "normal")))])
1282 (define_insn "movstrictqi"
1283   [(set (strict_low_part
1284          (match_operand:QI 0 "nonimmediate_operand" "+r,Q>,r,r,Q>,g,g,r"))
1285         (match_operand:QI 1 "general_operand" "r,r,Q>,M,M,M,r,g"))]
1286   ""
1287   "@
1288    move.b %1,%0
1289    move.b %1,%0
1290    move.b %1,%0
1291    clear.b %0
1292    clear.b %0
1293    clear.b %0
1294    move.b %1,%0
1295    move.b %1,%0"
1296   [(set_attr "slottable" "yes,yes,yes,yes,yes,no,no,no")])
1298 ;; The valid "quick" bit-patterns are, except for 0.0, denormalized
1299 ;; values REALLY close to 0, and some NaN:s (I think; their exponent is
1300 ;; all ones); the worthwhile one is "0.0".
1301 ;; It will use clear, so we know ALL types of immediate 0 never change cc.
1303 (define_insn "movsf"
1304   [(set (match_operand:SF 0 "nonimmediate_operand" "=r,Q>,r,r,Q>,g,g,r")
1305         (match_operand:SF 1 "general_operand" "r,r,Q>,G,G,G,r,g"))]
1306   ""
1307   "@
1308    move.d %1,%0
1309    move.d %1,%0
1310    move.d %1,%0
1311    clear.d %0
1312    clear.d %0
1313    clear.d %0
1314    move.d %1,%0
1315    move.d %1,%0"
1316   [(set_attr "slottable" "yes,yes,yes,yes,yes,no,no,no")])
1319 ;; Sign- and zero-extend insns with standard names.
1320 ;;  Those for integer source operand are ordered with the widest source
1321 ;; type first.
1323 ;; Sign-extend.
1325 (define_insn "extendsidi2"
1326   [(set (match_operand:DI 0 "register_operand" "=r")
1327         (sign_extend:DI (match_operand:SI 1 "general_operand" "g")))]
1328   ""
1329   "move.d %1,%M0\;smi %H0\;neg.d %H0,%H0")
1331 (define_insn "extendhidi2"
1332   [(set (match_operand:DI 0 "register_operand" "=r")
1333         (sign_extend:DI (match_operand:HI 1 "general_operand" "g")))]
1334   ""
1335   "movs.w %1,%M0\;smi %H0\;neg.d %H0,%H0")
1337 (define_insn "extendhisi2"
1338   [(set (match_operand:SI 0 "register_operand" "=r,r,r")
1339         (sign_extend:SI (match_operand:HI 1 "general_operand" "r,Q>,g")))]
1340   ""
1341   "movs.w %1,%0"
1342   [(set_attr "slottable" "yes,yes,no")])
1344 (define_insn "extendqidi2"
1345   [(set (match_operand:DI 0 "register_operand" "=r")
1346         (sign_extend:DI (match_operand:QI 1 "general_operand" "g")))]
1347   ""
1348   "movs.b %1,%M0\;smi %H0\;neg.d %H0,%H0")
1350 (define_insn "extendqisi2"
1351   [(set (match_operand:SI 0 "register_operand" "=r,r,r")
1352         (sign_extend:SI (match_operand:QI 1 "general_operand" "r,Q>,g")))]
1353   ""
1354   "movs.b %1,%0"
1355   [(set_attr "slottable" "yes,yes,no")])
1357 ;; To do a byte->word extension, extend to dword, exept that the top half
1358 ;; of the register will be clobbered.  FIXME: Perhaps this is not needed.
1360 (define_insn "extendqihi2"
1361   [(set (match_operand:HI 0 "register_operand" "=r,r,r")
1362         (sign_extend:HI (match_operand:QI 1 "general_operand" "r,Q>,g")))]
1363   ""
1364   "movs.b %1,%0"
1365   [(set_attr "slottable" "yes,yes,no")])
1368 ;; Zero-extend.  The DImode ones are synthesized by gcc, so we don't
1369 ;; specify them here.
1371 (define_insn "zero_extendhisi2"
1372   [(set (match_operand:SI 0 "register_operand" "=r,r,r")
1373         (zero_extend:SI
1374          (match_operand:HI 1 "nonimmediate_operand" "r,Q>,m")))]
1375   ""
1376   "movu.w %1,%0"
1377   [(set_attr "slottable" "yes,yes,no")])
1379 (define_insn "zero_extendqisi2"
1380   [(set (match_operand:SI 0 "register_operand" "=r,r,r")
1381         (zero_extend:SI
1382          (match_operand:QI 1 "nonimmediate_operand" "r,Q>,m")))]
1383   ""
1384   "movu.b %1,%0"
1385   [(set_attr "slottable" "yes,yes,no")])
1387 ;; Same comment as sign-extend QImode to HImode above applies.
1389 (define_insn "zero_extendqihi2"
1390   [(set (match_operand:HI 0 "register_operand" "=r,r,r")
1391         (zero_extend:HI
1392          (match_operand:QI 1 "nonimmediate_operand" "r,Q>,m")))]
1393   ""
1394   "movu.b %1,%0"
1395   [(set_attr "slottable" "yes,yes,no")])
1397 ;; All kinds of arithmetic and logical instructions.
1399 ;; First, anonymous patterns to match addressing modes with
1400 ;; side-effects.
1402 ;; op.S [rx=ry+I],rz; (add, sub, or, and, bound).
1404 ;; [rx=ry+rz.S]
1405 ;; FIXME: These could have anonymous mode for operand 0.
1407 ;; QImode
1409 (define_insn "*op_sideqi_biap"
1410   [(set (match_operand:QI 0 "register_operand" "=r,r")
1411         (match_operator:QI
1412          6 "cris_orthogonal_operator"
1413          [(match_operand:QI 1 "register_operand" "0,0")
1414           (mem:QI (plus:SI
1415                    (mult:SI (match_operand:SI 2 "register_operand" "r,r")
1416                             (match_operand:SI 3 "const_int_operand" "n,n"))
1417                    (match_operand:SI 4 "register_operand" "r,r")))]))
1418    (set (match_operand:SI 5 "register_operand" "=*4,r")
1419         (plus:SI (mult:SI (match_dup 2)
1420                           (match_dup 3))
1421                  (match_dup 4)))]
1422   "cris_side_effect_mode_ok (MULT, operands, 5, 4, 2, 3, 0)"
1423   "@
1424    #
1425    %x6.%s0 [%5=%4+%2%T3],%0")
1427 ;; HImode
1429 (define_insn "*op_sidehi_biap"
1430   [(set (match_operand:HI 0 "register_operand" "=r,r")
1431         (match_operator:HI
1432          6 "cris_orthogonal_operator"
1433          [(match_operand:HI 1 "register_operand" "0,0")
1434           (mem:HI (plus:SI
1435                    (mult:SI (match_operand:SI 2 "register_operand" "r,r")
1436                             (match_operand:SI 3 "const_int_operand" "n,n"))
1437                    (match_operand:SI 4 "register_operand" "r,r")))]))
1438    (set (match_operand:SI 5 "register_operand" "=*4,r")
1439         (plus:SI (mult:SI (match_dup 2)
1440                           (match_dup 3))
1441                  (match_dup 4)))]
1442   "cris_side_effect_mode_ok (MULT, operands, 5, 4, 2, 3, 0)"
1443   "@
1444    #
1445    %x6.%s0 [%5=%4+%2%T3],%0")
1447 ;; SImode
1449 (define_insn "*op_sidesi_biap"
1450   [(set (match_operand:SI 0 "register_operand" "=r,r")
1451         (match_operator:SI
1452          6 "cris_orthogonal_operator"
1453          [(match_operand:SI 1 "register_operand" "0,0")
1454           (mem:SI (plus:SI
1455                    (mult:SI (match_operand:SI 2 "register_operand" "r,r")
1456                             (match_operand:SI 3 "const_int_operand" "n,n"))
1457                    (match_operand:SI 4 "register_operand" "r,r")))]))
1458    (set (match_operand:SI 5 "register_operand" "=*4,r")
1459         (plus:SI (mult:SI (match_dup 2)
1460                           (match_dup 3))
1461                  (match_dup 4)))]
1462   "cris_side_effect_mode_ok (MULT, operands, 5, 4, 2, 3, 0)"
1463   "@
1464    #
1465    %x6.%s0 [%5=%4+%2%T3],%0")
1467 ;; [rx=ry+i] ([%4=%2+%3])
1468 ;; FIXME: These could have anonymous mode for operand 0.
1470 ;; QImode
1472 (define_insn "*op_sideqi"
1473   [(set (match_operand:QI 0 "register_operand" "=r,r,r")
1474         (match_operator:QI
1475          5 "cris_orthogonal_operator"
1476          [(match_operand:QI 1 "register_operand" "0,0,0")
1477           (mem:QI (plus:SI
1478                    (match_operand:SI 2 "cris_bdap_operand" "%r,r,r")
1479                    (match_operand:SI 3 "cris_bdap_operand" "r>Rn,r,>Rn")))]))
1480    (set (match_operand:SI 4 "register_operand" "=*2,r,r")
1481         (plus:SI (match_dup 2)
1482                  (match_dup 3)))]
1483   "cris_side_effect_mode_ok (PLUS, operands, 4, 2, 3, -1, 0)"
1484   "*
1486   if (which_alternative == 0
1487       && (GET_CODE (operands[3]) != CONST_INT
1488           || INTVAL (operands[3]) > 127
1489           || INTVAL (operands[3]) < -128
1490           || CONST_OK_FOR_LETTER_P (INTVAL (operands[3]), 'N')
1491           || CONST_OK_FOR_LETTER_P (INTVAL (operands[3]), 'J')))
1492     return \"#\";
1493   return \"%x5.%s0 [%4=%2%S3],%0\";
1496 ;; HImode
1498 (define_insn "*op_sidehi"
1499   [(set (match_operand:HI 0 "register_operand" "=r,r,r")
1500         (match_operator:HI
1501          5 "cris_orthogonal_operator"
1502          [(match_operand:HI 1 "register_operand" "0,0,0")
1503           (mem:HI (plus:SI
1504                    (match_operand:SI 2 "cris_bdap_operand" "%r,r,r")
1505                    (match_operand:SI 3 "cris_bdap_operand" "r>Rn,r,>Rn")))]))
1506    (set (match_operand:SI 4 "register_operand" "=*2,r,r")
1507         (plus:SI (match_dup 2)
1508                  (match_dup 3)))]
1509   "cris_side_effect_mode_ok (PLUS, operands, 4, 2, 3, -1, 0)"
1510   "*
1512   if (which_alternative == 0
1513       && (GET_CODE (operands[3]) != CONST_INT
1514           || INTVAL (operands[3]) > 127
1515           || INTVAL (operands[3]) < -128
1516           || CONST_OK_FOR_LETTER_P (INTVAL (operands[3]), 'N')
1517           || CONST_OK_FOR_LETTER_P (INTVAL (operands[3]), 'J')))
1518     return \"#\";
1519   return \"%x5.%s0 [%4=%2%S3],%0\";
1522 ;; SImode
1524 (define_insn "*op_sidesi"
1525   [(set (match_operand:SI 0 "register_operand" "=r,r,r")
1526         (match_operator:SI
1527          5 "cris_orthogonal_operator"
1528          [(match_operand:SI 1 "register_operand" "0,0,0")
1529           (mem:SI (plus:SI
1530                    (match_operand:SI 2 "cris_bdap_operand" "%r,r,r")
1531                    (match_operand:SI 3 "cris_bdap_operand" "r>Rn,r,>Rn")))]))
1532    (set (match_operand:SI 4 "register_operand" "=*2,r,r")
1533         (plus:SI (match_dup 2)
1534                  (match_dup 3)))]
1535   "cris_side_effect_mode_ok (PLUS, operands, 4, 2, 3, -1, 0)"
1536   "*
1538   if (which_alternative == 0
1539       && (GET_CODE (operands[3]) != CONST_INT
1540           || INTVAL (operands[3]) > 127
1541           || INTVAL (operands[3]) < -128
1542           || CONST_OK_FOR_LETTER_P (INTVAL (operands[3]), 'N')
1543           || CONST_OK_FOR_LETTER_P (INTVAL (operands[3]), 'J')))
1544     return \"#\";
1545   return \"%x5.%s0 [%4=%2%S3],%0\";
1548 ;; To match all cases for commutative operations we may have to have the
1549 ;; following pattern for add, or & and.  I do not know really, but it does
1550 ;; not break anything.
1552 ;; FIXME: This really ought to be checked.
1554 ;; op.S [rx=ry+I],rz;
1556 ;; [rx=ry+rz.S]
1557 ;; FIXME: These could have anonymous mode for operand 0.
1559 ;; QImode
1561 (define_insn "*op_swap_sideqi_biap"
1562   [(set (match_operand:QI 0 "register_operand" "=r,r")
1563         (match_operator:QI
1564          6 "cris_commutative_orth_op"
1565          [(mem:QI (plus:SI
1566                    (mult:SI (match_operand:SI 2 "register_operand" "r,r")
1567                             (match_operand:SI 3 "const_int_operand" "n,n"))
1568                    (match_operand:SI 4 "register_operand" "r,r")))
1569           (match_operand:QI 1 "register_operand" "0,0")]))
1570    (set (match_operand:SI 5 "register_operand" "=*4,r")
1571         (plus:SI (mult:SI (match_dup 2)
1572                           (match_dup 3))
1573                  (match_dup 4)))]
1574   "cris_side_effect_mode_ok (MULT, operands, 5, 4, 2, 3, 0)"
1575   "@
1576    #
1577    %x6.%s0 [%5=%4+%2%T3],%0")
1579 ;; HImode
1581 (define_insn "*op_swap_sidehi_biap"
1582   [(set (match_operand:HI 0 "register_operand" "=r,r")
1583         (match_operator:HI
1584          6 "cris_commutative_orth_op"
1585          [(mem:HI (plus:SI
1586                    (mult:SI (match_operand:SI 2 "register_operand" "r,r")
1587                             (match_operand:SI 3 "const_int_operand" "n,n"))
1588                    (match_operand:SI 4 "register_operand" "r,r")))
1589           (match_operand:HI 1 "register_operand" "0,0")]))
1590    (set (match_operand:SI 5 "register_operand" "=*4,r")
1591         (plus:SI (mult:SI (match_dup 2)
1592                           (match_dup 3))
1593                  (match_dup 4)))]
1594   "cris_side_effect_mode_ok (MULT, operands, 5, 4, 2, 3, 0)"
1595   "@
1596    #
1597    %x6.%s0 [%5=%4+%2%T3],%0")
1599 ;; SImode
1601 (define_insn "*op_swap_sidesi_biap"
1602   [(set (match_operand:SI 0 "register_operand" "=r,r")
1603         (match_operator:SI
1604          6 "cris_commutative_orth_op"
1605          [(mem:SI (plus:SI
1606                    (mult:SI (match_operand:SI 2 "register_operand" "r,r")
1607                             (match_operand:SI 3 "const_int_operand" "n,n"))
1608                    (match_operand:SI 4 "register_operand" "r,r")))
1609           (match_operand:SI 1 "register_operand" "0,0")]))
1610    (set (match_operand:SI 5 "register_operand" "=*4,r")
1611         (plus:SI (mult:SI (match_dup 2)
1612                           (match_dup 3))
1613                  (match_dup 4)))]
1614   "cris_side_effect_mode_ok (MULT, operands, 5, 4, 2, 3, 0)"
1615   "@
1616    #
1617    %x6.%s0 [%5=%4+%2%T3],%0")
1619 ;; [rx=ry+i] ([%4=%2+%3])
1620 ;; FIXME: These could have anonymous mode for operand 0.
1622 ;; QImode
1624 (define_insn "*op_swap_sideqi"
1625   [(set (match_operand:QI 0 "register_operand" "=r,r,r")
1626         (match_operator:QI
1627          5 "cris_commutative_orth_op"
1628          [(mem:QI
1629            (plus:SI (match_operand:SI 2 "cris_bdap_operand" "%r,r,r")
1630                     (match_operand:SI 3 "cris_bdap_operand" "r>Rn,r,>Rn")))
1631           (match_operand:QI 1 "register_operand" "0,0,0")]))
1632    (set (match_operand:SI 4 "register_operand" "=*2,r,r")
1633         (plus:SI (match_dup 2)
1634                  (match_dup 3)))]
1635   "cris_side_effect_mode_ok (PLUS, operands, 4, 2, 3, -1, 0)"
1636   "*
1638   if (which_alternative == 0
1639       && (GET_CODE (operands[3]) != CONST_INT
1640           || INTVAL (operands[3]) > 127
1641           || INTVAL (operands[3]) < -128
1642           || CONST_OK_FOR_LETTER_P (INTVAL (operands[3]), 'N')
1643           || CONST_OK_FOR_LETTER_P (INTVAL (operands[3]), 'J')))
1644     return \"#\";
1645   return \"%x5.%s0 [%4=%2%S3],%0\";
1648 ;; HImode
1650 (define_insn "*op_swap_sidehi"
1651   [(set (match_operand:HI 0 "register_operand" "=r,r,r")
1652         (match_operator:HI
1653          5 "cris_commutative_orth_op"
1654          [(mem:HI
1655            (plus:SI (match_operand:SI 2 "cris_bdap_operand" "%r,r,r")
1656                     (match_operand:SI 3 "cris_bdap_operand" "r>Rn,r,>Rn")))
1657           (match_operand:HI 1 "register_operand" "0,0,0")]))
1658    (set (match_operand:SI 4 "register_operand" "=*2,r,r")
1659         (plus:SI (match_dup 2)
1660                  (match_dup 3)))]
1661   "cris_side_effect_mode_ok (PLUS, operands, 4, 2, 3, -1, 0)"
1662   "*
1664   if (which_alternative == 0
1665       && (GET_CODE (operands[3]) != CONST_INT
1666           || INTVAL (operands[3]) > 127
1667           || INTVAL (operands[3]) < -128
1668           || CONST_OK_FOR_LETTER_P (INTVAL (operands[3]), 'N')
1669           || CONST_OK_FOR_LETTER_P (INTVAL (operands[3]), 'J')))
1670     return \"#\";
1671   return \"%x5.%s0 [%4=%2%S3],%0\";
1674 ;; SImode
1676 (define_insn "*op_swap_sidesi"
1677   [(set (match_operand:SI 0 "register_operand" "=r,r,r")
1678         (match_operator:SI
1679          5 "cris_commutative_orth_op"
1680          [(mem:SI
1681            (plus:SI (match_operand:SI 2 "cris_bdap_operand" "%r,r,r")
1682                     (match_operand:SI 3 "cris_bdap_operand" "r>Rn,r,>Rn")))
1683           (match_operand:SI 1 "register_operand" "0,0,0")]))
1684    (set (match_operand:SI 4 "register_operand" "=*2,r,r")
1685         (plus:SI (match_dup 2)
1686                  (match_dup 3)))]
1687   "cris_side_effect_mode_ok (PLUS, operands, 4, 2, 3, -1, 0)"
1688   "*
1690   if (which_alternative == 0
1691       && (GET_CODE (operands[3]) != CONST_INT
1692           || INTVAL (operands[3]) > 127
1693           || INTVAL (operands[3]) < -128
1694           || CONST_OK_FOR_LETTER_P (INTVAL (operands[3]), 'N')
1695           || CONST_OK_FOR_LETTER_P (INTVAL (operands[3]), 'J')))
1696     return \"#\";
1697   return \"%x5.%s0 [%4=%2%S3],%0\";
1700 ;; Add operations, standard names.
1702 ;; Note that for the 'P' constraint, the high part can be -1 or 0.  We
1703 ;; output the insn through the 'A' output modifier as "adds.w" and "addq",
1704 ;; respectively.
1705 (define_insn "adddi3"
1706   [(set (match_operand:DI 0 "register_operand" "=r,r,r,&r,&r")
1707         (plus:DI (match_operand:DI 1 "register_operand" "%0,0,0,0,r")
1708                  (match_operand:DI 2 "general_operand" "J,N,P,g,!To")))]
1709   ""
1710   "@
1711    addq %2,%M0\;ax\;addq 0,%H0
1712    subq %n2,%M0\;ax\;subq 0,%H0
1713    add%e2.%z2 %2,%M0\;ax\;%A2 %H2,%H0
1714    add.d %M2,%M0\;ax\;add.d %H2,%H0
1715    add.d %M2,%M1,%M0\;ax\;add.d %H2,%H1,%H0")
1717 (define_insn "addsi3"
1718   [(set (match_operand:SI 0 "register_operand" "=r,r,r,r,r,r,r,r")
1719         (plus:SI
1720          (match_operand:SI 1 "register_operand" "%0,0,0,0,0,0,r,r")
1721          (match_operand:SI 2 "general_operand" "r,Q>,J,N,n,g,!To,0")))]
1723 ;; The last constraint is due to that after reload, the '%' is not
1724 ;; honored, and canonicalization doesn't care about keeping the same
1725 ;; register as in destination.  This will happen after insn splitting.
1726 ;; gcc <= 2.7.2.  FIXME: Check for gcc-2.9x
1728  ""
1729  "*
1731   switch (which_alternative)
1732     {
1733     case 0:
1734     case 1:
1735       return \"add.d %2,%0\";
1736     case 2:
1737       return \"addq %2,%0\";
1738     case 3:
1739       return \"subq %n2,%0\";
1740     case 4:
1741       /* 'Known value', but not in -63..63.
1742          Check if addu/subu may be used.  */
1743       if (INTVAL (operands[2]) > 0)
1744         {
1745           if (INTVAL (operands[2]) < 256)
1746             return \"addu.b %2,%0\";
1747           if (INTVAL (operands[2]) < 65536)
1748             return \"addu.w %2,%0\";
1749         }
1750       else
1751         {
1752           if (INTVAL (operands[2]) >= -255)
1753             return \"subu.b %n2,%0\";
1754           if (INTVAL (operands[2]) >= -65535)
1755             return \"subu.w %n2,%0\";
1756         }
1757       return \"add.d %2,%0\";
1758     case 6:
1759       return \"add.d %2,%1,%0\";
1760     case 5:
1761       return \"add.d %2,%0\";
1762     case 7:
1763       return \"add.d %1,%0\";
1764     default:
1765       return \"BOGUS addsi %2+%1 to %0\";
1766     }
1768  [(set_attr "slottable" "yes,yes,yes,yes,no,no,no,yes")])
1770 (define_insn "addhi3"
1771   [(set (match_operand:HI 0 "register_operand" "=r,r,r,r,r,r")
1772         (plus:HI (match_operand:HI 1 "register_operand" "%0,0,0,0,0,r")
1773                  (match_operand:HI 2 "general_operand" "r,Q>,J,N,g,!To")))]
1774   ""
1775   "@
1776    add.w %2,%0
1777    add.w %2,%0
1778    addq %2,%0
1779    subq %n2,%0
1780    add.w %2,%0
1781    add.w %2,%1,%0"
1782   [(set_attr "slottable" "yes,yes,yes,yes,no,no")
1783    (set_attr "cc" "normal,normal,clobber,clobber,normal,normal")])
1785 (define_insn "addqi3"
1786   [(set (match_operand:QI 0 "register_operand" "=r,r,r,r,r,r,r")
1787         (plus:QI (match_operand:QI 1 "register_operand" "%0,0,0,0,0,0,r")
1788                  (match_operand:QI 2 "general_operand" "r,Q>,J,N,O,g,!To")))]
1789   ""
1790   "@
1791    add.b %2,%0
1792    add.b %2,%0
1793    addq %2,%0
1794    subq %n2,%0
1795    subQ -%b2,%0
1796    add.b %2,%0
1797    add.b %2,%1,%0"
1798   [(set_attr "slottable" "yes,yes,yes,yes,yes,no,no")
1799    (set_attr "cc" "normal,normal,clobber,clobber,clobber,normal,normal")])
1801 ;; Subtract.
1803 ;; Note that because of insn canonicalization these will *seldom* but
1804 ;; rarely be used with a known constant as an operand.
1806 ;; Note that for the 'P' constraint, the high part can be -1 or 0.  We
1807 ;; output the insn through the 'D' output modifier as "subs.w" and "subq",
1808 ;; respectively.
1809 (define_insn "subdi3"
1810   [(set (match_operand:DI 0 "register_operand" "=r,r,r,&r,&r")
1811         (minus:DI (match_operand:DI 1 "register_operand" "0,0,0,0,r")
1812                   (match_operand:DI 2 "general_operand" "J,N,P,g,!To")))]
1813   ""
1814   "@
1815    subq %2,%M0\;ax\;subq 0,%H0
1816    addq %n2,%M0\;ax\;addq 0,%H0
1817    sub%e2.%z2 %2,%M0\;ax\;%D2 %H2,%H0
1818    sub.d %M2,%M0\;ax\;sub.d %H2,%H0
1819    sub.d %M2,%M1,%M0\;ax\;sub.d %H2,%H1,%H0")
1821 (define_insn "subsi3"
1822   [(set (match_operand:SI 0 "register_operand" "=r,r,r,r,r,r,r,r")
1823         (minus:SI
1824          (match_operand:SI 1 "register_operand" "0,0,0,0,0,0,0,r")
1825          (match_operand:SI 2 "general_operand" "r,Q>,J,N,P,n,g,!To")))]
1826   ""
1828 ;; This does not do the optimal: "addu.w 65535,r0" when %2 is negative.
1829 ;; But then again, %2 should not be negative.
1831   "@
1832    sub.d %2,%0
1833    sub.d %2,%0
1834    subq %2,%0
1835    addq %n2,%0
1836    sub%e2.%z2 %2,%0
1837    sub.d %2,%0
1838    sub.d %2,%0
1839    sub.d %2,%1,%0"
1840   [(set_attr "slottable" "yes,yes,yes,yes,no,no,no,no")])
1842 (define_insn "subhi3"
1843   [(set (match_operand:HI 0 "register_operand" "=r,r,r,r,r,r")
1844         (minus:HI (match_operand:HI 1 "register_operand" "0,0,0,0,0,r")
1845                   (match_operand:HI 2 "general_operand" "r,Q>,J,N,g,!To")))]
1846   ""
1847   "@
1848    sub.w %2,%0
1849    sub.w %2,%0
1850    subq %2,%0
1851    addq %n2,%0
1852    sub.w %2,%0
1853    sub.w %2,%1,%0"
1854   [(set_attr "slottable" "yes,yes,yes,yes,no,no")
1855    (set_attr "cc" "normal,normal,clobber,clobber,normal,normal")])
1857 (define_insn "subqi3"
1858   [(set (match_operand:QI 0 "register_operand" "=r,r,r,r,r,r")
1859         (minus:QI (match_operand:QI 1 "register_operand" "0,0,0,0,0,r")
1860                   (match_operand:QI 2 "general_operand" "r,Q>,J,N,g,!To")))]
1861   ""
1862   "@
1863    sub.b %2,%0
1864    sub.b %2,%0
1865    subq %2,%0
1866    addq %2,%0
1867    sub.b %2,%0
1868    sub.b %2,%1,%0"
1869   [(set_attr "slottable" "yes,yes,yes,yes,no,no")
1870    (set_attr "cc" "normal,normal,clobber,clobber,normal,normal")])
1872 ;; CRIS has some add/sub-with-sign/zero-extend instructions.
1873 ;;  Although these perform sign/zero-extension to SImode, they are
1874 ;; equally applicable for the HImode case.
1875 ;; FIXME: Check; GCC should handle the widening.
1876 ;;  Note that these must be located after the normal add/sub patterns,
1877 ;; so not to get constants into any less specific operands.
1879 ;; Extend with add/sub and side-effect.
1881 ;; ADDS/SUBS/ADDU/SUBU and BOUND, which needs a check for zero_extend
1883 ;; adds/subs/addu/subu bound [rx=ry+rz.S]
1884 ;; FIXME: These could have anonymous mode for operand 0.
1886 ;; QImode to HImode
1887 ;; FIXME: GCC should widen.
1889 (define_insn "*extopqihi_side_biap"
1890   [(set (match_operand:HI 0 "register_operand" "=r,r")
1891         (match_operator:HI
1892          6 "cris_additive_operand_extend_operator"
1893          [(match_operand:HI 1 "register_operand" "0,0")
1894           (match_operator:HI
1895            7 "cris_extend_operator"
1896            [(mem:QI (plus:SI
1897                      (mult:SI (match_operand:SI 2 "register_operand" "r,r")
1898                               (match_operand:SI 3 "const_int_operand" "n,n"))
1899                      (match_operand:SI 4 "register_operand" "r,r")))])]))
1900    (set (match_operand:SI 5 "register_operand" "=*4,r")
1901         (plus:SI (mult:SI (match_dup 2)
1902                           (match_dup 3))
1903                  (match_dup 4)))]
1904   "cris_side_effect_mode_ok (MULT, operands, 5, 4, 2, 3, 0)"
1905   "@
1906    #
1907    %x6%e7.%m7 [%5=%4+%2%T3],%0")
1909 ;; QImode to SImode
1911 (define_insn "*extopqisi_side_biap"
1912   [(set (match_operand:SI 0 "register_operand" "=r,r")
1913         (match_operator:SI
1914          6 "cris_operand_extend_operator"
1915          [(match_operand:SI 1 "register_operand" "0,0")
1916           (match_operator:SI
1917            7 "cris_extend_operator"
1918            [(mem:QI (plus:SI
1919                      (mult:SI (match_operand:SI 2 "register_operand" "r,r")
1920                               (match_operand:SI 3 "const_int_operand" "n,n"))
1921                      (match_operand:SI 4 "register_operand" "r,r")))])]))
1922    (set (match_operand:SI 5 "register_operand" "=*4,r")
1923         (plus:SI (mult:SI (match_dup 2)
1924                           (match_dup 3))
1925                  (match_dup 4)))]
1926   "(GET_CODE (operands[6]) != UMIN || GET_CODE (operands[7]) == ZERO_EXTEND)
1927    && cris_side_effect_mode_ok (MULT, operands, 5, 4, 2, 3, 0)"
1928   "@
1929    #
1930    %x6%e7.%m7 [%5=%4+%2%T3],%0")
1932 ;; HImode to SImode
1934 (define_insn "*extophisi_side_biap"
1935   [(set (match_operand:SI 0 "register_operand" "=r,r")
1936         (match_operator:SI
1937          6 "cris_operand_extend_operator"
1938          [(match_operand:SI 1 "register_operand" "0,0")
1939           (match_operator:SI
1940            7 "cris_extend_operator"
1941            [(mem:HI (plus:SI
1942                      (mult:SI (match_operand:SI 2 "register_operand" "r,r")
1943                               (match_operand:SI 3 "const_int_operand" "n,n"))
1944                      (match_operand:SI 4 "register_operand" "r,r")))])]))
1945    (set (match_operand:SI 5 "register_operand" "=*4,r")
1946         (plus:SI (mult:SI (match_dup 2)
1947                           (match_dup 3))
1948                  (match_dup 4)))]
1949   "(GET_CODE (operands[6]) != UMIN || GET_CODE (operands[7]) == ZERO_EXTEND)
1950    && cris_side_effect_mode_ok (MULT, operands, 5, 4, 2, 3, 0)"
1951   "@
1952    #
1953    %x6%e7.%m7 [%5=%4+%2%T3],%0")
1956 ;; [rx=ry+i]
1957 ;; FIXME: These could have anonymous mode for operand 0.
1959 ;; QImode to HImode
1961 (define_insn "*extopqihi_side"
1962   [(set (match_operand:HI 0 "register_operand" "=r,r,r")
1963         (match_operator:HI
1964          5 "cris_additive_operand_extend_operator"
1965          [(match_operand:HI 1 "register_operand" "0,0,0")
1966           (match_operator:HI
1967            6 "cris_extend_operator"
1968            [(mem:QI
1969              (plus:SI (match_operand:SI 2 "cris_bdap_operand" "%r,r,r")
1970                       (match_operand:SI 3 "cris_bdap_operand" "r>Rn,r,>Rn")
1971                       ))])]))
1972    (set (match_operand:SI 4 "register_operand" "=*2,r,r")
1973         (plus:SI (match_dup 2)
1974                  (match_dup 3)))]
1975   "cris_side_effect_mode_ok (PLUS, operands, 4, 2, 3, -1, 0)"
1976   "*
1978   if (which_alternative == 0
1979       && (GET_CODE (operands[3]) != CONST_INT
1980           || INTVAL (operands[3]) > 127
1981           || INTVAL (operands[3]) < -128
1982           || CONST_OK_FOR_LETTER_P (INTVAL (operands[3]), 'N')
1983           || CONST_OK_FOR_LETTER_P (INTVAL (operands[3]), 'J')))
1984     return \"#\";
1985   return \"%x5%e6.%m6 [%4=%2%S3],%0\";
1988 ;; QImode to SImode
1990 (define_insn "*extopqisi_side"
1991   [(set (match_operand:SI 0 "register_operand" "=r,r,r")
1992         (match_operator:SI
1993          5 "cris_operand_extend_operator"
1994          [(match_operand:SI 1 "register_operand" "0,0,0")
1995           (match_operator:SI
1996            6 "cris_extend_operator"
1997            [(mem:QI
1998              (plus:SI (match_operand:SI 2 "cris_bdap_operand" "%r,r,r")
1999                       (match_operand:SI 3 "cris_bdap_operand" "r>Rn,r,>Rn")
2000                       ))])]))
2001    (set (match_operand:SI 4 "register_operand" "=*2,r,r")
2002         (plus:SI (match_dup 2)
2003                  (match_dup 3)))]
2005   "(GET_CODE (operands[5]) != UMIN || GET_CODE (operands[6]) == ZERO_EXTEND)
2006    && cris_side_effect_mode_ok (PLUS, operands, 4, 2, 3, -1, 0)"
2007   "*
2009   if (which_alternative == 0
2010       && (GET_CODE (operands[3]) != CONST_INT
2011           || INTVAL (operands[3]) > 127
2012           || INTVAL (operands[3]) < -128
2013           || CONST_OK_FOR_LETTER_P (INTVAL (operands[3]), 'N')
2014           || CONST_OK_FOR_LETTER_P (INTVAL (operands[3]), 'J')))
2015     return \"#\";
2016   return \"%x5%e6.%m6 [%4=%2%S3],%0\";
2019 ;; HImode to SImode
2021 (define_insn "*extophisi_side"
2022   [(set (match_operand:SI 0 "register_operand" "=r,r,r")
2023         (match_operator:SI
2024          5 "cris_operand_extend_operator"
2025          [(match_operand:SI 1 "register_operand" "0,0,0")
2026           (match_operator:SI
2027            6 "cris_extend_operator"
2028            [(mem:HI
2029              (plus:SI (match_operand:SI 2 "cris_bdap_operand" "%r,r,r")
2030                       (match_operand:SI 3 "cris_bdap_operand" "r>Rn,r,>Rn")
2031                       ))])]))
2032    (set (match_operand:SI 4 "register_operand" "=*2,r,r")
2033         (plus:SI (match_dup 2)
2034                  (match_dup 3)))]
2035   "(GET_CODE (operands[5]) != UMIN || GET_CODE (operands[6]) == ZERO_EXTEND)
2036    && cris_side_effect_mode_ok (PLUS, operands, 4, 2, 3, -1, 0)"
2037   "*
2039   if (which_alternative == 0
2040       && (GET_CODE (operands[3]) != CONST_INT
2041           || INTVAL (operands[3]) > 127
2042           || INTVAL (operands[3]) < -128
2043           || CONST_OK_FOR_LETTER_P (INTVAL (operands[3]), 'N')
2044           || CONST_OK_FOR_LETTER_P (INTVAL (operands[3]), 'J')))
2045     return \"#\";
2046   return \"%x5%e6.%m6 [%4=%2%S3],%0\";
2050 ;; As with op.S we may have to add special pattern to match commuted
2051 ;; operands to adds/addu  and bound
2053 ;; adds/addu/bound [rx=ry+rz.S]
2055 ;; QImode to HImode
2056 ;; FIXME: GCC should widen.
2058 (define_insn "*extopqihi_swap_side_biap"
2059   [(set (match_operand:HI 0 "register_operand" "=r,r")
2060         (plus:HI
2061          (match_operator:HI
2062           6 "cris_extend_operator"
2063           [(mem:QI (plus:SI
2064                     (mult:SI (match_operand:SI 2 "register_operand" "r,r")
2065                              (match_operand:SI 3 "const_int_operand" "n,n"))
2066                     (match_operand:SI 4 "register_operand" "r,r")))])
2067          (match_operand:HI 1 "register_operand" "0,0")))
2068    (set (match_operand:SI 5 "register_operand" "=*4,r")
2069         (plus:SI (mult:SI (match_dup 2)
2070                           (match_dup 3))
2071                  (match_dup 4)))]
2072   "cris_side_effect_mode_ok (MULT, operands, 5, 4, 2, 3, 0)"
2073   "@
2074    #
2075    add%e6.b [%5=%4+%2%T3],%0")
2077 ;; QImode to SImode
2079 (define_insn "*extopqisi_swap_side_biap"
2080   [(set (match_operand:SI 0 "register_operand" "=r,r")
2081         (match_operator:SI
2082          7 "cris_plus_or_bound_operator"
2083          [(match_operator:SI
2084            6 "cris_extend_operator"
2085            [(mem:QI (plus:SI
2086                      (mult:SI (match_operand:SI 2 "register_operand" "r,r")
2087                               (match_operand:SI 3 "const_int_operand" "n,n"))
2088                      (match_operand:SI 4 "register_operand" "r,r")))])
2089           (match_operand:SI 1 "register_operand" "0,0")]))
2090    (set (match_operand:SI 5 "register_operand" "=*4,r")
2091         (plus:SI (mult:SI (match_dup 2)
2092                           (match_dup 3))
2093                  (match_dup 4)))]
2094   "(GET_CODE (operands[7]) != UMIN || GET_CODE (operands[6]) == ZERO_EXTEND)
2095    && cris_side_effect_mode_ok (MULT, operands, 5, 4, 2, 3, 0)"
2096   "@
2097    #
2098    %x7%e6.%m6 [%5=%4+%2%T3],%0")
2100 ;; HImode to SImode
2101 (define_insn "*extophisi_swap_side_biap"
2102   [(set (match_operand:SI 0 "register_operand" "=r,r")
2103         (match_operator:SI
2104          7 "cris_plus_or_bound_operator"
2105          [(match_operator:SI
2106            6 "cris_extend_operator"
2107            [(mem:HI (plus:SI
2108                      (mult:SI (match_operand:SI 2 "register_operand" "r,r")
2109                               (match_operand:SI 3 "const_int_operand" "n,n"))
2110                      (match_operand:SI 4 "register_operand" "r,r")))])
2111           (match_operand:SI 1 "register_operand" "0,0")]))
2112    (set (match_operand:SI 5 "register_operand" "=*4,r")
2113         (plus:SI (mult:SI (match_dup 2)
2114                           (match_dup 3))
2115                  (match_dup 4)))]
2116   "(GET_CODE (operands[7]) != UMIN || GET_CODE (operands[6]) == ZERO_EXTEND)
2117    && cris_side_effect_mode_ok (MULT, operands, 5, 4, 2, 3, 0)"
2118   "@
2119    #
2120    %x7%e6.%m6 [%5=%4+%2%T3],%0")
2122 ;; [rx=ry+i]
2123 ;; FIXME: These could have anonymous mode for operand 0.
2124 ;; FIXME: GCC should widen.
2126 ;; QImode to HImode
2128 (define_insn "*extopqihi_swap_side"
2129   [(set (match_operand:HI 0 "register_operand" "=r,r,r")
2130         (plus:HI
2131          (match_operator:HI
2132           5 "cris_extend_operator"
2133           [(mem:QI (plus:SI
2134                     (match_operand:SI 2 "cris_bdap_operand" "%r,r,r")
2135                     (match_operand:SI 3 "cris_bdap_operand" "r>Rn,r,>Rn")))])
2136          (match_operand:HI 1 "register_operand" "0,0,0")))
2137    (set (match_operand:SI 4 "register_operand" "=*2,r,r")
2138         (plus:SI (match_dup 2)
2139                  (match_dup 3)))]
2140   "cris_side_effect_mode_ok (PLUS, operands, 4, 2, 3, -1, 0)"
2141   "*
2143   if (which_alternative == 0
2144       && (GET_CODE (operands[3]) != CONST_INT
2145           || INTVAL (operands[3]) > 127
2146           || INTVAL (operands[3]) < -128
2147           || CONST_OK_FOR_LETTER_P (INTVAL (operands[3]), 'N')
2148           || CONST_OK_FOR_LETTER_P (INTVAL (operands[3]), 'J')))
2149     return \"#\";
2150   return \"add%e5.b [%4=%2%S3],%0\";
2153 ;; QImode to SImode
2155 (define_insn "*extopqisi_swap_side"
2156   [(set (match_operand:SI 0 "register_operand" "=r,r,r")
2157         (match_operator:SI
2158          6 "cris_plus_or_bound_operator"
2159          [(match_operator:SI
2160            5 "cris_extend_operator"
2161            [(mem:QI (plus:SI
2162                      (match_operand:SI 2 "cris_bdap_operand" "%r,r,r")
2163                      (match_operand:SI 3 "cris_bdap_operand" "r>Rn,r,>Rn")))])
2164           (match_operand:SI 1 "register_operand" "0,0,0")]))
2165    (set (match_operand:SI 4 "register_operand" "=*2,r,r")
2166         (plus:SI (match_dup 2)
2167                  (match_dup 3)))]
2168   "(GET_CODE (operands[6]) != UMIN || GET_CODE (operands[5]) == ZERO_EXTEND)
2169    && cris_side_effect_mode_ok (PLUS, operands, 4, 2, 3, -1, 0)"
2170   "*
2172   if (which_alternative == 0
2173       && (GET_CODE (operands[3]) != CONST_INT
2174           || INTVAL (operands[3]) > 127
2175           || INTVAL (operands[3]) < -128
2176           || CONST_OK_FOR_LETTER_P (INTVAL (operands[3]), 'N')
2177           || CONST_OK_FOR_LETTER_P (INTVAL (operands[3]), 'J')))
2178     return \"#\";
2179   return \"%x6%e5.%m5 [%4=%2%S3],%0\";
2182 ;; HImode to SImode
2184 (define_insn "*extophisi_swap_side"
2185   [(set (match_operand:SI 0 "register_operand" "=r,r,r")
2186         (match_operator:SI
2187          6 "cris_plus_or_bound_operator"
2188          [(match_operator:SI
2189            5 "cris_extend_operator"
2190            [(mem:HI (plus:SI
2191                      (match_operand:SI 2 "cris_bdap_operand" "%r,r,r")
2192                      (match_operand:SI 3 "cris_bdap_operand" "r>Rn,r,>Rn")))])
2193           (match_operand:SI 1 "register_operand" "0,0,0")]))
2194    (set (match_operand:SI 4 "register_operand" "=*2,r,r")
2195         (plus:SI (match_dup 2)
2196                  (match_dup 3)))]
2197   "(GET_CODE (operands[6]) != UMIN || GET_CODE (operands[5]) == ZERO_EXTEND)
2198    && cris_side_effect_mode_ok (PLUS, operands, 4, 2, 3, -1, 0)"
2199   "*
2201   if (which_alternative == 0
2202       && (GET_CODE (operands[3]) != CONST_INT
2203           || INTVAL (operands[3]) > 127
2204           || INTVAL (operands[3]) < -128
2205           || CONST_OK_FOR_LETTER_P (INTVAL (operands[3]), 'N')
2206           || CONST_OK_FOR_LETTER_P (INTVAL (operands[3]), 'J')))
2207     return \"#\";
2208   return \"%x6%e5.%m5 [%4=%2%S3],%0\";
2211 ;; Extend versions (zero/sign) of normal add/sub (no side-effects).
2212 ;; FIXME: These could have anonymous mode for operand 0.
2214 ;; QImode to HImode
2215 ;; FIXME: GCC should widen.
2217 (define_insn "*extopqihi"
2218   [(set (match_operand:HI 0 "register_operand" "=r,r,r,r")
2219         (match_operator:HI
2220          3 "cris_additive_operand_extend_operator"
2221          [(match_operand:HI 1 "register_operand" "0,0,0,r")
2222           (match_operator:HI
2223            4 "cris_extend_operator"
2224            [(match_operand:QI 2 "nonimmediate_operand" "r,Q>,m,!To")])]))]
2225   "GET_MODE_SIZE (GET_MODE (operands[0])) <= UNITS_PER_WORD
2226    && (operands[1] != frame_pointer_rtx || GET_CODE (operands[3]) != PLUS)"
2227   "@
2228    %x3%e4.%m4 %2,%0
2229    %x3%e4.%m4 %2,%0
2230    %x3%e4.%m4 %2,%0
2231    %x3%e4.%m4 %2,%1,%0"
2232   [(set_attr "slottable" "yes,yes,no,no")
2233    (set_attr "cc" "clobber")])
2235 ;; QImode to SImode
2237 (define_insn "*extopqisi"
2238   [(set (match_operand:SI 0 "register_operand" "=r,r,r,r")
2239         (match_operator:SI
2240          3 "cris_operand_extend_operator"
2241          [(match_operand:SI 1 "register_operand" "0,0,0,r")
2242           (match_operator:SI
2243            4 "cris_extend_operator"
2244            [(match_operand:QI 2 "nonimmediate_operand" "r,Q>,m,!To")])]))]
2245   "(GET_CODE (operands[3]) != UMIN || GET_CODE (operands[4]) == ZERO_EXTEND)
2246    && GET_MODE_SIZE (GET_MODE (operands[0])) <= UNITS_PER_WORD
2247    && (operands[1] != frame_pointer_rtx || GET_CODE (operands[3]) != PLUS)"
2248   "@
2249    %x3%e4.%m4 %2,%0
2250    %x3%e4.%m4 %2,%0
2251    %x3%e4.%m4 %2,%0
2252    %x3%e4.%m4 %2,%1,%0"
2253   [(set_attr "slottable" "yes,yes,no,no")])
2255 ;; HImode to SImode
2257 (define_insn "*extophisi"
2258   [(set (match_operand:SI 0 "register_operand" "=r,r,r,r")
2259         (match_operator:SI
2260          3 "cris_operand_extend_operator"
2261          [(match_operand:SI 1 "register_operand" "0,0,0,r")
2262           (match_operator:SI
2263            4 "cris_extend_operator"
2264            [(match_operand:HI 2 "nonimmediate_operand" "r,Q>,m,!To")])]))]
2265   "(GET_CODE (operands[3]) != UMIN || GET_CODE (operands[4]) == ZERO_EXTEND)
2266    && GET_MODE_SIZE (GET_MODE (operands[0])) <= UNITS_PER_WORD
2267    && (operands[1] != frame_pointer_rtx || GET_CODE (operands[3]) != PLUS)"
2268   "@
2269    %x3%e4.%m4 %2,%0
2270    %x3%e4.%m4 %2,%0
2271    %x3%e4.%m4 %2,%0
2272    %x3%e4.%m4 %2,%1,%0"
2273   [(set_attr "slottable" "yes,yes,no,no")])
2276 ;; As with the side-effect patterns, may have to have swapped operands for add.
2277 ;; FIXME: *should* be redundant to gcc.
2279 ;; QImode to HImode
2281 (define_insn "*extopqihi_swap"
2282   [(set (match_operand:HI 0 "register_operand" "=r,r,r,r")
2283         (plus:HI
2284          (match_operator:HI
2285           3 "cris_extend_operator"
2286           [(match_operand:QI 2 "nonimmediate_operand" "r,Q>,m,!To")])
2287          (match_operand:HI 1 "register_operand" "0,0,0,r")))]
2288   "operands[1] != frame_pointer_rtx"
2289   "@
2290    add%e3.b %2,%0
2291    add%e3.b %2,%0
2292    add%e3.b %2,%0
2293    add%e3.b %2,%1,%0"
2294   [(set_attr "slottable" "yes,yes,no,no")
2295    (set_attr "cc" "clobber")])
2297 ;; QImode to SImode
2299 (define_insn "*extopqisi_swap"
2300   [(set (match_operand:SI 0 "register_operand" "=r,r,r,r")
2301         (match_operator:SI
2302          4 "cris_plus_or_bound_operator"
2303          [(match_operator:SI
2304            3 "cris_extend_operator"
2305            [(match_operand:QI 2 "nonimmediate_operand" "r,Q>,m,!To")])
2306           (match_operand:SI 1 "register_operand" "0,0,0,r")]))]
2307   "(GET_CODE (operands[4]) != UMIN || GET_CODE (operands[3]) == ZERO_EXTEND)
2308    && operands[1] != frame_pointer_rtx"
2309   "@
2310    %x4%e3.%m3 %2,%0
2311    %x4%e3.%m3 %2,%0
2312    %x4%e3.%m3 %2,%0
2313    %x4%e3.%m3 %2,%1,%0"
2314   [(set_attr "slottable" "yes,yes,no,no")])
2316 ;; HImode to SImode
2318 (define_insn "*extophisi_swap"
2319   [(set (match_operand:SI 0 "register_operand" "=r,r,r,r")
2320         (match_operator:SI
2321          4 "cris_plus_or_bound_operator"
2322          [(match_operator:SI
2323            3 "cris_extend_operator"
2324            [(match_operand:HI 2 "nonimmediate_operand" "r,Q>,m,!To")])
2325           (match_operand:SI 1 "register_operand" "0,0,0,r")]))]
2326   "(GET_CODE (operands[4]) != UMIN || GET_CODE (operands[3]) == ZERO_EXTEND)
2327    && operands[1] != frame_pointer_rtx"
2328   "@
2329    %x4%e3.%m3 %2,%0
2330    %x4%e3.%m3 %2,%0
2331    %x4%e3.%m3 %2,%0
2332    %x4%e3.%m3 %2,%1,%0"
2333   [(set_attr "slottable" "yes,yes,no,no")])
2335 ;; This is the special case when we use what corresponds to the
2336 ;; instruction above in "casesi".  Do *not* change it to use the generic
2337 ;; pattern and "REG 15" as pc; I did that and it led to madness and
2338 ;; maintenance problems: Instead of (as imagined) recognizing and removing
2339 ;; or replacing this pattern with something simpler, other variant
2340 ;; patterns were recognized or combined, including some prefix variants
2341 ;; where the value in pc is not that of the next instruction (which means
2342 ;; this instruction actually *is* special and *should* be marked as such).
2343 ;; When switching from the "generic pattern match" approach to this simpler
2344 ;; approach, there were insignificant differences in gcc, ipps and
2345 ;; product code, somehow due to scratching reload behind the ear or
2346 ;; something.  Testcase "gcc" looked .01% slower and 4 bytes bigger;
2347 ;; product code became .001% smaller but "looked better".  The testcase
2348 ;; "ipps" was just different at register allocation).
2350 ;; Assumptions in the jump optimizer forces us to use IF_THEN_ELSE in this
2351 ;; pattern with the default-label as the else, with the "if" being
2352 ;; index-is-less-than the max number of cases plus one.  The default-label
2353 ;; is attached to the end of the case-table at time of output.
2355 (define_insn "*casesi_adds_w"
2356   [(set (pc)
2357         (if_then_else
2358          (ltu (match_operand:SI 0 "register_operand" "r")
2359               (match_operand:SI 1 "const_int_operand" "n"))
2360          (plus:SI (sign_extend:SI
2361                    (mem:HI
2362                     (plus:SI (mult:SI (match_dup 0) (const_int 2))
2363                              (pc))))
2364                   (pc))
2365          (label_ref (match_operand 2 "" ""))))
2366    (use (label_ref (match_operand 3 "" "")))]
2368   "operands[0] != frame_pointer_rtx"
2370   "adds.w [$pc+%0.w],$pc"
2371   [(set_attr "cc" "clobber")])
2373 ;; Multiply instructions.
2375 ;; Sometimes powers of 2 (which are normally canonicalized to a
2376 ;; left-shift) appear here, as a result of address reloading.
2377 ;; As a special, for values 3 and 5, we can match with an addi, so add those.
2379 ;; FIXME: This may be unnecessary now.
2380 ;; Explicitly named for convenience of having a gen_... function.
2382 (define_insn "addi_mul"
2383   [(set (match_operand:SI 0 "register_operand" "=r")
2384         (mult:SI
2385          (match_operand:SI 1 "register_operand" "%0")
2386          (match_operand:SI 2 "const_int_operand" "n")))]
2387   "operands[0] != frame_pointer_rtx
2388    && operands[1] != frame_pointer_rtx
2389    && GET_CODE (operands[2]) == CONST_INT
2390    && (INTVAL (operands[2]) == 2
2391        || INTVAL (operands[2]) == 4 || INTVAL (operands[2]) == 3
2392        || INTVAL (operands[2]) == 5)"
2393   "*
2395   if (INTVAL (operands[2]) == 2)
2396     return \"lslq 1,%0\";
2397   else if (INTVAL (operands[2]) == 4)
2398     return \"lslq 2,%0\";
2399   else if (INTVAL (operands[2]) == 3)
2400     return \"addi %0.w,%0\";
2401   else if (INTVAL (operands[2]) == 5)
2402     return \"addi %0.d,%0\";
2403   return \"BAD: adr_mulsi: %0=%1*%2\";
2405 [(set_attr "slottable" "yes")
2406  ;; No flags are changed if this insn is "addi", but it does not seem
2407  ;; worth the trouble to distinguish that to the lslq cases.
2408  (set_attr "cc" "clobber")])
2410 ;; The addi insn as it is normally used.
2412 (define_insn "*addi"
2413   [(set (match_operand:SI 0 "register_operand" "=r")
2414         (plus:SI
2415          (mult:SI (match_operand:SI 2 "register_operand" "r")
2416                   (match_operand:SI 3 "const_int_operand" "n"))
2417          (match_operand:SI 1 "register_operand" "0")))]
2418   "operands[0] != frame_pointer_rtx
2419    && operands[1] != frame_pointer_rtx
2420    && GET_CODE (operands[3]) == CONST_INT
2421    && (INTVAL (operands[3]) == 1
2422        || INTVAL (operands[3]) == 2 || INTVAL (operands[3]) == 4)"
2423   "addi %2%T3,%0"
2424   [(set_attr "slottable" "yes")
2425    (set_attr "cc" "none")])
2427 ;; The mstep instruction.  Probably not useful by itself; it's to
2428 ;; non-linear wrt. the other insns.  We used to expand to it, so at least
2429 ;; it's correct.
2431 (define_insn "mstep_shift"
2432   [(set (match_operand:SI 0 "register_operand" "=r")
2433         (if_then_else:SI
2434          (lt:SI (cc0) (const_int 0))
2435          (plus:SI (ashift:SI (match_operand:SI 1 "register_operand" "0")
2436                              (const_int 1))
2437                   (match_operand:SI 2 "register_operand" "r"))
2438          (ashift:SI (match_operand:SI 3 "register_operand" "0")
2439                     (const_int 1))))]
2440   ""
2441   "mstep %2,%0"
2442   [(set_attr "slottable" "yes")])
2444 ;; When illegitimate addresses are legitimized, sometimes gcc forgets
2445 ;; to canonicalize the multiplications.
2447 ;; FIXME: Check gcc > 2.7.2, remove and possibly fix in gcc.
2449 (define_insn "mstep_mul"
2450   [(set (match_operand:SI 0 "register_operand" "=r")
2451         (if_then_else:SI
2452          (lt:SI (cc0) (const_int 0))
2453          (plus:SI (mult:SI (match_operand:SI 1 "register_operand" "0")
2454                            (const_int 2))
2455                   (match_operand:SI 2 "register_operand" "r"))
2456          (mult:SI (match_operand:SI 3 "register_operand" "0")
2457                   (const_int 2))))]
2458   "operands[0] != frame_pointer_rtx
2459    && operands[1] != frame_pointer_rtx
2460    && operands[2] != frame_pointer_rtx
2461    && operands[3] != frame_pointer_rtx"
2462   "mstep %2,%0"
2463   [(set_attr "slottable" "yes")])
2465 (define_insn "umulhisi3"
2466   [(set (match_operand:SI 0 "register_operand" "=r")
2467         (mult:SI
2468          (zero_extend:SI (match_operand:HI 1 "register_operand" "0"))
2469          (zero_extend:SI (match_operand:HI 2 "register_operand" "r"))))]
2470   "TARGET_HAS_MUL_INSNS"
2471   "%!mulu.w %2,%0"
2472   [(set (attr "slottable")
2473         (if_then_else (ne (symbol_ref "TARGET_MUL_BUG") (const_int 0))
2474                       (const_string "no")
2475                       (const_string "yes")))
2476    ;; Just N unusable here, but let's be safe.
2477    (set_attr "cc" "clobber")])
2479 (define_insn "umulqihi3"
2480   [(set (match_operand:HI 0 "register_operand" "=r")
2481         (mult:HI
2482          (zero_extend:HI (match_operand:QI 1 "register_operand" "0"))
2483          (zero_extend:HI (match_operand:QI 2 "register_operand" "r"))))]
2484   "TARGET_HAS_MUL_INSNS"
2485   "%!mulu.b %2,%0"
2486   [(set (attr "slottable")
2487         (if_then_else (ne (symbol_ref "TARGET_MUL_BUG") (const_int 0))
2488                       (const_string "no")
2489                       (const_string "yes")))
2490    ;; Not exactly sure, but let's be safe.
2491    (set_attr "cc" "clobber")])
2493 ;; Note that gcc does not make use of such a thing as umulqisi3.  It gets
2494 ;; confused and will erroneously use it instead of umulhisi3, failing (at
2495 ;; least) gcc.c-torture/execute/arith-rand.c at all optimization levels.
2496 ;; Inspection of optab code shows that there must be only one widening
2497 ;; multiplication per mode widened to.
2499 (define_insn "mulsi3"
2500   [(set (match_operand:SI 0 "register_operand" "=r")
2501         (mult:SI (match_operand:SI 1 "register_operand" "0")
2502                  (match_operand:SI 2 "register_operand" "r")))]
2503   "TARGET_HAS_MUL_INSNS"
2504   "%!muls.d %2,%0"
2505   [(set (attr "slottable")
2506         (if_then_else (ne (symbol_ref "TARGET_MUL_BUG") (const_int 0))
2507                       (const_string "no")
2508                       (const_string "yes")))
2509    ;; Just N unusable here, but let's be safe.
2510    (set_attr "cc" "clobber")])
2512 ;; A few multiply variations.
2514 ;; This really extends to SImode, so cc should be considered clobbered.
2516 (define_insn "mulqihi3"
2517   [(set (match_operand:HI 0 "register_operand" "=r")
2518         (mult:HI
2519          (sign_extend:HI (match_operand:QI 1 "register_operand" "0"))
2520          (sign_extend:HI (match_operand:QI 2 "register_operand" "r"))))]
2521   "TARGET_HAS_MUL_INSNS"
2522   "%!muls.b %2,%0"
2523   [(set (attr "slottable")
2524         (if_then_else (ne (symbol_ref "TARGET_MUL_BUG") (const_int 0))
2525                       (const_string "no")
2526                       (const_string "yes")))
2527    (set_attr "cc" "clobber")])
2529 (define_insn "mulhisi3"
2530   [(set (match_operand:SI 0 "register_operand" "=r")
2531         (mult:SI
2532          (sign_extend:SI (match_operand:HI 1 "register_operand" "0"))
2533          (sign_extend:SI (match_operand:HI 2 "register_operand" "r"))))]
2534   "TARGET_HAS_MUL_INSNS"
2535   "%!muls.w %2,%0"
2536   [(set (attr "slottable")
2537         (if_then_else (ne (symbol_ref "TARGET_MUL_BUG") (const_int 0))
2538                       (const_string "no")
2539                       (const_string "yes")))
2540    ;; Just N unusable here, but let's be safe.
2541    (set_attr "cc" "clobber")])
2543 ;; When needed, we can get the high 32 bits from the overflow
2544 ;; register.  We don't care to split and optimize these.
2546 ;; Note that cc0 is still valid after the move-from-overflow-register
2547 ;; insn; no special precaution need to be taken in cris_notice_update_cc.
2549 (define_insn "mulsidi3"
2550   [(set (match_operand:DI 0 "register_operand" "=r")
2551         (mult:DI
2552          (sign_extend:DI (match_operand:SI 1 "register_operand" "0"))
2553          (sign_extend:DI (match_operand:SI 2 "register_operand" "r"))))]
2554   "TARGET_HAS_MUL_INSNS"
2555   "%!muls.d %2,%M0\;move $mof,%H0")
2557 (define_insn "umulsidi3"
2558   [(set (match_operand:DI 0 "register_operand" "=r")
2559         (mult:DI
2560          (zero_extend:DI (match_operand:SI 1 "register_operand" "0"))
2561          (zero_extend:DI (match_operand:SI 2 "register_operand" "r"))))]
2562   "TARGET_HAS_MUL_INSNS"
2563   "%!mulu.d %2,%M0\;move $mof,%H0")
2565 ;; This pattern would probably not be needed if we add "mof" in its own
2566 ;; register class (and open a can of worms about /not/ pairing it with a
2567 ;; "normal" register).  Having multiple register classes here, and
2568 ;; applicable to the v10 variant only, seems worse than having these two
2569 ;; patterns with multi-insn contents for now (may change; having a free
2570 ;; call-clobbered register is worth some trouble).
2572 (define_insn "smulsi3_highpart"
2573   [(set (match_operand:SI 0 "nonimmediate_operand" "=r,r,m")
2574         (truncate:SI
2575          (lshiftrt:DI
2576           (mult:DI
2577            (sign_extend:DI (match_operand:SI 1 "register_operand" "%0,r,r"))
2578            (sign_extend:DI (match_operand:SI 2 "register_operand" "r,r,r")))
2579           (const_int 32))))
2580    (clobber (match_scratch:SI 3 "=X,1,1"))]
2581   "TARGET_HAS_MUL_INSNS"
2582   "%!muls.d %2,%1\;move $mof,%0"
2583   [(set_attr "cc" "clobber")])
2585 (define_insn "umulsi3_highpart"
2586   [(set (match_operand:SI 0 "nonimmediate_operand" "=r,r,m")
2587         (truncate:SI
2588          (lshiftrt:DI
2589           (mult:DI
2590            (zero_extend:DI (match_operand:SI 1 "register_operand" "%0,r,r"))
2591            (zero_extend:DI (match_operand:SI 2 "register_operand" "r,r,r")))
2592           (const_int 32))))
2593    (clobber (match_scratch:SI 3 "=X,1,1"))]
2594   "TARGET_HAS_MUL_INSNS"
2595   "%!mulu.d %2,%1\;move $mof,%0"
2596   [(set_attr "cc" "clobber")])
2598 ;; Divide and modulus instructions.  CRIS only has a step instruction.
2600 (define_insn "dstep_shift"
2601   [(set (match_operand:SI 0 "register_operand" "=r")
2602         (if_then_else:SI
2603          (geu:SI (ashift:SI (match_operand:SI 1 "register_operand" "0")
2604                             (const_int 1))
2605               (match_operand:SI 2 "register_operand" "r"))
2606          (minus:SI (ashift:SI (match_operand:SI 3 "register_operand" "0")
2607                         (const_int 1))
2608                    (match_operand:SI 4 "register_operand" "2"))
2609          (ashift:SI (match_operand:SI 5 "register_operand" "0")
2610                         (const_int 1))))]
2611   ""
2612   "dstep %2,%0"
2613   [(set_attr "slottable" "yes")])
2615 ;; Here's a variant with mult instead of ashift.
2617 ;; FIXME: This should be investigated.  Which one matches through combination?
2619 (define_insn "dstep_mul"
2620   [(set (match_operand:SI 0 "register_operand" "=r")
2621         (if_then_else:SI
2622          (geu:SI (mult:SI (match_operand:SI 1 "register_operand" "0")
2623                           (const_int 2))
2624               (match_operand:SI 2 "register_operand" "r"))
2625          (minus:SI (mult:SI (match_operand:SI 3 "register_operand" "0")
2626                             (const_int 2))
2627                    (match_operand:SI 4 "register_operand" "2"))
2628          (mult:SI (match_operand:SI 5 "register_operand" "0")
2629                   (const_int 2))))]
2630   "operands[0] != frame_pointer_rtx
2631    && operands[1] != frame_pointer_rtx
2632    && operands[2] != frame_pointer_rtx
2633    && operands[3] != frame_pointer_rtx"
2634   "dstep %2,%0"
2635   [(set_attr "slottable" "yes")])
2637 ;; Logical operators.
2639 ;; Bitwise "and".
2641 ;; There is no use in defining "anddi3", because gcc can expand this by
2642 ;; itself, and make reasonable code without interference.
2644 ;; If the first operand is memory or a register and is the same as the
2645 ;; second operand, and the third operand is -256 or -65536, we can use
2646 ;; CLEAR instead.  Or, if the first operand is a register, and the third
2647 ;; operand is 255 or 65535, we can zero_extend.
2648 ;; GCC isn't smart enough to recognize these cases (yet), and they seem
2649 ;; to be common enough to be worthwhile.
2650 ;; FIXME: This should be made obsolete.
2652 (define_expand "andsi3"
2653   [(set (match_operand:SI 0 "nonimmediate_operand"         "")
2654         (and:SI (match_operand:SI 1 "nonimmediate_operand" "")
2655                 (match_operand:SI 2 "general_operand"    "")))]
2656   ""
2657   "
2659   if (! (GET_CODE (operands[2]) == CONST_INT
2660          && (((INTVAL (operands[2]) == -256
2661                || INTVAL (operands[2]) == -65536)
2662               && rtx_equal_p (operands[1], operands[0]))
2663              || ((INTVAL (operands[2]) == 255
2664                   || INTVAL (operands[2]) == 65535)
2665                  && REG_P (operands[0])))))
2666     {
2667       /* Make intermediate steps if operand0 is not a register or
2668          operand1 is not a register, and hope that the reload pass will
2669          make something useful out of it.  Note that the operands are
2670          *not* canonicalized.  For the moment, I chicken out on this,
2671          because all or most ports do not describe 'and' with
2672          canonicalized operands, and I seem to remember magic in reload,
2673          checking that operand1 has constraint '%0', in which case
2674          operand0 and operand1 must have similar predicates.
2675          FIXME: Investigate.  */
2676       rtx reg0 = REG_P (operands[0]) ? operands[0] : gen_reg_rtx (SImode);
2677       rtx reg1 = operands[1];
2679       if (! REG_P (reg1))
2680         {
2681           emit_move_insn (reg0, reg1);
2682           reg1 = reg0;
2683         }
2685       emit_insn (gen_rtx_SET (SImode, reg0,
2686                           gen_rtx_AND (SImode, reg1, operands[2])));
2688       /* Make sure we get the right *final* destination.  */
2689       if (! REG_P (operands[0]))
2690         emit_move_insn (operands[0], reg0);
2692       DONE;
2693     }
2696 ;; Some special cases of andsi3.
2698 (define_insn "*andsi_movu"
2699   [(set (match_operand:SI 0 "register_operand" "=r,r,r")
2700         (and:SI (match_operand:SI 1 "nonimmediate_operand" "%r,Q,To")
2701                 (match_operand:SI 2 "const_int_operand" "n,n,n")))]
2702   "(INTVAL (operands[2]) == 255 || INTVAL (operands[2]) == 65535)
2703    && (GET_CODE (operands[1]) != MEM || ! MEM_VOLATILE_P (operands[1]))"
2704   "movu.%z2 %1,%0"
2705   [(set_attr "slottable" "yes,yes,no")])
2707 (define_insn "*andsi_clear"
2708   [(set (match_operand:SI 0 "nonimmediate_operand" "=r,r,Q,Q,To,To")
2709         (and:SI (match_operand:SI 1 "nonimmediate_operand" "%0,0,0,0,0,0")
2710                 (match_operand:SI 2 "const_int_operand" "P,n,P,n,P,n")))]
2711   "(INTVAL (operands[2]) == -65536 || INTVAL (operands[2]) == -256)
2712    && (GET_CODE (operands[0]) != MEM || ! MEM_VOLATILE_P (operands[0]))"
2713   "@
2714    cLear.b %0
2715    cLear.w %0
2716    cLear.b %0
2717    cLear.w %0
2718    cLear.b %0
2719    cLear.w %0"
2720   [(set_attr "slottable" "yes,yes,yes,yes,no,no")
2721    (set_attr "cc" "none")])
2723 ;; This is a catch-all pattern, taking care of everything that was not
2724 ;; matched in the insns above.
2726 ;; Sidenote: the tightening from "nonimmediate_operand" to
2727 ;; "register_operand" for operand 1 actually increased the register
2728 ;; pressure (worse code).  That will hopefully change with an
2729 ;; improved reload pass.
2731 (define_insn "*expanded_andsi"
2732   [(set (match_operand:SI 0 "register_operand" "=r,r,r,r,r")
2733         (and:SI (match_operand:SI 1 "register_operand" "%0,0,0,0,r")
2734                 (match_operand:SI 2 "general_operand" "I,r,Q>,g,!To")))]
2735   ""
2736   "@
2737    andq %2,%0
2738    and.d %2,%0
2739    and.d %2,%0
2740    and.d %2,%0
2741    and.d %2,%1,%0"
2742   [(set_attr "slottable" "yes,yes,yes,no,no")])
2744 ;; For both QI and HI we may use the quick patterns.  This results in
2745 ;; useless condition codes, but that is used rarely enough for it to
2746 ;; normally be a win (could check ahead for use of cc0, but seems to be
2747 ;; more pain than win).
2749 ;; FIXME: See note for andsi3
2751 (define_expand "andhi3"
2752   [(set (match_operand:HI 0 "nonimmediate_operand" "")
2753         (and:HI (match_operand:HI 1 "nonimmediate_operand" "")
2754                 (match_operand:HI 2 "general_operand"  "")))]
2755   ""
2756   "
2758   if (! (GET_CODE (operands[2]) == CONST_INT
2759          && (((INTVAL (operands[2]) == -256
2760                || INTVAL (operands[2]) == 65280)
2761               && rtx_equal_p (operands[1], operands[0]))
2762              || (INTVAL (operands[2]) == 255
2763                  && REG_P (operands[0])))))
2764     {
2765       /* See comment for andsi3.  */
2766       rtx reg0 = REG_P (operands[0]) ? operands[0] : gen_reg_rtx (HImode);
2767       rtx reg1 = operands[1];
2769       if (! REG_P (reg1))
2770         {
2771           emit_move_insn (reg0, reg1);
2772           reg1 = reg0;
2773         }
2775       emit_insn (gen_rtx_SET (HImode, reg0,
2776                           gen_rtx_AND (HImode, reg1, operands[2])));
2778       /* Make sure we get the right destination.  */
2779       if (! REG_P (operands[0]))
2780         emit_move_insn (operands[0], reg0);
2782       DONE;
2783     }
2786 ;; Some fast andhi3 special cases.
2788 (define_insn "*andhi_movu"
2789   [(set (match_operand:HI 0 "register_operand" "=r,r,r")
2790         (and:HI (match_operand:HI 1 "nonimmediate_operand" "r,Q,To")
2791                 (const_int 255)))]
2792   "GET_CODE (operands[1]) != MEM || ! MEM_VOLATILE_P (operands[1])"
2793   "mOvu.b %1,%0"
2794   [(set_attr "slottable" "yes,yes,no")])
2796 (define_insn "*andhi_clear"
2797   [(set (match_operand:HI 0 "nonimmediate_operand" "=r,Q,To")
2798         (and:HI (match_operand:HI 1 "nonimmediate_operand" "0,0,0")
2799                 (const_int -256)))]
2800   "GET_CODE (operands[0]) != MEM || ! MEM_VOLATILE_P (operands[0])"
2801   "cLear.b %0"
2802   [(set_attr "slottable" "yes,yes,no")
2803    (set_attr "cc" "none")])
2805 ;; Catch-all andhi3 pattern.
2807 (define_insn "*expanded_andhi"
2808   [(set (match_operand:HI 0 "register_operand" "=r,r,r,r,r,r,r")
2809         (and:HI (match_operand:HI 1 "register_operand" "%0,0,0,0,0,0,r")
2810                 (match_operand:HI 2 "general_operand" "I,r,Q>,L,O,g,!To")))]
2812 ;; Sidenote: the tightening from "general_operand" to
2813 ;; "register_operand" for operand 1 actually increased the register
2814 ;; pressure (worse code).  That will hopefully change with an
2815 ;; improved reload pass.
2817   ""
2818   "@
2819    andq %2,%0
2820    and.w %2,%0
2821    and.w %2,%0
2822    and.w %2,%0
2823    anDq %b2,%0
2824    and.w %2,%0
2825    and.w %2,%1,%0"
2826   [(set_attr "slottable" "yes,yes,yes,no,yes,no,no")
2827    (set_attr "cc" "clobber,normal,normal,normal,clobber,normal,normal")])
2829 ;; A strict_low_part pattern.
2831 (define_insn "*andhi_lowpart"
2832   [(set (strict_low_part
2833          (match_operand:HI 0 "register_operand" "=r,r,r,r,r,r"))
2834         (and:HI (match_operand:HI 1 "register_operand" "%0,0,0,0,0,r")
2835                 (match_operand:HI 2 "general_operand" "r,Q>,L,O,g,!To")))]
2836   ""
2837   "@
2838    and.w %2,%0
2839    and.w %2,%0
2840    and.w %2,%0
2841    anDq %b2,%0
2842    and.w %2,%0
2843    and.w %2,%1,%0"
2844   [(set_attr "slottable" "yes,yes,no,yes,no,no")
2845    (set_attr "cc" "normal,normal,normal,clobber,normal,normal")])
2847 (define_insn "andqi3"
2848   [(set (match_operand:QI 0 "register_operand" "=r,r,r,r,r,r")
2849         (and:QI (match_operand:QI 1 "register_operand" "%0,0,0,0,0,r")
2850                 (match_operand:QI 2 "general_operand" "I,r,Q>,O,g,!To")))]
2851   ""
2852   "@
2853    andq %2,%0
2854    and.b %2,%0
2855    and.b %2,%0
2856    andQ %b2,%0
2857    and.b %2,%0
2858    and.b %2,%1,%0"
2859   [(set_attr "slottable" "yes,yes,yes,yes,no,no")
2860    (set_attr "cc" "clobber,normal,normal,clobber,normal,normal")])
2862 (define_insn "*andqi_lowpart"
2863   [(set (strict_low_part
2864          (match_operand:QI 0 "register_operand" "=r,r,r,r,r"))
2865         (and:QI (match_operand:QI 1 "register_operand" "%0,0,0,0,r")
2866                 (match_operand:QI 2 "general_operand" "r,Q>,O,g,!To")))]
2867   ""
2868   "@
2869    and.b %2,%0
2870    and.b %2,%0
2871    andQ %b2,%0
2872    and.b %2,%0
2873    and.b %2,%1,%0"
2874   [(set_attr "slottable" "yes,yes,yes,no,no")
2875    (set_attr "cc" "normal,normal,clobber,normal,normal")])
2877 ;; Bitwise or.
2879 ;; Same comment as anddi3 applies here - no need for such a pattern.
2881 ;; It seems there's no need to jump through hoops to get good code such as
2882 ;; with andsi3.
2884 (define_insn "iorsi3"
2885   [(set (match_operand:SI 0 "register_operand" "=r,r,r,r,r,r")
2886         (ior:SI (match_operand:SI 1 "register_operand" "%0,0,0,0,0,r")
2887                 (match_operand:SI 2 "general_operand" "I,r,Q>,n,g,!To")))]
2888   ""
2889   "@
2890    orq %2,%0
2891    or.d %2,%0
2892    or.d %2,%0
2893    oR.%s2 %2,%0
2894    or.d %2,%0
2895    or.d %2,%1,%0"
2896   [(set_attr "slottable" "yes,yes,yes,no,no,no")
2897    (set_attr "cc" "normal,normal,normal,clobber,normal,normal")])
2899 (define_insn "iorhi3"
2900   [(set (match_operand:HI 0 "register_operand" "=r,r,r,r,r,r,r")
2901         (ior:HI (match_operand:HI 1 "register_operand" "%0,0,0,0,0,0,r")
2902                 (match_operand:HI 2 "general_operand" "I,r,Q>,L,O,g,!To")))]
2903   ""
2904   "@
2905    orq %2,%0
2906    or.w %2,%0
2907    or.w %2,%0
2908    or.w %2,%0
2909    oRq %b2,%0
2910    or.w %2,%0
2911    or.w %2,%1,%0"
2912   [(set_attr "slottable" "yes,yes,yes,no,yes,no,no")
2913    (set_attr "cc" "clobber,normal,normal,normal,clobber,normal,normal")])
2915 (define_insn "iorqi3"
2916   [(set (match_operand:QI 0 "register_operand" "=r,r,r,r,r,r")
2917         (ior:QI (match_operand:QI 1 "register_operand" "%0,0,0,0,0,r")
2918                 (match_operand:QI 2 "general_operand" "I,r,Q>,O,g,!To")))]
2919   ""
2920   "@
2921    orq %2,%0
2922    or.b %2,%0
2923    or.b %2,%0
2924    orQ %b2,%0
2925    or.b %2,%0
2926    or.b %2,%1,%0"
2927   [(set_attr "slottable" "yes,yes,yes,yes,no,no")
2928    (set_attr "cc" "clobber,normal,normal,clobber,normal,normal")])
2930 ;; Exclusive-or
2932 ;; See comment about "anddi3" for xordi3 - no need for such a pattern.
2934 (define_insn "xorsi3"
2935   [(set (match_operand:SI 0 "register_operand" "=r")
2936         (xor:SI (match_operand:SI 1 "register_operand" "%0")
2937                 (match_operand:SI 2 "register_operand" "r")))]
2938   ""
2939   "xor %2,%0"
2940   [(set_attr "slottable" "yes")])
2942 (define_insn "xorhi3"
2943   [(set (match_operand:HI 0 "register_operand" "=r")
2944         (xor:HI (match_operand:HI 1 "register_operand" "%0")
2945                 (match_operand:HI 2 "register_operand" "r")))]
2946   ""
2947   "xor %2,%0"
2948   [(set_attr "slottable" "yes")
2949    (set_attr "cc" "clobber")])
2951 (define_insn "xorqi3"
2952   [(set (match_operand:QI 0 "register_operand" "=r")
2953         (xor:QI (match_operand:QI 1 "register_operand" "%0")
2954                 (match_operand:QI 2 "register_operand" "r")))]
2955   ""
2956   "xor %2,%0"
2957   [(set_attr "slottable" "yes")
2958    (set_attr "cc" "clobber")])
2960 ;; Negation insns.
2962 ;; Questionable use, here mostly as a (slightly usable) define_expand
2963 ;; example.
2965 (define_expand "negsf2"
2966   [(set (match_dup 2)
2967         (match_dup 3))
2968    (parallel [(set (match_operand:SF 0 "register_operand" "=r")
2969                    (neg:SF (match_operand:SF 1
2970                             "register_operand" "0")))
2971               (use (match_dup 2))])]
2972   ""
2973   "
2975   operands[2] = gen_reg_rtx (SImode);
2976   operands[3] = GEN_INT (1 << 31);
2979 (define_insn "*expanded_negsf2"
2980   [(set (match_operand:SF 0 "register_operand" "=r")
2981         (neg:SF (match_operand:SF 1 "register_operand" "0")))
2982    (use (match_operand:SI 2 "register_operand" "r"))]
2983   ""
2984   "xor %2,%0"
2985   [(set_attr "slottable" "yes")])
2987 ;; No "negdi2" although we could make one up that may be faster than
2988 ;; the one in libgcc.
2990 (define_insn "negsi2"
2991   [(set (match_operand:SI 0 "register_operand" "=r")
2992         (neg:SI (match_operand:SI 1 "register_operand" "r")))]
2993   ""
2994   "neg.d %1,%0"
2995   [(set_attr "slottable" "yes")])
2997 (define_insn "neghi2"
2998   [(set (match_operand:HI 0 "register_operand" "=r")
2999         (neg:HI (match_operand:HI 1 "register_operand" "r")))]
3000   ""
3001   "neg.w %1,%0"
3002   [(set_attr "slottable" "yes")])
3004 (define_insn "negqi2"
3005   [(set (match_operand:QI 0 "register_operand" "=r")
3006         (neg:QI (match_operand:QI 1 "register_operand" "r")))]
3007   ""
3008   "neg.b %1,%0"
3009   [(set_attr "slottable" "yes")])
3011 ;; One-complements.
3013 ;; See comment on anddi3 - no need for a DImode pattern.
3015 (define_insn "one_cmplsi2"
3016   [(set (match_operand:SI 0 "register_operand" "=r")
3017         (not:SI (match_operand:SI 1 "register_operand" "0")))]
3018   ""
3019   "not %0"
3020   [(set_attr "slottable" "yes")])
3022 (define_insn "one_cmplhi2"
3023   [(set (match_operand:HI 0 "register_operand" "=r")
3024         (not:HI (match_operand:HI 1 "register_operand" "0")))]
3025   ""
3026   "not %0"
3027   [(set_attr "slottable" "yes")
3028    (set_attr "cc" "clobber")])
3030 (define_insn "one_cmplqi2"
3031   [(set (match_operand:QI 0 "register_operand" "=r")
3032         (not:QI (match_operand:QI 1 "register_operand" "0")))]
3033   ""
3034   "not %0"
3035   [(set_attr "slottable" "yes")
3036    (set_attr "cc" "clobber")])
3038 ;; Arithmetic shift right.
3040 (define_insn "ashrsi3"
3041   [(set (match_operand:SI 0 "register_operand" "=r")
3042         (ashiftrt:SI (match_operand:SI 1 "register_operand" "0")
3043                      (match_operand:SI 2 "nonmemory_operand" "Kr")))]
3044   ""
3045   "*
3047   if (REG_S_P (operands[2]))
3048     return \"asr.d %2,%0\";
3050   return \"asrq %2,%0\";
3052   [(set_attr "slottable" "yes")])
3054 ;; Since gcc gets lost, and forgets to zero-extend the source (or mask
3055 ;; the destination) when it changes shifts of lower modes into SImode,
3056 ;; it is better to make these expands an anonymous patterns instead of
3057 ;; the more correct define_insns.  This occurs when gcc thinks that is
3058 ;; is better to widen to SImode and use immediate shift count.
3060 ;; FIXME: Is this legacy or still true for gcc >= 2.7.2?
3062 (define_expand "ashrhi3"
3063   [(set (match_dup 3)
3064         (sign_extend:SI (match_operand:HI 1 "nonimmediate_operand" "rm")))
3065    (set (match_dup 4)
3066         (zero_extend:SI (match_operand:HI 2 "nonimmediate_operand" "rm")))
3067    (set (match_dup 5) (ashiftrt:SI (match_dup 3) (match_dup 4)))
3068    (set (match_operand:HI 0 "general_operand" "=g")
3069         (subreg:HI (match_dup 5) 0))]
3070   ""
3071   "
3073   int i;
3075   for (i = 3; i < 6; i++)
3076     operands[i] = gen_reg_rtx (SImode);
3079 (define_insn "*expanded_ashrhi"
3080   [(set (match_operand:HI 0 "register_operand" "=r")
3081         (ashiftrt:HI (match_operand:HI 1 "register_operand" "0")
3082                      (match_operand:HI 2 "register_operand" "r")))]
3083   ""
3084   "asr.w %2,%0"
3085   [(set_attr "slottable" "yes")])
3087 (define_insn "*ashrhi_lowpart"
3088   [(set (strict_low_part (match_operand:HI 0 "register_operand" "+r"))
3089         (ashiftrt:HI (match_dup 0)
3090                      (match_operand:HI 1 "register_operand" "r")))]
3091   ""
3092   "asr.w %1,%0"
3093   [(set_attr "slottable" "yes")])
3095 ;; Same comment goes as for "ashrhi3".
3097 (define_expand "ashrqi3"
3098   [(set (match_dup 3)
3099         (sign_extend:SI (match_operand:QI 1 "nonimmediate_operand" "g")))
3100    (set (match_dup 4)
3101         (zero_extend:SI (match_operand:QI 2 "nonimmediate_operand" "g")))
3102    (set (match_dup 5) (ashiftrt:SI (match_dup 3) (match_dup 4)))
3103    (set (match_operand:QI 0 "general_operand" "=g")
3104         (subreg:QI (match_dup 5) 0))]
3105   ""
3106   "
3108   int i;
3110   for (i = 3; i < 6; i++)
3111     operands[i] = gen_reg_rtx (SImode);
3114 (define_insn "*expanded_ashrqi"
3115   [(set (match_operand:QI 0 "register_operand" "=r")
3116         (ashiftrt:QI (match_operand:QI 1 "register_operand" "0")
3117                      (match_operand:QI 2 "register_operand" "r")))]
3118   ""
3119   "asr.b %2,%0"
3120   [(set_attr "slottable" "yes")])
3122 ;; A strict_low_part matcher.
3124 (define_insn "*ashrqi_lowpart"
3125   [(set (strict_low_part (match_operand:QI 0 "register_operand" "+r"))
3126         (ashiftrt:QI (match_dup 0)
3127                      (match_operand:QI 1 "register_operand" "r")))]
3128   ""
3129   "asr.b %1,%0"
3130   [(set_attr "slottable" "yes")])
3132 ;; Logical shift right.
3134 (define_insn "lshrsi3"
3135   [(set (match_operand:SI 0 "register_operand" "=r")
3136         (lshiftrt:SI (match_operand:SI 1 "register_operand" "0")
3137                      (match_operand:SI 2 "nonmemory_operand" "Kr")))]
3138   ""
3139   "*
3141   if (REG_S_P (operands[2]))
3142     return \"lsr.d %2,%0\";
3144   return \"lsrq %2,%0\";
3146   [(set_attr "slottable" "yes")])
3148 ;; Same comments as for ashrhi3.
3150 (define_expand "lshrhi3"
3151   [(set (match_dup 3)
3152         (zero_extend:SI (match_operand:HI 1 "nonimmediate_operand" "g")))
3153    (set (match_dup 4)
3154         (zero_extend:SI (match_operand:HI 2 "nonimmediate_operand" "g")))
3155    (set (match_dup 5) (lshiftrt:SI (match_dup 3) (match_dup 4)))
3156    (set (match_operand:HI 0 "general_operand" "=g")
3157         (subreg:HI (match_dup 5) 0))]
3158   ""
3159   "
3161   int i;
3163   for (i = 3; i < 6; i++)
3164     operands[i] = gen_reg_rtx (SImode);
3167 (define_insn "*expanded_lshrhi"
3168   [(set (match_operand:HI 0 "register_operand" "=r")
3169         (lshiftrt:HI (match_operand:HI 1 "register_operand" "0")
3170                      (match_operand:HI 2 "register_operand" "r")))]
3171   ""
3172   "lsr.w %2,%0"
3173   [(set_attr "slottable" "yes")])
3175 ;; A strict_low_part matcher.
3177 (define_insn "*lshrhi_lowpart"
3178   [(set (strict_low_part (match_operand:HI 0 "register_operand" "+r"))
3179         (lshiftrt:HI (match_dup 0)
3180                      (match_operand:HI 1 "register_operand" "r")))]
3181   ""
3182   "lsr.w %1,%0"
3183   [(set_attr "slottable" "yes")])
3185 ;; Same comments as for ashrhi3.
3187 (define_expand "lshrqi3"
3188   [(set (match_dup 3)
3189         (zero_extend:SI (match_operand:QI 1 "nonimmediate_operand" "g")))
3190    (set (match_dup 4)
3191         (zero_extend:SI (match_operand:QI 2 "nonimmediate_operand" "g")))
3192    (set (match_dup 5) (lshiftrt:SI (match_dup 3) (match_dup 4)))
3193    (set (match_operand:QI 0 "general_operand" "=g")
3194         (subreg:QI (match_dup 5) 0))]
3195   ""
3196   "
3198   int i;
3200   for (i = 3; i < 6; i++)
3201     operands[i] = gen_reg_rtx (SImode);
3204 (define_insn "*expanded_lshrqi"
3205   [(set (match_operand:QI 0 "register_operand" "=r")
3206         (lshiftrt:QI (match_operand:QI 1 "register_operand" "0")
3207                      (match_operand:QI 2 "register_operand" "r")))]
3208   ""
3209   "lsr.b %2,%0"
3210   [(set_attr "slottable" "yes")])
3212 ;; A strict_low_part matcher.
3214 (define_insn "*lshrqi_lowpart"
3215   [(set (strict_low_part (match_operand:QI 0 "register_operand" "+r"))
3216         (lshiftrt:QI (match_dup 0)
3217                      (match_operand:QI 1 "register_operand" "r")))]
3218   ""
3219   "lsr.b %1,%0"
3220   [(set_attr "slottable" "yes")])
3222 ;; Arithmetic/logical shift left.
3224 (define_insn "ashlsi3"
3225   [(set (match_operand:SI 0 "register_operand" "=r")
3226         (ashift:SI (match_operand:SI 1 "register_operand" "0")
3227                    (match_operand:SI 2 "nonmemory_operand" "Kr")))]
3228   ""
3229   "*
3231   if (REG_S_P (operands[2]))
3232     return \"lsl.d %2,%0\";
3234   return \"lslq %2,%0\";
3236   [(set_attr "slottable" "yes")])
3238 ;; For narrower modes than SI, we can use lslq although it makes cc
3239 ;; unusable.  The win is that we do not have to reload the shift-count
3240 ;; into a register.
3242 (define_insn "ashlhi3"
3243   [(set (match_operand:HI 0 "register_operand" "=r,r")
3244         (ashift:HI (match_operand:HI 1 "register_operand" "0,0")
3245                    (match_operand:HI 2 "nonmemory_operand" "r,K")))]
3246   ""
3247   "*
3249   return
3250     (GET_CODE (operands[2]) == CONST_INT && INTVAL (operands[2]) > 15)
3251     ? \"moveq 0,%0\"
3252     : (CONSTANT_P (operands[2])
3253        ? \"lslq %2,%0\" : \"lsl.w %2,%0\");
3255   [(set_attr "slottable" "yes")
3256    (set_attr "cc" "normal,clobber")])
3258 ;; A strict_low_part matcher.
3260 (define_insn "*ashlhi_lowpart"
3261   [(set (strict_low_part (match_operand:HI 0 "register_operand" "+r"))
3262         (ashift:HI (match_dup 0)
3263                    (match_operand:HI 1 "register_operand" "r")))]
3264   ""
3265   "lsl.w %1,%0"
3266   [(set_attr "slottable" "yes")])
3268 (define_insn "ashlqi3"
3269   [(set (match_operand:QI 0 "register_operand" "=r,r")
3270         (ashift:QI (match_operand:QI 1 "register_operand" "0,0")
3271                    (match_operand:QI 2 "nonmemory_operand" "r,K")))]
3272   ""
3273   "*
3275   return
3276     (GET_CODE (operands[2]) == CONST_INT
3277      && INTVAL (operands[2]) > 7)
3278     ? \"moveq 0,%0\"
3279     : (CONSTANT_P (operands[2])
3280        ? \"lslq %2,%0\" : \"lsl.b %2,%0\");
3282   [(set_attr "slottable" "yes")
3283    (set_attr "cc" "normal,clobber")])
3285 ;; A strict_low_part matcher.
3287 (define_insn "*ashlqi_lowpart"
3288   [(set (strict_low_part (match_operand:QI 0 "register_operand" "+r"))
3289         (ashift:QI (match_dup 0)
3290                    (match_operand:QI 1 "register_operand" "r")))]
3291   ""
3292   "lsl.b %1,%0"
3293   [(set_attr "slottable" "yes")])
3295 ;; Various strange insns that gcc likes.
3297 ;; Fortunately, it is simple to construct an abssf (although it may not
3298 ;; be very much used in practice).
3300 (define_insn "abssf2"
3301   [(set (match_operand:SF 0 "register_operand" "=r")
3302         (abs:SF (match_operand:SF 1 "register_operand" "0")))]
3303   ""
3304   "lslq 1,%0\;lsrq 1,%0")
3306 (define_insn "abssi2"
3307   [(set (match_operand:SI 0 "register_operand" "=r")
3308         (abs:SI (match_operand:SI 1 "register_operand" "r")))]
3309   ""
3310   "abs %1,%0"
3311   [(set_attr "slottable" "yes")])
3313 ;; FIXME: GCC should be able to do these expansions itself.
3315 (define_expand "abshi2"
3316   [(set (match_dup 2)
3317         (sign_extend:SI (match_operand:HI 1 "general_operand" "g")))
3318    (set (match_dup 3) (abs:SI (match_dup 2)))
3319    (set (match_operand:HI 0 "register_operand" "=r")
3320         (subreg:HI (match_dup 3) 0))]
3321   ""
3322   "operands[2] = gen_reg_rtx (SImode); operands[3] = gen_reg_rtx (SImode);")
3324 (define_expand "absqi2"
3325   [(set (match_dup 2)
3326         (sign_extend:SI (match_operand:QI 1 "general_operand" "g")))
3327    (set (match_dup 3) (abs:SI (match_dup 2)))
3328    (set (match_operand:QI 0 "register_operand" "=r")
3329         (subreg:QI (match_dup 3) 0))]
3330   ""
3331   "operands[2] = gen_reg_rtx (SImode); operands[3] = gen_reg_rtx (SImode);")
3333 ;; Bound-insn.  Defined to be the same as an unsigned minimum, which is an
3334 ;; operation supported by gcc.  Used in casesi, but used now and then in
3335 ;; normal code too.
3337 (define_insn "uminsi3"
3338   [(set (match_operand:SI 0 "register_operand" "=r,r,r,r")
3339         (umin:SI  (match_operand:SI 1 "register_operand" "%0,0,0,r")
3340                   (match_operand:SI 2 "general_operand" "r,Q>,g,!STo")))]
3341   ""
3342   "*
3344   if (GET_CODE (operands[2]) == CONST_INT)
3345     {
3346       if (INTVAL (operands[2]) < 256)
3347         return \"bound.b %2,%0\";
3349       if (INTVAL (operands[2]) < 65536)
3350         return \"bound.w %2,%0\";
3351     }
3352   else if (which_alternative == 3)
3353     return \"bound.d %2,%1,%0\";
3355   return \"bound.d %2,%0\";
3357  [(set_attr "slottable" "yes,yes,no,no")])
3359 ;; Jump and branch insns.
3361 (define_insn "jump"
3362   [(set (pc)
3363         (label_ref (match_operand 0 "" "")))]
3364   ""
3365   "ba %l0%#"
3366   [(set_attr "slottable" "has_slot")])
3368 ;; Testcase gcc.c-torture/compile/991213-3.c fails if we allow a constant
3369 ;; here, since the insn is not recognized as an indirect jump by
3370 ;; jmp_uses_reg_or_mem used by computed_jump_p.  Perhaps it is a kludge to
3371 ;; change from general_operand to nonimmediate_operand (at least the docs
3372 ;; should be changed), but then again the pattern is called indirect_jump.
3373 (define_insn "indirect_jump"
3374   [(set (pc) (match_operand:SI 0 "nonimmediate_operand" "rm"))]
3375   ""
3376   "jump %0")
3378 ;; Return insn.  Used whenever the epilogue is very simple; if it is only
3379 ;; a single ret or jump [sp+] or a contiguous sequence of movem:able saved
3380 ;; registers.  No allocated stack space is allowed.
3381 ;; Note that for this pattern, although named, it is ok to check the
3382 ;; context of the insn in the test, not only compiler switches.
3384 (define_insn "return"
3385   [(return)]
3386   "cris_simple_epilogue ()"
3387   "*
3389   int i;
3391   /* Just needs to hold a 'movem [sp+],rN'.  */
3392   char rd[sizeof (\"movem [$sp+],$r99\")];
3394   /* Try to avoid reorg.c surprises; avoid emitting invalid code, prefer
3395      crashing.  This test would have avoided invalid code for target/7042.  */
3396   if (current_function_epilogue_delay_list != NULL)
3397     abort ();
3399   *rd = 0;
3401   /* Start from the last call-saved register.  We know that we have a
3402      simple epilogue, so we just have to find the last register in the
3403      movem sequence.  */
3404   for (i = 8; i >= 0; i--)
3405     if (regs_ever_live[i]
3406         || (i == PIC_OFFSET_TABLE_REGNUM
3407             && current_function_uses_pic_offset_table))
3408       break;
3410   if (i >= 0)
3411     sprintf (rd, \"movem [$sp+],$%s\", reg_names [i]);
3413   if (regs_ever_live[CRIS_SRP_REGNUM])
3414     {
3415       if (*rd)
3416         output_asm_insn (rd, operands);
3417       return \"jump [$sp+]\";
3418     }
3420   if (*rd)
3421     {
3422       output_asm_insn (\"reT\", operands);
3423       output_asm_insn (rd, operands);
3424       return \"\";
3425     }
3427   return \"ret%#\";
3429   [(set (attr "slottable")
3430         (if_then_else
3431          (ne (symbol_ref "regs_ever_live[CRIS_SRP_REGNUM]") (const_int 0))
3432          (const_string "no")         ; If jump then not slottable.
3433          (if_then_else
3434           (ne (symbol_ref
3435                "(regs_ever_live[0]
3436                  || (flag_pic != 0 && regs_ever_live[1])
3437                  || (PIC_OFFSET_TABLE_REGNUM == 0
3438                      && cris_cfun_uses_pic_table ()))")
3439               (const_int 0))
3440           (const_string "no") ; ret+movem [sp+],rx: slot already filled.
3441           (const_string "has_slot")))) ; If ret then need to fill a slot.
3442    (set_attr "cc" "none")])
3444 ;; Conditional branches.
3446 ;; We suffer from the same overflow-bit-gets-in-the-way problem as
3447 ;; e.g. m68k, so we have to check if overflow bit is set on all "signed"
3448 ;; conditions.
3450 (define_insn "beq"
3451   [(set (pc)
3452         (if_then_else (eq (cc0)
3453                           (const_int 0))
3454                       (label_ref (match_operand 0 "" ""))
3455                       (pc)))]
3456   ""
3457   "beq %l0%#"
3458   [(set_attr "slottable" "has_slot")])
3460 (define_insn "bne"
3461   [(set (pc)
3462         (if_then_else (ne (cc0)
3463                           (const_int 0))
3464                       (label_ref (match_operand 0 "" ""))
3465                       (pc)))]
3466   ""
3467   "bne %l0%#"
3468   [(set_attr "slottable" "has_slot")])
3470 (define_insn "bgt"
3471   [(set (pc)
3472         (if_then_else (gt (cc0)
3473                           (const_int 0))
3474                       (label_ref (match_operand 0 "" ""))
3475                       (pc)))]
3476   ""
3477   "*
3479   return
3480     (cc_prev_status.flags & CC_NO_OVERFLOW)
3481     ? 0 : \"bgt %l0%#\";
3483   [(set_attr "slottable" "has_slot")])
3485 (define_insn "bgtu"
3486   [(set (pc)
3487         (if_then_else (gtu (cc0)
3488                            (const_int 0))
3489                       (label_ref (match_operand 0 "" ""))
3490                       (pc)))]
3491   ""
3492   "bhi %l0%#"
3493   [(set_attr "slottable" "has_slot")])
3495 (define_insn "blt"
3496   [(set (pc)
3497         (if_then_else (lt (cc0)
3498                           (const_int 0))
3499                       (label_ref (match_operand 0 "" ""))
3500                       (pc)))]
3501   ""
3502   "*
3504   return
3505     (cc_prev_status.flags & CC_NO_OVERFLOW)
3506     ? \"bmi %l0%#\" : \"blt %l0%#\";
3508   [(set_attr "slottable" "has_slot")])
3510 (define_insn "bltu"
3511   [(set (pc)
3512         (if_then_else (ltu (cc0)
3513                            (const_int 0))
3514                       (label_ref (match_operand 0 "" ""))
3515                       (pc)))]
3516   ""
3517   "blo %l0%#"
3518   [(set_attr "slottable" "has_slot")])
3520 (define_insn "bge"
3521   [(set (pc)
3522         (if_then_else (ge (cc0)
3523                           (const_int 0))
3524                       (label_ref (match_operand 0 "" ""))
3525                       (pc)))]
3526   ""
3527   "*
3529   return
3530     (cc_prev_status.flags & CC_NO_OVERFLOW)
3531     ? \"bpl %l0%#\" : \"bge %l0%#\";
3533   [(set_attr "slottable" "has_slot")])
3535 (define_insn "bgeu"
3536   [(set (pc)
3537         (if_then_else (geu (cc0)
3538                            (const_int 0))
3539                       (label_ref (match_operand 0 "" ""))
3540                       (pc)))]
3541   ""
3542   "bhs %l0%#"
3543   [(set_attr "slottable" "has_slot")])
3545 (define_insn "ble"
3546   [(set (pc)
3547         (if_then_else (le (cc0)
3548                           (const_int 0))
3549                       (label_ref (match_operand 0 "" ""))
3550                       (pc)))]
3551   ""
3552   "*
3554   return
3555     (cc_prev_status.flags & CC_NO_OVERFLOW)
3556     ? 0 : \"ble %l0%#\";
3558   [(set_attr "slottable" "has_slot")])
3560 (define_insn "bleu"
3561   [(set (pc)
3562         (if_then_else (leu (cc0)
3563                            (const_int 0))
3564                       (label_ref (match_operand 0 "" ""))
3565                       (pc)))]
3566   ""
3567   "bls %l0%#"
3568   [(set_attr "slottable" "has_slot")])
3570 ;; Reversed anonymous patterns to the ones above, as mandated.
3572 (define_insn "*beq_reversed"
3573   [(set (pc)
3574         (if_then_else (eq (cc0)
3575                           (const_int 0))
3576                       (pc)
3577                       (label_ref (match_operand 0 "" ""))))]
3578   ""
3579   "bne %l0%#"
3580   [(set_attr "slottable" "has_slot")])
3582 (define_insn "*bne_reversed"
3583   [(set (pc)
3584         (if_then_else (ne (cc0)
3585                           (const_int 0))
3586                       (pc)
3587                       (label_ref (match_operand 0 "" ""))))]
3588   ""
3589   "beq %l0%#"
3590   [(set_attr "slottable" "has_slot")])
3592 (define_insn "*bgt_reversed"
3593   [(set (pc)
3594         (if_then_else (gt (cc0)
3595                           (const_int 0))
3596                       (pc)
3597                       (label_ref (match_operand 0 "" ""))))]
3598   ""
3599   "*
3601   return
3602     (cc_prev_status.flags & CC_NO_OVERFLOW)
3603     ? 0 : \"ble %l0%#\";
3605   [(set_attr "slottable" "has_slot")])
3607 (define_insn "*bgtu_reversed"
3608   [(set (pc)
3609         (if_then_else (gtu (cc0)
3610                            (const_int 0))
3611                       (pc)
3612                       (label_ref (match_operand 0 "" ""))))]
3613   ""
3614   "bls %l0%#"
3615   [(set_attr "slottable" "has_slot")])
3617 (define_insn "*blt_reversed"
3618   [(set (pc)
3619         (if_then_else (lt (cc0)
3620                           (const_int 0))
3621                       (pc)
3622                       (label_ref (match_operand 0 "" ""))))]
3623   ""
3624   "*
3626   return
3627     (cc_prev_status.flags & CC_NO_OVERFLOW)
3628     ? \"bpl %l0%#\" : \"bge %l0%#\";
3630   [(set_attr "slottable" "has_slot")])
3632 (define_insn "*bltu_reversed"
3633   [(set (pc)
3634         (if_then_else (ltu (cc0)
3635                            (const_int 0))
3636                       (pc)
3637                       (label_ref (match_operand 0 "" ""))))]
3638   ""
3639   "bhs %l0%#"
3640   [(set_attr "slottable" "has_slot")])
3642 (define_insn "*bge_reversed"
3643   [(set (pc)
3644         (if_then_else (ge (cc0)
3645                           (const_int 0))
3646                       (pc)
3647                       (label_ref (match_operand 0 "" ""))))]
3648   ""
3649   "*
3651   return
3652     (cc_prev_status.flags & CC_NO_OVERFLOW)
3653     ? \"bmi %l0%#\" : \"blt %l0%#\";
3655   [(set_attr "slottable" "has_slot")])
3657 (define_insn "*bgeu_reversed"
3658   [(set (pc)
3659         (if_then_else (geu (cc0)
3660                            (const_int 0))
3661                       (pc)
3662                       (label_ref (match_operand 0 "" ""))))]
3663   ""
3664   "blo %l0%#"
3665   [(set_attr "slottable" "has_slot")])
3667 (define_insn "*ble_reversed"
3668   [(set (pc)
3669         (if_then_else (le (cc0)
3670                           (const_int 0))
3671                       (pc)
3672                       (label_ref (match_operand 0 "" ""))))]
3673   ""
3674   "*
3676   return
3677     (cc_prev_status.flags & CC_NO_OVERFLOW)
3678     ? 0 : \"bgt %l0%#\";
3680   [(set_attr "slottable" "has_slot")])
3682 (define_insn "*bleu_reversed"
3683   [(set (pc)
3684         (if_then_else (leu (cc0)
3685                            (const_int 0))
3686                       (pc)
3687                       (label_ref (match_operand 0 "" ""))))]
3688   ""
3689   "bhi %l0%#"
3690   [(set_attr "slottable" "has_slot")])
3692 ;; Set on condition: sCC.
3694 ;; Like bCC, we have to check the overflow bit for
3695 ;; signed conditions.
3697 (define_insn "sgeu"
3698   [(set (match_operand:SI 0 "register_operand" "=r")
3699         (geu:SI (cc0) (const_int 0)))]
3700   ""
3701   "shs %0"
3702   [(set_attr "slottable" "yes")
3703    (set_attr "cc" "none")])
3705 (define_insn "sltu"
3706   [(set (match_operand:SI 0 "register_operand" "=r")
3707         (ltu:SI (cc0) (const_int 0)))]
3708   ""
3709   "slo %0"
3710   [(set_attr "slottable" "yes")
3711    (set_attr "cc" "none")])
3713 (define_insn "seq"
3714   [(set (match_operand:SI 0 "register_operand" "=r")
3715         (eq:SI (cc0) (const_int 0)))]
3716   ""
3717   "seq %0"
3718   [(set_attr "slottable" "yes")
3719    (set_attr "cc" "none")])
3721 (define_insn "sge"
3722   [(set (match_operand:SI 0 "register_operand" "=r")
3723         (ge:SI (cc0) (const_int 0)))]
3724   ""
3725   "*
3727   return
3728     (cc_prev_status.flags & CC_NO_OVERFLOW)
3729     ? \"spl %0\" : \"sge %0\";
3731   [(set_attr "slottable" "yes")
3732    (set_attr "cc" "none")])
3734 (define_insn "sgt"
3735   [(set (match_operand:SI 0 "register_operand" "=r")
3736         (gt:SI (cc0) (const_int 0)))]
3737   ""
3738   "*
3740   return
3741     (cc_prev_status.flags & CC_NO_OVERFLOW)
3742     ? 0 : \"sgt %0\";
3744   [(set_attr "slottable" "yes")
3745    (set_attr "cc" "none")])
3747 (define_insn "sgtu"
3748   [(set (match_operand:SI 0 "register_operand" "=r")
3749         (gtu:SI (cc0) (const_int 0)))]
3750   ""
3751   "shi %0"
3752   [(set_attr "slottable" "yes")
3753    (set_attr "cc" "none")])
3755 (define_insn "sle"
3756   [(set (match_operand:SI 0 "register_operand" "=r")
3757         (le:SI (cc0) (const_int 0)))]
3758   ""
3759   "*
3761   return
3762     (cc_prev_status.flags & CC_NO_OVERFLOW)
3763     ? 0 : \"sle %0\";
3765   [(set_attr "slottable" "yes")
3766    (set_attr "cc" "none")])
3768 (define_insn "sleu"
3769   [(set (match_operand:SI 0 "register_operand" "=r")
3770         (leu:SI (cc0) (const_int 0)))]
3771   ""
3772   "sls %0"
3773   [(set_attr "slottable" "yes")
3774    (set_attr "cc" "none")])
3776 (define_insn "slt"
3777   [(set (match_operand:SI 0 "register_operand" "=r")
3778         (lt:SI (cc0) (const_int 0)))]
3779   ""
3780   "*
3782   return
3783     (cc_prev_status.flags & CC_NO_OVERFLOW)
3784     ? \"smi %0\" : \"slt %0\";
3786   [(set_attr "slottable" "yes")
3787    (set_attr "cc" "none")])
3789 (define_insn "sne"
3790   [(set (match_operand:SI 0 "register_operand" "=r")
3791         (ne:SI (cc0) (const_int 0)))]
3792   ""
3793   "sne %0"
3794   [(set_attr "slottable" "yes")
3795    (set_attr "cc" "none")])
3797 ;; Call insns.
3799 ;; We need to make these patterns "expand", since the real operand is
3800 ;; hidden in a (mem:QI ) inside operand[0] (call_value: operand[1]),
3801 ;; and cannot be checked if it were a "normal" pattern.
3802 ;;  Note that "call" and "call_value" are *always* called with a
3803 ;; mem-operand for operand 0 and 1 respective.  What happens for combined
3804 ;; instructions is a different issue.
3806 (define_expand "call"
3807   [(parallel [(call (match_operand:QI 0 "cris_mem_call_operand" "")
3808                     (match_operand 1 "general_operand" ""))
3809               ;; 16 is the srp (can't use the symbolic name here)
3810               (clobber (reg:SI 16))])]
3811   ""
3812   "
3814   rtx op0;
3816   if (GET_CODE (operands[0]) != MEM)
3817     abort ();
3819   if (flag_pic)
3820     {
3821       op0 = XEXP (operands[0], 0);
3823       /* It might be that code can be generated that jumps to 0 (or to a
3824          specific address).  Don't abort on that.  At least there's a
3825          testcase.  */
3826       if (CONSTANT_ADDRESS_P (op0) && GET_CODE (op0) != CONST_INT)
3827         {
3828           if (no_new_pseudos)
3829             abort ();
3831           /* For local symbols (non-PLT), get the plain symbol reference
3832              into a register.  For symbols that can be PLT, make them PLT.  */
3833           if (cris_gotless_symbol (op0) || GET_CODE (op0) != SYMBOL_REF)
3834             op0 = force_reg (Pmode, op0);
3835           else if (cris_symbol (op0))
3836             /* FIXME: Would hanging a REG_EQUIV/EQUAL on that register
3837                for the symbol cause bad recombinatorial effects?  */
3838             op0 = force_reg (Pmode,
3839                              gen_rtx_CONST
3840                              (VOIDmode,
3841                               gen_rtx_UNSPEC (VOIDmode,
3842                                               gen_rtvec (1, op0), 0)));
3843           else
3844             abort ();
3846           operands[0] = replace_equiv_address (operands[0], op0);
3847         }
3848     }
3851 ;; Accept *anything* as operand 1.  Accept operands for operand 0 in
3852 ;; order of preference (Q includes r, but r is shorter, faster)
3854 (define_insn "*expanded_call"
3855   [(call (mem:QI (match_operand:SI
3856                   0 "cris_general_operand_or_plt_symbol" "r,Q>,g,S"))
3857          (match_operand 1 "" ""))
3858    (clobber (reg:SI 16))] ;; 16 is the srp (can't use symbolic name)
3859   "! TARGET_AVOID_GOTPLT"
3860   "jsr %0")
3862 ;; Same as above, since can't afford wasting a constraint letter to mean
3863 ;; "S unless TARGET_AVOID_GOTPLT".
3864 (define_insn "*expanded_call_no_gotplt"
3865   [(call (mem:QI (match_operand:SI
3866                   0 "cris_general_operand_or_plt_symbol" "r,Q>,g"))
3867          (match_operand 1 "" ""))
3868    (clobber (reg:SI 16))] ;; 16 is the srp (can't use symbolic name)
3869   "TARGET_AVOID_GOTPLT"
3870   "jsr %0")
3872 (define_expand "call_value"
3873   [(parallel [(set (match_operand 0 "" "")
3874                    (call (match_operand:QI 1 "cris_mem_call_operand" "")
3875                          (match_operand 2 "" "")))
3876               ;; 16 is the srp (can't use symbolic name)
3877               (clobber (reg:SI 16))])]
3878   ""
3879   "
3881   rtx op1;
3883   if (GET_CODE (operands[1]) != MEM)
3884     abort ();
3886   if (flag_pic)
3887     {
3888       op1 = XEXP (operands[1], 0);
3890       /* It might be that code can be generated that jumps to 0 (or to a
3891          specific address).  Don't abort on that.  At least there's a
3892          testcase.  */
3893       if (CONSTANT_ADDRESS_P (op1) && GET_CODE (op1) != CONST_INT)
3894         {
3895           if (no_new_pseudos)
3896             abort ();
3898           if (cris_gotless_symbol (op1))
3899             op1 = force_reg (Pmode, op1);
3900           else if (cris_symbol (op1))
3901             /* FIXME: Would hanging a REG_EQUIV/EQUAL on that register
3902                for the symbol cause bad recombinatorial effects?  */
3903             op1 = force_reg (Pmode,
3904                              gen_rtx_CONST
3905                              (VOIDmode,
3906                               gen_rtx_UNSPEC (VOIDmode,
3907                                               gen_rtvec (1, op1), 0)));
3908           else
3909             abort ();
3911           operands[1] = replace_equiv_address (operands[1], op1);
3912         }
3913     }
3916 ;; Accept *anything* as operand 2.  The validity other than "general" of
3917 ;; operand 0 will be checked elsewhere.  Accept operands for operand 1 in
3918 ;; order of preference (Q includes r, but r is shorter, faster).
3919 ;;  We also accept a PLT symbol.  We output it as [rPIC+sym:GOTPLT] rather
3920 ;; than requiring getting rPIC + sym:PLT into a register.
3922 (define_insn "*expanded_call_value"
3923   [(set (match_operand 0 "nonimmediate_operand" "=g,g,g,g")
3924         (call (mem:QI (match_operand:SI
3925                        1 "cris_general_operand_or_plt_symbol" "r,Q>,g,S"))
3926               (match_operand 2 "" "")))
3927    (clobber (reg:SI 16))]
3928   "! TARGET_AVOID_GOTPLT"
3929   "Jsr %1"
3930   [(set_attr "cc" "clobber")])
3932 ;; Same as above, since can't afford wasting a constraint letter to mean
3933 ;; "S unless TARGET_AVOID_GOTPLT".
3934 (define_insn "*expanded_call_value_no_gotplt"
3935   [(set (match_operand 0 "nonimmediate_operand" "=g,g,g")
3936         (call (mem:QI (match_operand:SI
3937                        1 "cris_general_operand_or_plt_symbol" "r,Q>,g"))
3938               (match_operand 2 "" "")))
3939    (clobber (reg:SI 16))]
3940   "TARGET_AVOID_GOTPLT"
3941   "Jsr %1"
3942   [(set_attr "cc" "clobber")])
3944 ;; Used in debugging.  No use for the direct pattern; unfilled
3945 ;; delayed-branches are taken care of by other means.
3947 (define_insn "nop"
3948   [(const_int 0)]
3949   ""
3950   "nop"
3951   [(set_attr "cc" "none")])
3953 ;; We expand on casesi so we can use "bound" and "add offset fetched from
3954 ;; a table to pc" (adds.w [pc+%0.w],pc).
3956 ;; Note: if you change the "parallel" (or add anything after it) in
3957 ;; this expansion, you must change the macro ASM_OUTPUT_CASE_END
3958 ;; accordingly, to add the default case at the end of the jump-table.
3960 (define_expand "casesi"
3961   [(set (match_dup 5) (match_operand:SI 0 "general_operand" ""))
3962    (set (match_dup 6)
3963         (minus:SI (match_dup 5)
3964                   (match_operand:SI 1 "const_int_operand" "n")))
3965    (set (match_dup 7)
3966         (umin:SI (match_dup 6)
3967                  (match_operand:SI 2 "const_int_operand" "n")))
3968    (parallel
3969     [(set (pc)
3970           (if_then_else
3971            (ltu (match_dup 7) (match_dup 2))
3972            (plus:SI (sign_extend:SI
3973                      (mem:HI
3974                       (plus:SI (mult:SI (match_dup 7) (const_int 2))
3975                                (pc))))
3976                     (pc))
3977            (label_ref (match_operand 4 "" ""))))
3978      (use (label_ref (match_operand 3 "" "")))])]
3979   ""
3980   "
3982   operands[2] = plus_constant (operands[2], 1);
3983   operands[5] = gen_reg_rtx (SImode);
3984   operands[6] = gen_reg_rtx (SImode);
3985   operands[7] = gen_reg_rtx (SImode);
3988 ;; Split-patterns.  Some of them have modes unspecified.  This
3989 ;; should always be ok; if for no other reason sparc.md has it as
3990 ;; well.
3992 ;; When register_operand is specified for an operand, we can get a
3993 ;; subreg as well (Axis-990331), so don't just assume that REG_P is true
3994 ;; for a register_operand and that REGNO can be used as is.  It is best to
3995 ;; guard with REG_P, unless it is worth it to adjust for the subreg case.
3997 ;; op [rx + 0],ry,rz
3998 ;; The index to rx is optimized into zero, and gone.
4000 ;; First, recognize bound [rx],ry,rz; where [rx] is zero-extended,
4001 ;; and add/sub [rx],ry,rz, with zero or sign-extend on [rx].
4002 ;; Split this into:
4003 ;;  move ry,rz
4004 ;;  op [rx],rz
4005 ;; Lose if rz=ry or rx=rz.
4006 ;; Call this op-extend-split
4008 (define_split
4009   [(set (match_operand 0 "register_operand" "")
4010         (match_operator
4011          4 "cris_operand_extend_operator"
4012          [(match_operand 1 "register_operand" "")
4013           (match_operator
4014            3 "cris_extend_operator"
4015            [(match_operand 2 "memory_operand" "")])]))]
4016   "REG_P (operands[0])
4017    && REG_P (operands[1])
4018    && REGNO (operands[1]) != REGNO (operands[0])
4019    && GET_MODE_SIZE (GET_MODE (operands[0])) <= UNITS_PER_WORD
4020    && REG_P (XEXP (operands[2], 0))
4021    && REGNO (XEXP (operands[2], 0)) != REGNO (operands[0])"
4022   [(set (match_dup 0)
4023         (match_dup 1))
4024    (set (match_dup 0)
4025         (match_op_dup
4026          4 [(match_dup 0)
4027             (match_op_dup 3 [(match_dup 2)])]))]
4028   "")
4030 ;; As op-extend-split, but recognize and split op [rz],ry,rz into
4031 ;;  ext [rz],rz
4032 ;;  op ry,rz
4033 ;; Do this for plus or bound only, being commutative operations, since we
4034 ;; have swapped the operands.
4035 ;; Call this op-extend-split-rx=rz
4037 (define_split
4038   [(set (match_operand 0 "register_operand" "")
4039         (match_operator
4040          4 "cris_plus_or_bound_operator"
4041          [(match_operand 1 "register_operand" "")
4042           (match_operator
4043            3 "cris_extend_operator"
4044            [(match_operand 2 "memory_operand" "")])]))]
4045   "REG_P (operands[0])
4046    && REG_P (operands[1])
4047    && REGNO (operands[1]) != REGNO (operands[0])
4048    && GET_MODE_SIZE (GET_MODE (operands[0])) <= UNITS_PER_WORD
4049    && REG_P (XEXP (operands[2], 0))
4050    && REGNO (XEXP (operands[2], 0)) == REGNO (operands[0])"
4051   [(set (match_dup 0)
4052         (match_op_dup 3 [(match_dup 2)]))
4053    (set (match_dup 0)
4054         (match_op_dup
4055          4 [(match_dup 0)
4056             (match_dup 1)]))]
4057   "")
4059 ;; As the op-extend-split, but swapped operands, and only for
4060 ;; plus or bound, being the commutative extend-operators.  FIXME: Why is
4061 ;; this needed?  Is it?
4062 ;; Call this op-extend-split-swapped
4064 (define_split
4065   [(set (match_operand 0 "register_operand" "")
4066         (match_operator
4067          4 "cris_plus_or_bound_operator"
4068          [(match_operator
4069            3 "cris_extend_operator"
4070            [(match_operand 2 "memory_operand" "")])
4071           (match_operand 1 "register_operand" "")]))]
4072   "REG_P (operands[0])
4073    && REG_P (operands[1])
4074    && REGNO (operands[1]) != REGNO (operands[0])
4075    && GET_MODE_SIZE (GET_MODE (operands[0])) <= UNITS_PER_WORD
4076    && REG_P (XEXP (operands[2], 0))
4077    && REGNO (XEXP (operands[2], 0)) != REGNO (operands[0])"
4078   [(set (match_dup 0)
4079         (match_dup 1))
4080    (set (match_dup 0)
4081         (match_op_dup
4082          4 [(match_dup 0)
4083             (match_op_dup 3 [(match_dup 2)])]))]
4084   "")
4086 ;; As op-extend-split-rx=rz, but swapped operands, only for plus or
4087 ;; bound.  Call this op-extend-split-swapped-rx=rz.
4089 (define_split
4090   [(set (match_operand 0 "register_operand" "")
4091         (match_operator
4092          4 "cris_plus_or_bound_operator"
4093          [(match_operator
4094            3 "cris_extend_operator"
4095            [(match_operand 2 "memory_operand" "")])
4096           (match_operand 1 "register_operand" "")]))]
4097   "REG_P (operands[0])
4098    && REG_P (operands[1])
4099    && REGNO (operands[1]) != REGNO (operands[0])
4100    && GET_MODE_SIZE (GET_MODE (operands[0])) <= UNITS_PER_WORD
4101    && REG_P (XEXP (operands[2], 0))
4102    && REGNO (XEXP (operands[2], 0)) == REGNO (operands[0])"
4103   [(set (match_dup 0)
4104         (match_op_dup 3 [(match_dup 2)]))
4105    (set (match_dup 0)
4106         (match_op_dup
4107          4 [(match_dup 0)
4108             (match_dup 1)]))]
4109   "")
4111 ;; As op-extend-split, but the mem operand is not extended.
4113 ;; op [rx],ry,rz changed into
4114 ;;  move ry,rz
4115 ;;  op [rx],rz
4116 ;; lose if ry=rz or rx=rz
4117 ;; Call this op-extend.
4119 (define_split
4120   [(set (match_operand 0 "register_operand" "")
4121         (match_operator
4122          3 "cris_orthogonal_operator"
4123          [(match_operand 1 "register_operand" "")
4124           (match_operand 2 "memory_operand" "")]))]
4125   "REG_P (operands[0])
4126    && REG_P (operands[1])
4127    && REGNO (operands[1]) != REGNO (operands[0])
4128    && GET_MODE_SIZE (GET_MODE (operands[0])) <= UNITS_PER_WORD
4129    && REG_P (XEXP (operands[2], 0))
4130    && REGNO (XEXP (operands[2], 0)) != REGNO (operands[0])"
4131   [(set (match_dup 0)
4132         (match_dup 1))
4133    (set (match_dup 0)
4134         (match_op_dup
4135          3 [(match_dup 0)
4136             (match_dup 2)]))]
4137   "")
4139 ;; As op-extend-split-rx=rz, non-extended.
4140 ;; Call this op-split-rx=rz
4142 (define_split
4143   [(set (match_operand 0 "register_operand" "")
4144         (match_operator
4145          3 "cris_commutative_orth_op"
4146          [(match_operand 2 "memory_operand" "")
4147           (match_operand 1 "register_operand" "")]))]
4148   "REG_P (operands[0])
4149    && REG_P (operands[1])
4150    && REGNO (operands[1]) != REGNO (operands[0])
4151    && GET_MODE_SIZE (GET_MODE (operands[0])) <= UNITS_PER_WORD
4152    && REG_P (XEXP (operands[2], 0))
4153    && REGNO (XEXP (operands[2], 0)) != REGNO (operands[0])"
4154   [(set (match_dup 0)
4155         (match_dup 1))
4156    (set (match_dup 0)
4157         (match_op_dup
4158          3 [(match_dup 0)
4159             (match_dup 2)]))]
4160   "")
4162 ;; As op-extend-split-swapped, nonextended.
4163 ;; Call this op-split-swapped.
4165 (define_split
4166   [(set (match_operand 0 "register_operand" "")
4167         (match_operator
4168          3 "cris_commutative_orth_op"
4169          [(match_operand 1 "register_operand" "")
4170           (match_operand 2 "memory_operand" "")]))]
4171   "REG_P (operands[0]) && REG_P (operands[1])
4172    && REGNO (operands[1]) != REGNO (operands[0])
4173    && GET_MODE_SIZE (GET_MODE (operands[0])) <= UNITS_PER_WORD
4174    && REG_P (XEXP (operands[2], 0))
4175    && REGNO (XEXP (operands[2], 0)) == REGNO (operands[0])"
4176   [(set (match_dup 0)
4177         (match_dup 2))
4178    (set (match_dup 0)
4179         (match_op_dup
4180          3 [(match_dup 0)
4181             (match_dup 1)]))]
4182   "")
4184 ;; As op-extend-split-swapped-rx=rz, non-extended.
4185 ;; Call this op-split-swapped-rx=rz.
4187 (define_split
4188   [(set (match_operand 0 "register_operand" "")
4189         (match_operator
4190          3 "cris_orthogonal_operator"
4191          [(match_operand 2 "memory_operand" "")
4192           (match_operand 1 "register_operand" "")]))]
4193   "REG_P (operands[0]) && REG_P (operands[1])
4194    && REGNO (operands[1]) != REGNO (operands[0])
4195    && GET_MODE_SIZE (GET_MODE (operands[0])) <= UNITS_PER_WORD
4196    && REG_P (XEXP (operands[2], 0))
4197    && REGNO (XEXP (operands[2], 0)) == REGNO (operands[0])"
4198   [(set (match_dup 0)
4199         (match_dup 2))
4200    (set (match_dup 0)
4201         (match_op_dup
4202          3 [(match_dup 0)
4203             (match_dup 1)]))]
4204   "")
4206 ;; Splits for all cases in side-effect insns where (possibly after reload
4207 ;; and register allocation) rx and ry in [rx=ry+i] are equal.
4209 ;; move.S1 [rx=rx+rz.S2],ry
4211 (define_split
4212   [(parallel
4213     [(set (match_operand 0 "register_operand" "")
4214           (match_operator
4215            6 "cris_mem_op"
4216            [(plus:SI
4217              (mult:SI (match_operand:SI 1 "register_operand" "")
4218                       (match_operand:SI 2 "const_int_operand" ""))
4219              (match_operand:SI 3 "register_operand" ""))]))
4220      (set (match_operand:SI 4 "register_operand" "")
4221            (plus:SI (mult:SI (match_dup 1)
4222                              (match_dup 2))
4223                     (match_dup 3)))])]
4224   "REG_P (operands[3]) && REG_P (operands[4])
4225    && REGNO (operands[3]) == REGNO (operands[4])"
4226   [(set (match_dup 4) (plus:SI (mult:SI (match_dup 1) (match_dup 2))
4227                                 (match_dup 3)))
4228    (set (match_dup 0) (match_dup 5))]
4229   "operands[5] = replace_equiv_address (operands[6], operands[3]);")
4231 ;; move.S1 [rx=rx+i],ry
4233 (define_split
4234   [(parallel
4235     [(set (match_operand 0 "register_operand" "")
4236           (match_operator
4237            5 "cris_mem_op"
4238            [(plus:SI (match_operand:SI 1 "cris_bdap_operand" "")
4239                      (match_operand:SI 2 "cris_bdap_operand" ""))]))
4240      (set (match_operand:SI 3 "register_operand" "")
4241            (plus:SI (match_dup 1)
4242                     (match_dup 2)))])]
4243   "(rtx_equal_p (operands[3], operands[1])
4244     || rtx_equal_p (operands[3], operands[2]))"
4245   [(set (match_dup 3) (plus:SI (match_dup 1) (match_dup 2)))
4246    (set (match_dup 0) (match_dup 4))]
4247   "operands[4] = replace_equiv_address (operands[5], operands[3]);")
4249 ;; move.S1 ry,[rx=rx+rz.S2]
4251 (define_split
4252   [(parallel
4253     [(set (match_operator
4254            6 "cris_mem_op"
4255            [(plus:SI
4256              (mult:SI (match_operand:SI 0 "register_operand" "")
4257                       (match_operand:SI 1 "const_int_operand" ""))
4258              (match_operand:SI 2 "register_operand" ""))])
4259           (match_operand 3 "register_operand" ""))
4260      (set (match_operand:SI 4 "register_operand" "")
4261            (plus:SI (mult:SI (match_dup 0)
4262                              (match_dup 1))
4263                     (match_dup 2)))])]
4264   "REG_P (operands[2]) && REG_P (operands[4])
4265    && REGNO (operands[4]) == REGNO (operands[2])"
4266   [(set (match_dup 4) (plus:SI (mult:SI (match_dup 0) (match_dup 1))
4267                                 (match_dup 2)))
4268    (set (match_dup 5) (match_dup 3))]
4269   "operands[5] = replace_equiv_address (operands[6], operands[4]);")
4271 ;; move.S1 ry,[rx=rx+i]
4273 (define_split
4274   [(parallel
4275     [(set (match_operator
4276            6 "cris_mem_op"
4277            [(plus:SI (match_operand:SI 0 "cris_bdap_operand" "")
4278                      (match_operand:SI 1 "cris_bdap_operand" ""))])
4279           (match_operand 2 "register_operand" ""))
4280      (set (match_operand:SI 3 "register_operand" "")
4281            (plus:SI (match_dup 0)
4282                    (match_dup 1)))])]
4283   "(rtx_equal_p (operands[3], operands[0])
4284     || rtx_equal_p (operands[3], operands[1]))"
4285   [(set (match_dup 3) (plus:SI (match_dup 0) (match_dup 1)))
4286    (set (match_dup 5) (match_dup 2))]
4287   "operands[5] = replace_equiv_address (operands[6], operands[3]);")
4289 ;; clear.d [rx=rx+rz.S2]
4291 (define_split
4292   [(parallel
4293     [(set (mem:SI (plus:SI
4294                     (mult:SI (match_operand:SI 0 "register_operand" "")
4295                              (match_operand:SI 1 "const_int_operand" ""))
4296                     (match_operand:SI 2 "register_operand" "")))
4297            (const_int 0))
4298      (set (match_operand:SI 3 "register_operand" "")
4299            (plus:SI (mult:SI (match_dup 0)
4300                              (match_dup 1))
4301                     (match_dup 2)))])]
4302   "REG_P (operands[2]) && REG_P (operands[3])
4303    && REGNO (operands[3]) == REGNO (operands[2])"
4304   [(set (match_dup 3) (plus:SI (mult:SI (match_dup 0) (match_dup 1))
4305                                 (match_dup 2)))
4306    (set (mem:SI (match_dup 3)) (const_int 0))]
4307   "")
4309 ;; clear.w [rx=rx+rz.S2]
4311 (define_split
4312   [(parallel
4313     [(set (mem:HI (plus:SI
4314                     (mult:SI (match_operand:SI 0 "register_operand" "")
4315                              (match_operand:SI 1 "const_int_operand" ""))
4316                     (match_operand:SI 2 "register_operand" "")))
4317            (const_int 0))
4318      (set (match_operand:SI 3 "register_operand" "")
4319            (plus:SI (mult:SI (match_dup 0)
4320                              (match_dup 1))
4321                     (match_dup 2)))])]
4322   "REG_P (operands[2]) && REG_P (operands[3])
4323    && REGNO (operands[3]) == REGNO (operands[2])"
4324   [(set (match_dup 3) (plus:SI (mult:SI (match_dup 0) (match_dup 1))
4325                                 (match_dup 2)))
4326    (set (mem:HI (match_dup 3)) (const_int 0))]
4327   "")
4329 ;; clear.b [rx=rx+rz.S2]
4331 (define_split
4332   [(parallel
4333     [(set (mem:QI (plus:SI
4334                     (mult:SI (match_operand:SI 0 "register_operand" "")
4335                              (match_operand:SI 1 "const_int_operand" ""))
4336                     (match_operand:SI 2 "register_operand" "")))
4337            (const_int 0))
4338      (set (match_operand:SI 3 "register_operand" "")
4339            (plus:SI (mult:SI (match_dup 0)
4340                              (match_dup 1))
4341                     (match_dup 2)))])]
4342   "REG_P (operands[2]) && REG_P (operands[3])
4343    && REGNO (operands[3]) == REGNO (operands[2])"
4344   [(set (match_dup 3) (plus:SI (mult:SI (match_dup 0) (match_dup 1))
4345                                 (match_dup 2)))
4346    (set (mem:QI (match_dup 3)) (const_int 0))]
4347   "")
4349 ;; clear.d [rx=rx+i]
4351 (define_split
4352   [(parallel
4353     [(set (mem:SI
4354            (plus:SI (match_operand:SI 0 "cris_bdap_operand" "")
4355                     (match_operand:SI 1 "cris_bdap_operand" "")))
4356            (const_int 0))
4357      (set (match_operand:SI 2 "register_operand" "")
4358            (plus:SI (match_dup 0)
4359                     (match_dup 1)))])]
4360   "(rtx_equal_p (operands[0], operands[2])
4361     || rtx_equal_p (operands[2], operands[1]))"
4362   [(set (match_dup 2) (plus:SI (match_dup 0) (match_dup 1)))
4363    (set (mem:SI (match_dup 2)) (const_int 0))]
4364   "")
4366 ;; clear.w [rx=rx+i]
4368 (define_split
4369   [(parallel
4370     [(set (mem:HI
4371            (plus:SI (match_operand:SI 0 "cris_bdap_operand" "")
4372                     (match_operand:SI 1 "cris_bdap_operand" "")))
4373            (const_int 0))
4374      (set (match_operand:SI 2 "register_operand" "")
4375            (plus:SI (match_dup 0)
4376                     (match_dup 1)))])]
4377   "(rtx_equal_p (operands[0], operands[2])
4378     || rtx_equal_p (operands[2], operands[1]))"
4379   [(set (match_dup 2) (plus:SI (match_dup 0) (match_dup 1)))
4380    (set (mem:HI (match_dup 2)) (const_int 0))]
4381   "")
4383 ;; clear.b [rx=rx+i]
4385 (define_split
4386   [(parallel
4387     [(set (mem:QI
4388            (plus:SI (match_operand:SI 0 "cris_bdap_operand" "")
4389                     (match_operand:SI 1 "cris_bdap_operand" "")))
4390            (const_int 0))
4391      (set (match_operand:SI 2 "register_operand" "")
4392            (plus:SI (match_dup 0)
4393                     (match_dup 1)))])]
4394   "(rtx_equal_p (operands[0], operands[2])
4395     || rtx_equal_p (operands[2], operands[1]))"
4396   [(set (match_dup 2) (plus:SI (match_dup 0) (match_dup 1)))
4397    (set (mem:QI (match_dup 2)) (const_int 0))]
4398   "")
4400 ;; mov(s|u).S1 [rx=rx+rz.S2],ry
4402 (define_split
4403   [(parallel
4404     [(set (match_operand 0 "register_operand" "")
4405           (match_operator
4406             5 "cris_extend_operator"
4407             [(mem (plus:SI
4408                    (mult:SI (match_operand:SI 1 "register_operand" "")
4409                             (match_operand:SI 2 "const_int_operand" ""))
4410                    (match_operand:SI 3 "register_operand" "")))]))
4411      (set (match_operand:SI 4 "register_operand" "")
4412            (plus:SI (mult:SI (match_dup 1)
4413                              (match_dup 2))
4414                     (match_dup 3)))])]
4415   "REG_P (operands[3])
4416    && REG_P (operands[4])
4417    && REGNO (operands[3]) == REGNO (operands[4])"
4418   [(set (match_dup 4) (plus:SI (mult:SI (match_dup 1) (match_dup 2))
4419                                 (match_dup 3)))
4420    (set (match_dup 0) (match_op_dup 5 [(match_dup 6)]))]
4421   "operands[6] = replace_equiv_address (XEXP (operands[5], 0), operands[4]);")
4423 ;; mov(s|u).S1 [rx=rx+i],ry
4425 (define_split
4426   [(parallel
4427     [(set (match_operand 0 "register_operand" "")
4428           (match_operator
4429             4 "cris_extend_operator"
4430             [(mem (plus:SI
4431                    (match_operand:SI 1 "cris_bdap_operand" "")
4432                    (match_operand:SI 2 "cris_bdap_operand" "")))]))
4433      (set (match_operand:SI 3 "register_operand" "")
4434            (plus:SI (match_dup 1)
4435                     (match_dup 2)))])]
4436   "(rtx_equal_p (operands[1], operands[3])
4437     || rtx_equal_p (operands[2], operands[3]))"
4438   [(set (match_dup 3) (plus:SI (match_dup 1) (match_dup 2)))
4439    (set (match_dup 0) (match_op_dup 4 [(match_dup 5)]))]
4440   "operands[5] = replace_equiv_address (XEXP (operands[4], 0), operands[3]);")
4442 ;; op.S1 [rx=rx+i],ry
4444 (define_split
4445   [(parallel
4446     [(set (match_operand 0 "register_operand" "")
4447           (match_operator
4448             5 "cris_orthogonal_operator"
4449             [(match_operand 1 "register_operand" "")
4450              (mem (plus:SI
4451                    (match_operand:SI 2 "cris_bdap_operand" "")
4452                    (match_operand:SI 3 "cris_bdap_operand" "")))]))
4453      (set (match_operand:SI 4 "register_operand" "")
4454            (plus:SI (match_dup 2)
4455                     (match_dup 3)))])]
4456   "(rtx_equal_p (operands[4], operands[2])
4457     || rtx_equal_p (operands[4], operands[3]))"
4458   [(set (match_dup 4) (plus:SI (match_dup 2) (match_dup 3)))
4459    (set (match_dup 0) (match_op_dup 5 [(match_dup 1) (match_dup 6)]))]
4460   "operands[6] = replace_equiv_address (XEXP (operands[5], 1), operands[4]);")
4462 ;; op.S1 [rx=rx+rz.S2],ry
4464 (define_split
4465   [(parallel
4466     [(set (match_operand 0 "register_operand" "")
4467           (match_operator
4468             6 "cris_orthogonal_operator"
4469             [(match_operand 1 "register_operand" "")
4470              (mem (plus:SI
4471                    (mult:SI (match_operand:SI 2 "register_operand" "")
4472                             (match_operand:SI 3 "const_int_operand" ""))
4473                    (match_operand:SI 4 "register_operand" "")))]))
4474      (set (match_operand:SI 5 "register_operand" "")
4475            (plus:SI (mult:SI (match_dup 2)
4476                              (match_dup 3))
4477                    (match_dup 4)))])]
4478   "REG_P (operands[4])
4479    && REG_P (operands[5])
4480    && REGNO (operands[5]) == REGNO (operands[4])"
4481   [(set (match_dup 5) (plus:SI (mult:SI (match_dup 2) (match_dup 3))
4482                                 (match_dup 4)))
4483    (set (match_dup 0) (match_op_dup 6 [(match_dup 1) (match_dup 7)]))]
4484   "operands[7] = replace_equiv_address (XEXP (operands[6], 1), operands[5]);")
4486 ;; op.S1 [rx=rx+rz.S2],ry (swapped)
4488 (define_split
4489   [(parallel
4490     [(set (match_operand 0 "register_operand" "")
4491           (match_operator
4492             6 "cris_commutative_orth_op"
4493             [(mem (plus:SI
4494                    (mult:SI (match_operand:SI 2 "register_operand" "")
4495                             (match_operand:SI 3 "const_int_operand" ""))
4496                    (match_operand:SI 4 "register_operand" "")))
4497              (match_operand 1 "register_operand" "")]))
4498      (set (match_operand:SI 5 "register_operand" "")
4499            (plus:SI (mult:SI (match_dup 2)
4500                              (match_dup 3))
4501                     (match_dup 4)))])]
4502   "REG_P (operands[4])
4503    && REG_P (operands[5])
4504    && REGNO (operands[5]) == REGNO (operands[4])"
4505   [(set (match_dup 5) (plus:SI (mult:SI (match_dup 2) (match_dup 3))
4506                                (match_dup 4)))
4507    (set (match_dup 0) (match_op_dup 6 [(match_dup 7) (match_dup 1)]))]
4508   "operands[7] = replace_equiv_address (XEXP (operands[6], 0), operands[5]);")
4510 ;; op.S1 [rx=rx+i],ry (swapped)
4512 (define_split
4513   [(parallel
4514     [(set (match_operand 0 "register_operand" "")
4515           (match_operator
4516             5 "cris_commutative_orth_op"
4517             [(mem
4518               (plus:SI (match_operand:SI 2 "cris_bdap_operand" "")
4519                        (match_operand:SI 3 "cris_bdap_operand" "")))
4520              (match_operand 1 "register_operand" "")]))
4521      (set (match_operand:SI 4 "register_operand" "")
4522           (plus:SI (match_dup 2)
4523                     (match_dup 3)))])]
4524   "(rtx_equal_p (operands[4], operands[2])
4525     || rtx_equal_p (operands[4], operands[3]))"
4526   [(set (match_dup 4) (plus:SI (match_dup 2) (match_dup 3)))
4527    (set (match_dup 0) (match_op_dup 5 [(match_dup 6) (match_dup 1)]))]
4528   "operands[6] = replace_equiv_address (XEXP (operands[5], 0), operands[4]);")
4530 ;; op(s|u).S1 [rx=rx+rz.S2],ry
4532 (define_split
4533   [(parallel
4534     [(set (match_operand 0 "register_operand" "")
4535           (match_operator
4536             6 "cris_operand_extend_operator"
4537             [(match_operand 1 "register_operand" "")
4538              (match_operator
4539               7 "cris_extend_operator"
4540               [(mem (plus:SI
4541                      (mult:SI (match_operand:SI 2 "register_operand" "")
4542                               (match_operand:SI 3 "const_int_operand" ""))
4543                      (match_operand:SI 4 "register_operand" "")))])]))
4544      (set (match_operand:SI 5 "register_operand" "")
4545            (plus:SI (mult:SI (match_dup 2)
4546                              (match_dup 3))
4547                     (match_dup 4)))])]
4548   "REG_P (operands[4])
4549    && REG_P (operands[5])
4550    && REGNO (operands[5]) == REGNO (operands[4])"
4551   [(set (match_dup 5) (plus:SI (mult:SI (match_dup 2) (match_dup 3))
4552                                (match_dup 4)))
4553    (set (match_dup 0) (match_op_dup 6 [(match_dup 1) (match_dup 8)]))]
4554   "operands[8] = gen_rtx (GET_CODE (operands[7]), GET_MODE (operands[7]),
4555                           replace_equiv_address (XEXP (operands[7], 0),
4556                                                  operands[5]));")
4558 ;; op(s|u).S1 [rx=rx+i],ry
4560 (define_split
4561   [(parallel
4562     [(set (match_operand 0 "register_operand" "")
4563           (match_operator
4564             5 "cris_operand_extend_operator"
4565             [(match_operand 1 "register_operand" "")
4566              (match_operator
4567               6 "cris_extend_operator"
4568               [(mem
4569                 (plus:SI (match_operand:SI 2 "cris_bdap_operand" "")
4570                          (match_operand:SI 3 "cris_bdap_operand" "")
4571                          ))])]))
4572      (set (match_operand:SI 4 "register_operand" "")
4573            (plus:SI (match_dup 2)
4574                     (match_dup 3)))])]
4575   "(rtx_equal_p (operands[4], operands[2])
4576     || rtx_equal_p (operands[4], operands[3]))"
4577   [(set (match_dup 4) (plus:SI (match_dup 2) (match_dup 3)))
4578    (set (match_dup 0) (match_op_dup 5 [(match_dup 1) (match_dup 7)]))]
4579   "operands[7] = gen_rtx (GET_CODE (operands[6]), GET_MODE (operands[6]),
4580                           replace_equiv_address (XEXP (operands[6], 0),
4581                                                  operands[4]));")
4583 ;; op(s|u).S1 [rx=rx+rz.S2],ry (swapped, plus or bound)
4585 (define_split
4586   [(parallel
4587     [(set (match_operand 0 "register_operand" "")
4588           (match_operator
4589             7 "cris_plus_or_bound_operator"
4590             [(match_operator
4591               6 "cris_extend_operator"
4592               [(mem (plus:SI
4593                      (mult:SI (match_operand:SI 2 "register_operand" "")
4594                               (match_operand:SI 3 "const_int_operand" ""))
4595                      (match_operand:SI 4 "register_operand" "")))])
4596              (match_operand 1 "register_operand" "")]))
4597      (set (match_operand:SI 5 "register_operand" "")
4598            (plus:SI (mult:SI (match_dup 2)
4599                              (match_dup 3))
4600                     (match_dup 4)))])]
4601   "REG_P (operands[4]) && REG_P (operands[5])
4602    && REGNO (operands[5]) == REGNO (operands[4])"
4603   [(set (match_dup 5) (plus:SI (mult:SI (match_dup 2) (match_dup 3))
4604                                (match_dup 4)))
4605    (set (match_dup 0) (match_op_dup 6 [(match_dup 8) (match_dup 1)]))]
4606   "operands[8] = gen_rtx (GET_CODE (operands[6]), GET_MODE (operands[6]),
4607                           replace_equiv_address (XEXP (operands[6], 0),
4608                                                  operands[5]));")
4610 ;; op(s|u).S1 [rx=rx+i],ry (swapped, plus or bound)
4612 (define_split
4613   [(parallel
4614     [(set (match_operand 0 "register_operand" "")
4615           (match_operator
4616             6 "cris_plus_or_bound_operator"
4617             [(match_operator
4618               5 "cris_extend_operator"
4619              [(mem (plus:SI
4620                     (match_operand:SI 2 "cris_bdap_operand" "")
4621                     (match_operand:SI 3 "cris_bdap_operand" "")))])
4622              (match_operand 1 "register_operand" "")]))
4623      (set (match_operand:SI 4 "register_operand" "")
4624            (plus:SI (match_dup 2)
4625                     (match_dup 3)))])]
4626   "(rtx_equal_p (operands[4], operands[2])
4627     || rtx_equal_p (operands[4], operands[3]))"
4628   [(set (match_dup 4) (plus:SI (match_dup 2) (match_dup 3)))
4629    (set (match_dup 0) (match_op_dup 6 [(match_dup 7) (match_dup 1)]))]
4630   "operands[7] = gen_rtx (GET_CODE (operands[5]), GET_MODE (operands[5]),
4631                           replace_equiv_address (XEXP (operands[5], 0),
4632                                                  operands[4]));")
4634 ;; Splits for addressing prefixes that have no side-effects, so we can
4635 ;; fill a delay slot.  Never split if we lose something, though.
4637 ;; If we have a
4638 ;;  move [indirect_ref],rx
4639 ;; where indirect ref = {const, [r+], [r]}, it costs as much as
4640 ;;  move indirect_ref,rx
4641 ;;  move [rx],rx
4642 ;; Take care not to allow indirect_ref = register.
4644 ;; We're not allowed to generate copies of registers with different mode
4645 ;; until after reload; copying pseudos upsets reload.  CVS as of
4646 ;; 2001-08-24, unwind-dw2-fde.c, _Unwind_Find_FDE ICE in
4647 ;; cselib_invalidate_regno.
4649 (define_split
4650   [(set (match_operand 0 "register_operand" "")
4651         (match_operand 1 "indirect_operand" ""))]
4652   "reload_completed
4653    && REG_P (operands[0])
4654    && GET_MODE_SIZE (GET_MODE (operands[0])) <= UNITS_PER_WORD
4655    && (GET_CODE (XEXP (operands[1], 0)) == MEM
4656        || CONSTANT_P (XEXP (operands[1], 0)))"
4657   [(set (match_dup 2) (match_dup 4))
4658    (set (match_dup 0) (match_dup 3))]
4659   "operands[2] = gen_rtx_REG (Pmode, REGNO (operands[0]));
4660    operands[3] = replace_equiv_address (operands[1], operands[2]);
4661    operands[4] = XEXP (operands[1], 0);")
4663 ;; As the above, but MOVS and MOVU.
4665 (define_split
4666   [(set (match_operand 0 "register_operand" "")
4667         (match_operator
4668          4 "cris_extend_operator"
4669          [(match_operand 1 "indirect_operand" "")]))]
4670   "reload_completed
4671    && REG_P (operands[0])
4672    && GET_MODE_SIZE (GET_MODE (operands[0])) <= UNITS_PER_WORD
4673    && (GET_CODE (XEXP (operands[1], 0)) == MEM
4674        || CONSTANT_P (XEXP (operands[1], 0)))"
4675   [(set (match_dup 2) (match_dup 5))
4676    (set (match_dup 0) (match_op_dup 4 [(match_dup 3)]))]
4677   "operands[2] = gen_rtx_REG (Pmode, REGNO (operands[0]));
4678    operands[3] = replace_equiv_address (XEXP (operands[4], 0), operands[2]);
4679    operands[5] = XEXP (operands[1], 0);")
4681 ;; Various peephole optimizations.
4683 ;; Watch out: when you exchange one set of instructions for another, the
4684 ;; condition codes setting must be the same, or you have to CC_INIT or
4685 ;; whatever is appropriate, in the pattern before you emit the
4686 ;; assembly text.  This is best done here, not in cris_notice_update_cc,
4687 ;; to keep changes local to their cause.
4689 ;; Do not add patterns that you do not know will be matched.
4690 ;; Please also add a self-contained testcase.
4692 ;; We have trouble with and:s and shifts.  Maybe something is broken in
4693 ;; gcc?  Or it could just be that bit-field insn expansion is a bit
4694 ;; suboptimal when not having extzv insns.
4696 (define_peephole
4697   [(set (match_operand 0 "register_operand" "=r")
4698         (ashiftrt:SI (match_dup 0)
4699                      (match_operand:SI 1 "const_int_operand" "n")))
4700    (set (match_dup 0)
4701         (and:SI (match_dup 0)
4702                 (match_operand 2 "const_int_operand" "n")))]
4703   "INTVAL (operands[2]) > 31
4704    && INTVAL (operands[2]) < 255
4705    && INTVAL (operands[1]) > 23"
4707 ;; The m flag should be ignored, because this will be a *byte* "and"
4708 ;; operation.
4710   "*
4712   cc_status.flags |= CC_NOT_NEGATIVE;
4714   return \"lsrq %1,%0\;and.b %2,%0\";
4717 (define_peephole
4718   [(set (match_operand 0 "register_operand" "=r")
4719         (ashiftrt:SI (match_dup 0)
4720                      (match_operand:SI 1 "const_int_operand" "n")))
4721    (set (match_dup 0)
4722         (and:SI (match_dup 0)
4723                 (match_operand 2 "const_int_operand" "n")))]
4724   "INTVAL (operands[2]) > 31
4725    && INTVAL (operands[2]) < 65535
4726    && INTVAL (operands[2]) != 255
4727    && INTVAL (operands[1]) > 15"
4729 ;; The m flag should be ignored, because this will be a *word* "and"
4730 ;; operation.
4732   "*
4734   cc_status.flags |= CC_NOT_NEGATIVE;
4736   return \"lsrq %1,%0\;and.w %2,%0\";
4739 (define_peephole
4740   [(set (match_operand 0 "register_operand" "=r")
4741         (lshiftrt:SI (match_dup 0)
4742                      (match_operand:SI 1 "const_int_operand" "n")))
4743    (set (match_dup 0)
4744         (and:SI (match_dup 0)
4745                 (match_operand 2 "const_int_operand" "n")))]
4746   "INTVAL (operands[2]) > 31
4747    && INTVAL (operands[2]) < 255
4748    && INTVAL (operands[1]) > 23"
4750 ;; The m flag should be ignored, because this will be a *byte* "and"
4751 ;; operation.
4753   "*
4755   cc_status.flags |= CC_NOT_NEGATIVE;
4757   return \"lsrq %1,%0\;and.b %2,%0\";
4760 (define_peephole
4761   [(set (match_operand 0 "register_operand" "=r")
4762         (lshiftrt:SI (match_dup 0)
4763                      (match_operand:SI 1 "const_int_operand" "n")))
4764    (set (match_dup 0)
4765         (and:SI (match_dup 0)
4766                 (match_operand 2 "const_int_operand" "n")))]
4767   "INTVAL (operands[2]) > 31 && INTVAL (operands[2]) < 65535
4768    && INTVAL (operands[2]) != 255
4769    && INTVAL (operands[1]) > 15"
4771 ;; The m flag should be ignored, because this will be a *word* "and"
4772 ;; operation.
4774   "*
4776   cc_status.flags |= CC_NOT_NEGATIVE;
4778   return \"lsrq %1,%0\;and.w %2,%0\";
4782 ;; Change
4783 ;;  add.d n,rx
4784 ;;  move [rx],ry
4785 ;; into
4786 ;;  move [rx=rx+n],ry
4787 ;; when -128 <= n <= 127.
4788 ;; This will reduce the size of the assembler code for n = [-128..127],
4789 ;; and speed up accordingly.
4791 (define_peephole
4792   [(set (match_operand:SI 0 "register_operand" "=r")
4793         (plus:SI (match_operand:SI 1 "register_operand" "0")
4794                  (match_operand:SI 2 "const_int_operand" "n")))
4795    (set (match_operand 3 "register_operand" "=r")
4796         (mem (match_dup 0)))]
4797   "GET_MODE (operands[3]) != DImode
4798     && REGNO (operands[3]) != REGNO (operands[0])
4799     && (BASE_P (operands[1]) || BASE_P (operands[2]))
4800     && ! CONST_OK_FOR_LETTER_P (INTVAL (operands[2]), 'J')
4801     && ! CONST_OK_FOR_LETTER_P (INTVAL (operands[2]), 'N')
4802     && (INTVAL (operands[2]) >= -128 && INTVAL (operands[2]) < 128)"
4803   "move.%s3 [%0=%1%S2],%3")
4805 ;; Vice versa: move ry,[rx=rx+n]
4807 (define_peephole
4808   [(set (match_operand:SI 0 "register_operand" "=r")
4809         (plus:SI (match_operand:SI 1 "register_operand" "0")
4810                  (match_operand:SI 2 "const_int_operand" "n")))
4811    (set (mem (match_dup 0))
4812         (match_operand 3 "register_operand" "=r"))]
4813   "GET_MODE (operands[3]) != DImode
4814     && REGNO (operands[3]) != REGNO (operands[0])
4815     && (BASE_P (operands[1]) || BASE_P (operands[2]))
4816     && ! CONST_OK_FOR_LETTER_P (INTVAL (operands[2]), 'J')
4817     && ! CONST_OK_FOR_LETTER_P (INTVAL (operands[2]), 'N')
4818     && (INTVAL (operands[2]) >= -128 && INTVAL (operands[2]) < 128)"
4819   "move.%s3 %3,[%0=%1%S2]"
4820   [(set_attr "cc" "none")])
4822 ;; As above, change:
4823 ;;  add.d n,rx
4824 ;;  op.d [rx],ry
4825 ;; into:
4826 ;;  op.d [rx=rx+n],ry
4827 ;; Saves when n = [-128..127].
4829 ;; Splitting and joining combinations for side-effect modes are slightly
4830 ;; out of hand.  They probably will not save the time they take typing in,
4831 ;; not to mention the bugs that creep in.  FIXME: Get rid of as many of
4832 ;; the splits and peepholes as possible.
4834 (define_peephole
4835   [(set (match_operand:SI 0 "register_operand" "=r")
4836         (plus:SI (match_operand:SI 1 "register_operand" "0")
4837                  (match_operand:SI 2 "const_int_operand" "n")))
4838    (set (match_operand 3 "register_operand" "=r")
4839         (match_operator 4 "cris_orthogonal_operator"
4840                            [(match_dup 3)
4841                             (mem (match_dup 0))]))]
4842   "GET_MODE (operands[3]) != DImode
4843     && REGNO (operands[0]) != REGNO (operands[3])
4844     && ! CONST_OK_FOR_LETTER_P (INTVAL (operands[2]), 'J')
4845     && ! CONST_OK_FOR_LETTER_P (INTVAL (operands[2]), 'N')
4846     && INTVAL (operands[2]) >= -128
4847     && INTVAL (operands[2]) <= 127"
4848   "%x4.%s3 [%0=%1%S2],%3")
4850 ;; Sometimes, for some reason the pattern
4851 ;;  move x,rx
4852 ;;  add y,rx
4853 ;;  move [rx],rz
4854 ;; will occur.  Solve this, and likewise for to-memory.
4856 (define_peephole
4857   [(set (match_operand:SI 0 "register_operand" "=r,r,r,r")
4858         (match_operand:SI 1 "cris_bdap_biap_operand" "r,>Rn,r,>Rn"))
4859    (set (match_dup 0)
4860         (plus:SI (match_operand:SI 2 "cris_bdap_biap_operand" "0,0,r>Rn,r")
4861                  (match_operand:SI 3 "cris_bdap_biap_operand" "r>Rn,r,0,0")))
4862    (set (match_operand 4 "register_operand" "=r,r,r,r")
4863         (mem (match_dup 0)))]
4864   "(rtx_equal_p (operands[2], operands[0])
4865     || rtx_equal_p (operands[3], operands[0]))
4866    && cris_side_effect_mode_ok (PLUS, operands, 0,
4867                                 (REG_S_P (operands[1])
4868                                  ? 1
4869                                  : (rtx_equal_p (operands[2], operands[0])
4870                                     ? 3 : 2)),
4871                                 (! REG_S_P (operands[1])
4872                                  ? 1
4873                                  : (rtx_equal_p (operands[2], operands[0])
4874                                     ? 3 : 2)),
4875                                 -1, 4)"
4876   "@
4877    move.%s4 [%0=%1%S3],%4
4878    move.%s4 [%0=%3%S1],%4
4879    move.%s4 [%0=%1%S2],%4
4880    move.%s4 [%0=%2%S1],%4")
4882 ;; As above but to memory.
4884 (define_peephole
4885   [(set (match_operand:SI 0 "register_operand" "=r,r,r,r")
4886         (match_operand:SI 1 "cris_bdap_biap_operand" "r,>Rn,r,>Rn"))
4887    (set (match_dup 0)
4888         (plus:SI (match_operand:SI 2 "cris_bdap_biap_operand" "0,0,r>Rn,r")
4889                  (match_operand:SI 3 "cris_bdap_biap_operand" "r>Rn,r,0,0")))
4890    (set (mem (match_dup 0))
4891         (match_operand 4 "register_operand" "=r,r,r,r"))]
4892   "(rtx_equal_p (operands[2], operands[0])
4893     || rtx_equal_p (operands[3], operands[0]))
4894    && cris_side_effect_mode_ok (PLUS, operands, 0,
4895                                 (REG_S_P (operands[1])
4896                                  ? 1
4897                                  : (rtx_equal_p (operands[2], operands[0])
4898                                     ? 3 : 2)),
4899                                 (! REG_S_P (operands[1])
4900                                    ? 1
4901                                  : (rtx_equal_p (operands[2], operands[0])
4902                                     ? 3 : 2)),
4903                                 -1, 4)"
4904   "@
4905    move.%s4 %4,[%0=%1%S3]
4906    move.%s4 %4,[%0=%3%S1]
4907    move.%s4 %4,[%0=%1%S2]
4908    move.%s4 %4,[%0=%2%S1]"
4909   [(set_attr "cc" "none")])
4912 ;; As the move from-memory above, but with an operation.
4914 (define_peephole
4915   [(set (match_operand:SI 0 "register_operand" "=r,r,r,r")
4916         (match_operand:SI 1 "cris_bdap_biap_operand" "r,>Rn,r,>Rn"))
4917    (set (match_dup 0)
4918         (plus:SI (match_operand:SI 2 "cris_bdap_biap_operand" "0,0,r>Rn,r")
4919                  (match_operand:SI 3 "cris_bdap_biap_operand" "r>Rn,r,0,0")))
4920    (set (match_operand 4 "register_operand" "=r,r,r,r")
4921         (match_operator 5 "cris_orthogonal_operator"
4922                         [(match_dup 3)
4923                          (mem (match_dup 0))]))]
4924   "(rtx_equal_p (operands[2], operands[0])
4925     || rtx_equal_p (operands[3], operands[0]))
4926    && cris_side_effect_mode_ok (PLUS, operands, 0,
4927                                 (REG_S_P (operands[1])
4928                                  ? 1
4929                                  : (rtx_equal_p (operands[2], operands[0])
4930                                     ? 3 : 2)),
4931                                 (! REG_S_P (operands[1])
4932                                  ? 1
4933                                  : (rtx_equal_p (operands[2], operands[0])
4934                                     ? 3 : 2)),
4935                                 -1, 4)"
4936   "@
4937    %x5.%s4 [%0=%1%S3],%4
4938    %x5.%s4 [%0=%3%S1],%4
4939    %x5.%s4 [%0=%1%S2],%4
4940    %x5.%s4 [%0=%2%S1],%4")
4942 ;; Same, but with swapped operands (and commutative operation).
4944 (define_peephole
4945   [(set (match_operand:SI 0 "register_operand" "=r,r,r,r")
4946         (match_operand:SI 1 "cris_bdap_biap_operand" "r,>Rn,r,>Rn"))
4947    (set (match_dup 0)
4948         (plus:SI (match_operand:SI 2 "cris_bdap_biap_operand" "0,0,r>Rn,r")
4949                  (match_operand:SI 3 "cris_bdap_biap_operand" "r>Rn,r,0,0")))
4950    (set (match_operand 4 "register_operand" "=r,r,r,r")
4951         (match_operator 5 "cris_commutative_orth_op"
4952                         [(mem (match_dup 0))
4953                          (match_dup 3)]))]
4954   "(rtx_equal_p (operands[2], operands[0])
4955     || rtx_equal_p (operands[3], operands[0]))
4956    && cris_side_effect_mode_ok (PLUS, operands, 0,
4957                            (REG_S_P (operands[1])
4958                             ? 1
4959                             : (rtx_equal_p (operands[2], operands[0])
4960                                ? 3 : 2)),
4961                            (! REG_S_P (operands[1])
4962                             ? 1
4963                             : (rtx_equal_p (operands[2], operands[0])
4964                                ? 3 : 2)),
4965                            -1, 4)"
4966   "@
4967    %x5.%s4 [%0=%1%S3],%4
4968    %x5.%s4 [%0=%3%S1],%4
4969    %x5.%s4 [%0=%1%S2],%4
4970    %x5.%s4 [%0=%2%S1],%4")
4972 ;; Another spotted bad code:
4973 ;;   move rx,ry
4974 ;;   move [ry],ry
4976 (define_peephole
4977   [(set (match_operand:SI 0 "register_operand" "=r")
4978         (match_operand:SI 1 "register_operand" "r"))
4979    (set (match_operand 2 "register_operand" "=r")
4980         (mem (match_dup 0)))]
4981   "REGNO (operands[0]) == REGNO (operands[2])
4982    && GET_MODE_SIZE (GET_MODE (operands[2])) <= UNITS_PER_WORD"
4983   "move.%s2 [%1],%0"
4984   [(set_attr "slottable" "yes")])
4986 ;; And a simple variant with extended operand.
4988 (define_peephole
4989   [(set (match_operand:SI 0 "register_operand" "=r")
4990         (match_operand:SI 1 "register_operand" "r"))
4991    (set (match_operand 2 "register_operand" "=r")
4992         (match_operator 3 "cris_extend_operator" [(mem (match_dup 0))]))]
4993   "REGNO (operands[0]) == REGNO (operands[2])
4994    && GET_MODE_SIZE (GET_MODE (operands[2])) <= UNITS_PER_WORD"
4995   "mov%e3.%m3 [%1],%0"
4996   [(set_attr "slottable" "yes")])
4998 ;; Here are all peepholes that have a saved testcase.
4999 ;; Do not add new peepholes without testcases.
5001 ;; peep-1:
5002 ;;   move.d [r10+16],r9
5003 ;;   and.d r12,r9
5004 ;; change to
5005 ;;   and.d [r10+16],r12,r9
5006 ;; With generalization of the operation, the size and the addressing mode.
5007 ;;  This seems to be the result of a quirk in register allocation
5008 ;; missing the three-operand cases when having different predicates.
5009 ;; Maybe that it matters that it is a commutative operation.
5010 ;;  This pattern helps that situation, but there's still the increased
5011 ;; register pressure.
5012 ;;  Note that adding the noncommutative variant did not show any matches
5013 ;; in ipps and cc1, so it's not here.
5015 (define_peephole
5016   [(set (match_operand 0 "register_operand" "=r,r,r,r")
5017         (mem (plus:SI
5018               (match_operand:SI 1 "cris_bdap_biap_operand" "r,r>Rn,r,r>Rn")
5019               (match_operand:SI 2 "cris_bdap_biap_operand" "r>Rn,r,r>Rn,r"))))
5020    (set (match_dup 0)
5021         (match_operator 5 "cris_commutative_orth_op"
5022                         [(match_operand 3 "register_operand" "0,0,r,r")
5023                          (match_operand 4 "register_operand" "r,r,0,0")]))]
5024   "(rtx_equal_p (operands[3], operands[0])
5025     || rtx_equal_p (operands[4], operands[0]))
5026    && ! rtx_equal_p (operands[3], operands[4])
5027    && (REG_S_P (operands[1]) || REG_S_P (operands[2]))
5028    && GET_MODE_SIZE (GET_MODE (operands[0])) <= UNITS_PER_WORD"
5029   "@
5030    %x5.%s0 [%1%S2],%4,%0
5031    %x5.%s0 [%2%S1],%4,%0
5032    %x5.%s0 [%1%S2],%3,%0
5033    %x5.%s0 [%2%S1],%3,%0")
5035 ;; peep-2:
5036 ;;  I cannot tell GCC (2.1, 2.7.2) how to correctly reload an instruction
5037 ;; that looks like
5038 ;;   and.b some_byte,const,reg_32
5039 ;; where reg_32 is the destination of the "three-address" code optimally.
5040 ;; It should be:
5041 ;;   movu.b some_byte,reg_32
5042 ;;   and.b const,reg_32
5043 ;; but is turns into:
5044 ;;   move.b some_byte,reg_32
5045 ;;   and.d const,reg_32
5046 ;; Fix it here.
5048 (define_peephole
5049   [(set (match_operand:SI 0 "register_operand" "=r")
5050         (match_operand:SI 1 "nonimmediate_operand" "rm"))
5051    (set (match_operand:SI 2 "register_operand" "=0")
5052         (and:SI (match_dup 0)
5053                 (match_operand:SI 3 "const_int_operand" "n")))]
5055    ;; Since the size of the memory access could be made different here,
5056    ;; don't do this for a mem-volatile access.
5058   "REGNO (operands[2]) == REGNO (operands[0])
5059    && INTVAL (operands[3]) <= 65535 && INTVAL (operands[3]) >= 0
5060    && ! CONST_OK_FOR_LETTER_P (INTVAL (operands[3]), 'I')
5061    && (GET_CODE (operands[1]) != MEM || ! MEM_VOLATILE_P (operands[1]))"
5062   "*
5064   if (CONST_OK_FOR_LETTER_P (INTVAL (operands[3]), 'O'))
5065     return \"movu.%z3 %1,%0\;andq %b3,%0\";
5067   cc_status.flags |= CC_NOT_NEGATIVE;
5069   return \"movu.%z3 %1,%0\;and.%z3 %3,%0\";
5072 ;; peep-3
5074 (define_peephole
5075   [(set (match_operand 0 "register_operand" "=r")
5076         (match_operand 1 "nonimmediate_operand" "rm"))
5077    (set (match_operand:SI 2 "register_operand" "=r")
5078         (and:SI (subreg:SI (match_dup 0) 0)
5079                 (match_operand 3 "const_int_operand" "n")))]
5081    ;; Since the size of the memory access could be made different here,
5082    ;; don't do this for a mem-volatile access.
5084   "REGNO (operands[0]) == REGNO (operands[2])
5085    && INTVAL (operands[3]) > 0
5086    && INTVAL (operands[3]) <= 65535
5087    && ! CONST_OK_FOR_LETTER_P (INTVAL (operands[3]), 'I')
5088    && (GET_CODE (operands[1]) != MEM || ! MEM_VOLATILE_P (operands[1]))"
5089   "*
5091   if (CONST_OK_FOR_LETTER_P (INTVAL (operands[3]), 'O'))
5092     return \"movu.%z3 %1,%0\;andq %b3,%0\";
5094   cc_status.flags |= CC_NOT_NEGATIVE;
5096   return \"movu.%z3 %1,%0\;and.%z3 %3,%0\";
5099 ;; Local variables:
5100 ;; mode:emacs-lisp
5101 ;; comment-start: ";; "
5102 ;; eval: (set-syntax-table (copy-sequence (syntax-table)))
5103 ;; eval: (modify-syntax-entry ?[ "(]")
5104 ;; eval: (modify-syntax-entry ?] ")[")
5105 ;; eval: (modify-syntax-entry ?{ "(}")
5106 ;; eval: (modify-syntax-entry ?} "){")
5107 ;; eval: (setq indent-tabs-mode t)
5108 ;; End: