1 ;; -----------------------------------------------------------------
3 ;; -----------------------------------------------------------------
5 ;; Convert (A >> B) & C to (A & 255) >> B if C == 255 >> B.
8 [(parallel [(set (match_operand:HI 0 "register_operand" "")
9 (lshiftrt:HI (match_dup 0)
10 (match_operand:HI 1 "const_int_operand" "")))
11 (clobber (match_operand:HI 2 "" ""))])
14 (match_operand:HI 3 "const_int_operand" "")))]
15 "INTVAL (operands[3]) == (255 >> INTVAL (operands[1]))"
19 (parallel [(set (match_dup 0)
20 (lshiftrt:HI (match_dup 0) (match_dup 1)))
21 (clobber (match_dup 2))])]
24 ;; Convert (A << B) & C to (A & 255) << B if C == 255 << B.
27 [(parallel [(set (match_operand:HI 0 "register_operand" "")
28 (ashift:HI (match_dup 0)
29 (match_operand:HI 1 "const_int_operand" "")))
30 (clobber (match_operand:HI 2 "" ""))])
33 (match_operand:HI 3 "const_int_operand" "")))]
34 "INTVAL (operands[3]) == (255 << INTVAL (operands[1]))"
38 (parallel [(set (match_dup 0)
39 (ashift:HI (match_dup 0) (match_dup 1)))
40 (clobber (match_dup 2))])]
43 ;; Convert (A >> B) & C to (A & 255) >> B if C == 255 >> B.
46 [(parallel [(set (match_operand:SI 0 "register_operand" "")
47 (lshiftrt:SI (match_dup 0)
48 (match_operand:SI 1 "const_int_operand" "")))
49 (clobber (match_operand:SI 2 "" ""))])
52 (match_operand:SI 3 "const_int_operand" "")))]
53 "INTVAL (operands[3]) == (255 >> INTVAL (operands[1]))"
57 (parallel [(set (match_dup 0)
58 (lshiftrt:SI (match_dup 0) (match_dup 1)))
59 (clobber (match_dup 2))])]
62 ;; Convert (A << B) & C to (A & 255) << B if C == 255 << B.
65 [(parallel [(set (match_operand:SI 0 "register_operand" "")
66 (ashift:SI (match_dup 0)
67 (match_operand:SI 1 "const_int_operand" "")))
68 (clobber (match_operand:SI 2 "" ""))])
71 (match_operand:SI 3 "const_int_operand" "")))]
72 "INTVAL (operands[3]) == (255 << INTVAL (operands[1]))"
76 (parallel [(set (match_dup 0)
77 (ashift:SI (match_dup 0) (match_dup 1)))
78 (clobber (match_dup 2))])]
81 ;; Convert (A >> B) & C to (A & 65535) >> B if C == 65535 >> B.
84 [(parallel [(set (match_operand:SI 0 "register_operand" "")
85 (lshiftrt:SI (match_dup 0)
86 (match_operand:SI 1 "const_int_operand" "")))
87 (clobber (match_operand:SI 2 "" ""))])
90 (match_operand:SI 3 "const_int_operand" "")))]
91 "INTVAL (operands[3]) == (65535 >> INTVAL (operands[1]))"
95 (parallel [(set (match_dup 0)
96 (lshiftrt:SI (match_dup 0) (match_dup 1)))
97 (clobber (match_dup 2))])]
100 ;; Convert (A << B) & C to (A & 65535) << B if C == 65535 << B.
103 [(parallel [(set (match_operand:SI 0 "register_operand" "")
104 (ashift:SI (match_dup 0)
105 (match_operand:SI 1 "const_int_operand" "")))
106 (clobber (match_operand:SI 2 "" ""))])
108 (and:SI (match_dup 0)
109 (match_operand:SI 3 "const_int_operand" "")))]
110 "INTVAL (operands[3]) == (65535 << INTVAL (operands[1]))"
112 (and:SI (match_dup 0)
114 (parallel [(set (match_dup 0)
115 (ashift:SI (match_dup 0) (match_dup 1)))
116 (clobber (match_dup 2))])]
119 ;; Cram four pushes into stm.l.
122 [(set (mem:SI (pre_dec:SI (reg:SI SP_REG)))
123 (match_operand:SI 0 "register_operand" ""))
124 (set (mem:SI (pre_dec:SI (reg:SI SP_REG)))
125 (match_operand:SI 1 "register_operand" ""))
126 (set (mem:SI (pre_dec:SI (reg:SI SP_REG)))
127 (match_operand:SI 2 "register_operand" ""))
128 (set (mem:SI (pre_dec:SI (reg:SI SP_REG)))
129 (match_operand:SI 3 "register_operand" ""))]
130 "TARGET_H8300S && !TARGET_NORMAL_MODE
131 && (REGNO_REG_CLASS (REGNO (operands[3])) == GENERAL_REGS
132 && REGNO (operands[1]) == REGNO (operands[0]) + 1
133 && REGNO (operands[2]) == REGNO (operands[0]) + 2
134 && REGNO (operands[3]) == REGNO (operands[0]) + 3
135 && (TARGET_H8300SX || REGNO (operands[0]) == 0))"
136 [(parallel [(set (mem:SI (plus:SI (reg:SI SP_REG) (const_int -4)))
138 (set (mem:SI (plus:SI (reg:SI SP_REG) (const_int -8)))
140 (set (mem:SI (plus:SI (reg:SI SP_REG) (const_int -12)))
142 (set (mem:SI (plus:SI (reg:SI SP_REG) (const_int -16)))
145 (plus:SI (reg:SI SP_REG)
150 [(set (mem:SI (pre_dec:HI (reg:HI SP_REG)))
151 (match_operand:SI 0 "register_operand" ""))
152 (set (mem:SI (pre_dec:HI (reg:HI SP_REG)))
153 (match_operand:SI 1 "register_operand" ""))
154 (set (mem:SI (pre_dec:HI (reg:HI SP_REG)))
155 (match_operand:SI 2 "register_operand" ""))
156 (set (mem:SI (pre_dec:HI (reg:HI SP_REG)))
157 (match_operand:SI 3 "register_operand" ""))]
158 "TARGET_H8300S && TARGET_NORMAL_MODE
159 && (REGNO_REG_CLASS (REGNO (operands[3])) == GENERAL_REGS
160 && REGNO (operands[1]) == REGNO (operands[0]) + 1
161 && REGNO (operands[2]) == REGNO (operands[0]) + 2
162 && REGNO (operands[3]) == REGNO (operands[0]) + 3
163 && (TARGET_H8300SX || REGNO (operands[0]) == 0))"
164 [(parallel [(set (mem:SI (plus:HI (reg:HI SP_REG) (const_int -4)))
166 (set (mem:SI (plus:HI (reg:HI SP_REG) (const_int -8)))
168 (set (mem:SI (plus:HI (reg:HI SP_REG) (const_int -12)))
170 (set (mem:SI (plus:HI (reg:HI SP_REG) (const_int -16)))
173 (plus:HI (reg:HI SP_REG)
177 ;; Cram three pushes into stm.l.
180 [(set (mem:SI (pre_dec:SI (reg:SI SP_REG)))
181 (match_operand:SI 0 "register_operand" ""))
182 (set (mem:SI (pre_dec:SI (reg:SI SP_REG)))
183 (match_operand:SI 1 "register_operand" ""))
184 (set (mem:SI (pre_dec:SI (reg:SI SP_REG)))
185 (match_operand:SI 2 "register_operand" ""))]
186 "TARGET_H8300S && !TARGET_NORMAL_MODE
187 && (REGNO_REG_CLASS (REGNO (operands[2])) == GENERAL_REGS
188 && REGNO (operands[1]) == REGNO (operands[0]) + 1
189 && REGNO (operands[2]) == REGNO (operands[0]) + 2
190 && (TARGET_H8300SX || (REGNO (operands[0]) & 3) == 0))"
191 [(parallel [(set (mem:SI (plus:SI (reg:SI SP_REG) (const_int -4)))
193 (set (mem:SI (plus:SI (reg:SI SP_REG) (const_int -8)))
195 (set (mem:SI (plus:SI (reg:SI SP_REG) (const_int -12)))
198 (plus:SI (reg:SI SP_REG)
203 [(set (mem:SI (pre_dec:HI (reg:HI SP_REG)))
204 (match_operand:SI 0 "register_operand" ""))
205 (set (mem:SI (pre_dec:HI (reg:HI SP_REG)))
206 (match_operand:SI 1 "register_operand" ""))
207 (set (mem:SI (pre_dec:HI (reg:HI SP_REG)))
208 (match_operand:SI 2 "register_operand" ""))]
209 "TARGET_H8300S && TARGET_NORMAL_MODE
210 && (REGNO_REG_CLASS (REGNO (operands[2])) == GENERAL_REGS
211 && REGNO (operands[1]) == REGNO (operands[0]) + 1
212 && REGNO (operands[2]) == REGNO (operands[0]) + 2
213 && (TARGET_H8300SX || (REGNO (operands[0]) & 3) == 0))"
214 [(parallel [(set (mem:SI (plus:HI (reg:HI SP_REG) (const_int -4)))
216 (set (mem:SI (plus:HI (reg:HI SP_REG) (const_int -8)))
218 (set (mem:SI (plus:HI (reg:HI SP_REG) (const_int -12)))
221 (plus:HI (reg:HI SP_REG)
225 ;; Cram two pushes into stm.l.
228 [(set (mem:SI (pre_dec:SI (reg:SI SP_REG)))
229 (match_operand:SI 0 "register_operand" ""))
230 (set (mem:SI (pre_dec:SI (reg:SI SP_REG)))
231 (match_operand:SI 1 "register_operand" ""))]
232 "TARGET_H8300S && !TARGET_NORMAL_MODE
233 && (REGNO_REG_CLASS (REGNO (operands[1])) == GENERAL_REGS
234 && REGNO (operands[1]) == REGNO (operands[0]) + 1
235 && (TARGET_H8300SX || (REGNO (operands[0]) & 1) == 0))"
236 [(parallel [(set (mem:SI (plus:SI (reg:SI SP_REG) (const_int -4)))
238 (set (mem:SI (plus:SI (reg:SI SP_REG) (const_int -8)))
241 (plus:SI (reg:SI SP_REG)
246 [(set (mem:SI (pre_dec:HI (reg:HI SP_REG)))
247 (match_operand:SI 0 "register_operand" ""))
248 (set (mem:SI (pre_dec:HI (reg:HI SP_REG)))
249 (match_operand:SI 1 "register_operand" ""))]
250 "TARGET_H8300S && TARGET_NORMAL_MODE
251 && (REGNO_REG_CLASS (REGNO (operands[1])) == GENERAL_REGS
252 && REGNO (operands[1]) == REGNO (operands[0]) + 1
253 && (TARGET_H8300SX || (REGNO (operands[0]) & 1) == 0))"
254 [(parallel [(set (mem:SI (plus:HI (reg:HI SP_REG) (const_int -4)))
256 (set (mem:SI (plus:HI (reg:HI SP_REG) (const_int -8)))
259 (plus:HI (reg:HI SP_REG)
266 ;; add.w r7,r0 (6 bytes)
271 ;; adds #2,r0 (4 bytes)
274 [(set (match_operand:HI 0 "register_operand" "")
275 (match_operand:HI 1 "const_int_operand" ""))
277 (plus:HI (match_dup 0)
278 (match_operand:HI 2 "register_operand" "")))]
279 "REG_P (operands[0]) && REG_P (operands[2])
280 && REGNO (operands[0]) != REGNO (operands[2])
281 && (satisfies_constraint_J (operands[1])
282 || satisfies_constraint_L (operands[1])
283 || satisfies_constraint_N (operands[1]))"
287 (plus:HI (match_dup 0)
295 ;; add.l er7,er0 (6 bytes)
300 ;; adds #4,er0 (4 bytes)
303 [(set (match_operand:SI 0 "register_operand" "")
304 (match_operand:SI 1 "const_int_operand" ""))
306 (plus:SI (match_dup 0)
307 (match_operand:SI 2 "register_operand" "")))]
308 "REG_P (operands[0]) && REG_P (operands[2])
309 && REGNO (operands[0]) != REGNO (operands[2])
310 && (satisfies_constraint_L (operands[1])
311 || satisfies_constraint_N (operands[1]))"
315 (plus:SI (match_dup 0)
322 ;; add.l #10,er0 (takes 8 bytes)
328 ;; add.l er7,er0 (takes 6 bytes)
331 [(set (match_operand:SI 0 "register_operand" "")
332 (match_operand:SI 1 "register_operand" ""))
334 (plus:SI (match_dup 0)
335 (match_operand:SI 2 "const_int_operand" "")))]
336 "operands[0] != stack_pointer_rtx
337 && REG_P (operands[0]) && REG_P (operands[1])
338 && REGNO (operands[0]) != REGNO (operands[1])
339 && !satisfies_constraint_L (operands[2])
340 && !satisfies_constraint_N (operands[2])
341 && ((INTVAL (operands[2]) & 0xff) == INTVAL (operands[2])
342 || (INTVAL (operands[2]) & 0xff00) == INTVAL (operands[2])
343 || INTVAL (operands[2]) == 0xffff
344 || INTVAL (operands[2]) == 0xfffe)"
348 (plus:SI (match_dup 0)
364 [(set (match_operand:HI 0 "register_operand" "")
365 (plus:HI (match_dup 0)
366 (match_operand 1 "incdec_operand" "")))
367 (set (cc0) (compare (match_dup 0)
370 (if_then_else (match_operator 3 "eqne_operator"
371 [(cc0) (const_int 0)])
372 (label_ref (match_operand 2 "" ""))
375 [(set (match_operand:HI 0 "register_operand" "")
376 (unspec:HI [(match_dup 0)
379 (set (cc0) (compare (match_dup 0)
382 (if_then_else (match_op_dup 3 [(cc0) (const_int 0)])
383 (label_ref (match_dup 2))
387 ;; The SImode version of the previous pattern.
390 [(set (match_operand:SI 0 "register_operand" "")
391 (plus:SI (match_dup 0)
392 (match_operand 1 "incdec_operand" "")))
393 (set (cc0) (compare (match_dup 0)
396 (if_then_else (match_operator 3 "eqne_operator"
397 [(cc0) (const_int 0)])
398 (label_ref (match_operand 2 "" ""))
401 [(set (match_operand:SI 0 "register_operand" "")
402 (unspec:SI [(match_dup 0)
405 (set (cc0) (compare (match_dup 0)
408 (if_then_else (match_op_dup 3 [(cc0) (const_int 0)])
409 (label_ref (match_dup 2))
414 [(parallel [(set (cc0)
415 (compare (zero_extract:SI (match_operand:QI 0 "register_operand" "")
419 (clobber (scratch:QI))])
421 (if_then_else (match_operator 1 "eqne_operator"
422 [(cc0) (const_int 0)])
423 (label_ref (match_operand 2 "" ""))
426 [(set (cc0) (compare (match_dup 0)
429 (if_then_else (match_op_dup 3 [(cc0) (const_int 0)])
430 (label_ref (match_dup 2))
433 operands[3] = ((GET_CODE (operands[1]) == EQ)
434 ? gen_rtx_GE (VOIDmode, cc0_rtx, const0_rtx)
435 : gen_rtx_LT (VOIDmode, cc0_rtx, const0_rtx));
438 ;; The next three peephole2's will try to transform
440 ;; mov.b A,r0l (or mov.l A,er0)
447 ;; and.b #CST,r0l (if CST is not 255)
450 [(set (match_operand:QI 0 "register_operand" "")
451 (match_operand:QI 1 "general_operand" ""))
452 (set (match_operand:SI 2 "register_operand" "")
453 (and:SI (match_dup 2)
455 "!reg_overlap_mentioned_p (operands[2], operands[1])
456 && REGNO (operands[0]) == REGNO (operands[2])"
459 (set (strict_low_part (match_dup 0))
464 [(set (match_operand:SI 0 "register_operand" "")
465 (match_operand:SI 1 "nonimmediate_operand" ""))
467 (and:SI (match_dup 0)
469 "!reg_overlap_mentioned_p (operands[0], operands[1])
470 && !(GET_CODE (operands[1]) == MEM && !offsettable_memref_p (operands[1]))
471 && !(GET_CODE (operands[1]) == MEM && MEM_VOLATILE_P (operands[1]))"
474 (set (strict_low_part (match_dup 2))
477 operands[2] = gen_lowpart (QImode, operands[0]);
478 operands[3] = gen_lowpart (QImode, operands[1]);
482 [(set (match_operand 0 "register_operand" "")
483 (match_operand 1 "nonimmediate_operand" ""))
484 (set (match_operand:SI 2 "register_operand" "")
485 (and:SI (match_dup 2)
486 (match_operand:SI 3 "const_int_qi_operand" "")))]
487 "(GET_MODE (operands[0]) == QImode
488 || GET_MODE (operands[0]) == HImode
489 || GET_MODE (operands[0]) == SImode)
490 && GET_MODE (operands[0]) == GET_MODE (operands[1])
491 && REGNO (operands[0]) == REGNO (operands[2])
492 && !reg_overlap_mentioned_p (operands[2], operands[1])
493 && !(GET_MODE (operands[1]) != QImode
494 && GET_CODE (operands[1]) == MEM
495 && !offsettable_memref_p (operands[1]))
496 && !(GET_MODE (operands[1]) != QImode
497 && GET_CODE (operands[1]) == MEM
498 && MEM_VOLATILE_P (operands[1]))"
501 (set (strict_low_part (match_dup 4))
504 (and:SI (match_dup 2)
507 operands[4] = gen_lowpart (QImode, operands[0]);
508 operands[5] = gen_lowpart (QImode, operands[1]);
509 operands[6] = GEN_INT (~0xff | INTVAL (operands[3]));
513 [(set (match_operand:SI 0 "register_operand" "")
514 (match_operand:SI 1 "register_operand" ""))
516 (and:SI (match_dup 0)
518 "!reg_overlap_mentioned_p (operands[0], operands[1])"
521 (set (zero_extract:SI (match_dup 0)
524 (lshiftrt:SI (match_dup 1)
528 ;; If a load of mem:SI is followed by an AND that turns off the upper
529 ;; half, then we can load mem:HI instead.
532 [(set (match_operand:SI 0 "register_operand" "")
533 (match_operand:SI 1 "memory_operand" ""))
535 (and:SI (match_dup 0)
536 (match_operand:SI 2 "const_int_operand" "")))]
537 "!MEM_VOLATILE_P (operands[1])
538 && offsettable_memref_p (operands[1])
539 && (INTVAL (operands[2]) & ~0xffff) == 0
540 && INTVAL (operands[2]) != 255"
544 (and:SI (match_dup 0)
547 operands[3] = gen_lowpart (HImode, operands[0]);
548 operands[4] = gen_lowpart (HImode, operands[1]);
551 ;; Convert a memory comparison to a move if there is a scratch register.
554 [(match_scratch:QHSI 1 "r")
556 (compare (match_operand:QHSI 0 "memory_operand" "")
561 (set (cc0) (compare (match_dup 1)
565 ;; (compare (reg:HI) (const_int)) takes 4 bytes, so we try to achieve
566 ;; the equivalent with shorter sequences. Here is the summary. Cases
567 ;; are grouped for each define_peephole2.
569 ;; reg const_int use insn
570 ;; --------------------------------------------------------
571 ;; dead -2 eq/ne inc.l
572 ;; dead -1 eq/ne inc.l
573 ;; dead 1 eq/ne dec.l
574 ;; dead 2 eq/ne dec.l
576 ;; dead 1 ge/lt shar.l
577 ;; dead 3 (H8S) ge/lt shar.l
579 ;; dead 1 geu/ltu shar.l
580 ;; dead 3 (H8S) geu/ltu shar.l
582 ;; ---- 255 ge/lt mov.b
584 ;; ---- 255 geu/ltu mov.b
598 (compare (match_operand:HI 0 "register_operand" "")
599 (match_operand:HI 1 "incdec_operand" "")))
601 (if_then_else (match_operator 3 "eqne_operator"
602 [(cc0) (const_int 0)])
603 (label_ref (match_operand 2 "" ""))
605 "INTVAL (operands[1]) != 0 && peep2_reg_dead_p (1, operands[0])"
607 (unspec:HI [(match_dup 0)
610 (set (cc0) (compare (match_dup 0)
613 (if_then_else (match_op_dup 3 [(cc0) (const_int 0)])
614 (label_ref (match_dup 2))
617 operands[4] = GEN_INT (- INTVAL (operands[1]));
632 (compare (match_operand:HI 0 "register_operand" "")
633 (match_operand:HI 1 "const_int_operand" "")))
635 (if_then_else (match_operator 2 "gtle_operator"
636 [(cc0) (const_int 0)])
637 (label_ref (match_operand 3 "" ""))
639 "peep2_reg_dead_p (1, operands[0])
640 && (INTVAL (operands[1]) == 1
641 || (TARGET_H8300S && INTVAL (operands[1]) == 3))"
642 [(parallel [(set (match_dup 0)
643 (ashiftrt:HI (match_dup 0)
645 (clobber (scratch:QI))])
646 (set (cc0) (compare (match_dup 0)
649 (if_then_else (match_dup 2)
650 (label_ref (match_dup 3))
653 operands[4] = GEN_INT (exact_log2 (INTVAL (operands[1]) + 1));
668 (compare (match_operand:HI 0 "register_operand" "")
669 (match_operand:HI 1 "const_int_operand" "")))
671 (if_then_else (match_operator 2 "gtuleu_operator"
672 [(cc0) (const_int 0)])
673 (label_ref (match_operand 3 "" ""))
675 "peep2_reg_dead_p (1, operands[0])
676 && (INTVAL (operands[1]) == 1
677 || (TARGET_H8300S && INTVAL (operands[1]) == 3))"
678 [(parallel [(set (match_dup 0)
679 (ashiftrt:HI (match_dup 0)
681 (clobber (scratch:QI))])
682 (set (cc0) (compare (match_dup 0)
685 (if_then_else (match_dup 5)
686 (label_ref (match_dup 3))
689 operands[4] = GEN_INT (exact_log2 (INTVAL (operands[1]) + 1));
690 operands[5] = gen_rtx_fmt_ee (GET_CODE (operands[2]) == GTU ? NE : EQ,
691 VOIDmode, cc0_rtx, const0_rtx);
706 (compare (match_operand:HI 0 "register_operand" "")
709 (if_then_else (match_operator 1 "gtle_operator"
710 [(cc0) (const_int 0)])
711 (label_ref (match_operand 2 "" ""))
714 [(set (cc0) (compare (and:HI (match_dup 0)
718 (if_then_else (match_dup 1)
719 (label_ref (match_dup 2))
735 (compare (match_operand:HI 0 "register_operand" "")
738 (if_then_else (match_operator 1 "gtuleu_operator"
739 [(cc0) (const_int 0)])
740 (label_ref (match_operand 2 "" ""))
743 [(set (cc0) (compare (and:HI (match_dup 0)
747 (if_then_else (match_dup 3)
748 (label_ref (match_dup 2))
751 operands[3] = gen_rtx_fmt_ee (GET_CODE (operands[1]) == GTU ? NE : EQ,
752 VOIDmode, cc0_rtx, const0_rtx);
755 ;; (compare (reg:SI) (const_int)) takes 6 bytes, so we try to achieve
756 ;; the equivalent with shorter sequences. Here is the summary. Cases
757 ;; are grouped for each define_peephole2.
759 ;; reg const_int use insn
760 ;; --------------------------------------------------------
761 ;; live -2 eq/ne copy and inc.l
762 ;; live -1 eq/ne copy and inc.l
763 ;; live 1 eq/ne copy and dec.l
764 ;; live 2 eq/ne copy and dec.l
766 ;; dead -2 eq/ne inc.l
767 ;; dead -1 eq/ne inc.l
768 ;; dead 1 eq/ne dec.l
769 ;; dead 2 eq/ne dec.l
771 ;; dead -131072 eq/ne inc.w and test
772 ;; dead -65536 eq/ne inc.w and test
773 ;; dead 65536 eq/ne dec.w and test
774 ;; dead 131072 eq/ne dec.w and test
776 ;; dead 0x000000?? except 1 and 2 eq/ne xor.b and test
777 ;; dead 0x0000??00 eq/ne xor.b and test
778 ;; dead 0x0000ffff eq/ne not.w and test
780 ;; dead 0xffffff?? except -1 and -2 eq/ne xor.b and not.l
781 ;; dead 0xffff??ff eq/ne xor.b and not.l
782 ;; dead 0x40000000 (H8S) eq/ne rotl.l and dec.l
783 ;; dead 0x80000000 eq/ne rotl.l and dec.l
785 ;; live 1 ge/lt copy and shar.l
786 ;; live 3 (H8S) ge/lt copy and shar.l
788 ;; live 1 geu/ltu copy and shar.l
789 ;; live 3 (H8S) geu/ltu copy and shar.l
791 ;; dead 1 ge/lt shar.l
792 ;; dead 3 (H8S) ge/lt shar.l
794 ;; dead 1 geu/ltu shar.l
795 ;; dead 3 (H8S) geu/ltu shar.l
797 ;; dead 3 (H8/300H) ge/lt and.b and test
798 ;; dead 7 ge/lt and.b and test
799 ;; dead 15 ge/lt and.b and test
800 ;; dead 31 ge/lt and.b and test
801 ;; dead 63 ge/lt and.b and test
802 ;; dead 127 ge/lt and.b and test
803 ;; dead 255 ge/lt and.b and test
805 ;; dead 3 (H8/300H) geu/ltu and.b and test
806 ;; dead 7 geu/ltu and.b and test
807 ;; dead 15 geu/ltu and.b and test
808 ;; dead 31 geu/ltu and.b and test
809 ;; dead 63 geu/ltu and.b and test
810 ;; dead 127 geu/ltu and.b and test
811 ;; dead 255 geu/ltu and.b and test
813 ;; ---- 65535 ge/lt mov.w
815 ;; ---- 65535 geu/ltu mov.w
829 (compare (match_operand:SI 0 "register_operand" "")
830 (match_operand:SI 1 "incdec_operand" "")))
832 (if_then_else (match_operator 3 "eqne_operator"
833 [(cc0) (const_int 0)])
834 (label_ref (match_operand 2 "" ""))
836 "INTVAL (operands[1]) != 0 && peep2_reg_dead_p (1, operands[0])"
838 (unspec:SI [(match_dup 0)
841 (set (cc0) (compare (match_dup 0)
844 (if_then_else (match_op_dup 3 [(cc0) (const_int 0)])
845 (label_ref (match_dup 2))
848 operands[4] = GEN_INT (- INTVAL (operands[1]));
863 (compare (match_operand:SI 0 "register_operand" "")
864 (match_operand:SI 1 "const_int_operand" "")))
866 (if_then_else (match_operator 3 "eqne_operator"
867 [(cc0) (const_int 0)])
868 (label_ref (match_operand 2 "" ""))
870 "peep2_reg_dead_p (1, operands[0])
871 && (INTVAL (operands[1]) == -131072
872 || INTVAL (operands[1]) == -65536
873 || INTVAL (operands[1]) == 65536
874 || INTVAL (operands[1]) == 131072)"
876 (plus:SI (match_dup 0)
878 (set (cc0) (compare (match_dup 0)
881 (if_then_else (match_op_dup 3 [(cc0) (const_int 0)])
882 (label_ref (match_dup 2))
885 operands[4] = GEN_INT (- INTVAL (operands[1]));
901 (compare (match_operand:SI 0 "register_operand" "")
902 (match_operand:SI 1 "const_int_operand" "")))
904 (if_then_else (match_operator 3 "eqne_operator"
905 [(cc0) (const_int 0)])
906 (label_ref (match_operand 2 "" ""))
908 "peep2_reg_dead_p (1, operands[0])
909 && ((INTVAL (operands[1]) & 0x00ff) == INTVAL (operands[1])
910 || (INTVAL (operands[1]) & 0xff00) == INTVAL (operands[1])
911 || INTVAL (operands[1]) == 0x0000ffff)
912 && INTVAL (operands[1]) != 0
913 && INTVAL (operands[1]) != 1
914 && INTVAL (operands[1]) != 2"
916 (xor:SI (match_dup 0)
918 (set (cc0) (compare (match_dup 0)
921 (if_then_else (match_op_dup 3 [(cc0) (const_int 0)])
922 (label_ref (match_dup 2))
939 (compare (match_operand:SI 0 "register_operand" "")
940 (match_operand:SI 1 "const_int_operand" "")))
942 (if_then_else (match_operator 3 "eqne_operator"
943 [(cc0) (const_int 0)])
944 (label_ref (match_operand 2 "" ""))
946 "peep2_reg_dead_p (1, operands[0])
947 && ((INTVAL (operands[1]) | 0x00ff) == -1
948 || (INTVAL (operands[1]) | 0xff00) == -1)
949 && INTVAL (operands[1]) != -1
950 && INTVAL (operands[1]) != -2"
952 (xor:SI (match_dup 0)
955 (not:SI (match_dup 0)))
956 (set (cc0) (compare (match_dup 0)
959 (if_then_else (match_op_dup 3 [(cc0) (const_int 0)])
960 (label_ref (match_dup 2))
963 operands[4] = GEN_INT (INTVAL (operands[1]) ^ -1);
968 ;; cmp.l #-2147483648,er0
979 (compare (match_operand:SI 0 "register_operand" "")
980 (match_operand:SI 1 "const_int_operand" "")))
982 (if_then_else (match_operator 3 "eqne_operator"
983 [(cc0) (const_int 0)])
984 (label_ref (match_operand 2 "" ""))
986 "peep2_reg_dead_p (1, operands[0])
987 && (INTVAL (operands[1]) == -2147483647 - 1
988 || (TARGET_H8300S && INTVAL (operands[1]) == 1073741824))"
990 (rotate:SI (match_dup 0)
993 (unspec:SI [(match_dup 0)
996 (set (cc0) (compare (match_dup 0)
999 (if_then_else (match_op_dup 3 [(cc0) (const_int 0)])
1000 (label_ref (match_dup 2))
1003 operands[4] = GEN_INT (INTVAL (operands[1]) == -2147483647 - 1 ? 1 : 2);
1017 ;; We avoid this transformation if we see more than one copy of the
1018 ;; same compare insn immediately before this one.
1021 [(match_scratch:SI 4 "r")
1023 (compare (match_operand:SI 0 "register_operand" "")
1024 (match_operand:SI 1 "const_int_operand" "")))
1026 (if_then_else (match_operator 2 "gtle_operator"
1027 [(cc0) (const_int 0)])
1028 (label_ref (match_operand 3 "" ""))
1030 "!peep2_reg_dead_p (1, operands[0])
1031 && (INTVAL (operands[1]) == 1
1032 || (TARGET_H8300S && INTVAL (operands[1]) == 3))
1033 && !same_cmp_preceding_p (insn)"
1036 (parallel [(set (match_dup 4)
1037 (ashiftrt:SI (match_dup 4)
1039 (clobber (scratch:QI))])
1040 (set (cc0) (compare (match_dup 4)
1043 (if_then_else (match_dup 2)
1044 (label_ref (match_dup 3))
1047 operands[5] = GEN_INT (exact_log2 (INTVAL (operands[1]) + 1));
1061 ;; We avoid this transformation if we see more than one copy of the
1062 ;; same compare insn immediately before this one.
1065 [(match_scratch:SI 4 "r")
1067 (compare (match_operand:SI 0 "register_operand" "")
1068 (match_operand:SI 1 "const_int_operand" "")))
1070 (if_then_else (match_operator 2 "gtuleu_operator"
1071 [(cc0) (const_int 0)])
1072 (label_ref (match_operand 3 "" ""))
1074 "!peep2_reg_dead_p (1, operands[0])
1075 && (INTVAL (operands[1]) == 1
1076 || (TARGET_H8300S && INTVAL (operands[1]) == 3))
1077 && !same_cmp_preceding_p (insn)"
1080 (parallel [(set (match_dup 4)
1081 (ashiftrt:SI (match_dup 4)
1083 (clobber (scratch:QI))])
1084 (set (cc0) (compare (match_dup 4)
1087 (if_then_else (match_dup 6)
1088 (label_ref (match_dup 3))
1091 operands[5] = GEN_INT (exact_log2 (INTVAL (operands[1]) + 1));
1092 operands[6] = gen_rtx_fmt_ee (GET_CODE (operands[2]) == GTU ? NE : EQ,
1093 VOIDmode, cc0_rtx, const0_rtx);
1108 (compare (match_operand:SI 0 "register_operand" "")
1109 (match_operand:SI 1 "const_int_operand" "")))
1111 (if_then_else (match_operator 2 "gtle_operator"
1112 [(cc0) (const_int 0)])
1113 (label_ref (match_operand 3 "" ""))
1115 "peep2_reg_dead_p (1, operands[0])
1116 && (INTVAL (operands[1]) == 1
1117 || (TARGET_H8300S && INTVAL (operands[1]) == 3))"
1118 [(parallel [(set (match_dup 0)
1119 (ashiftrt:SI (match_dup 0)
1121 (clobber (scratch:QI))])
1122 (set (cc0) (compare (match_dup 0)
1125 (if_then_else (match_dup 2)
1126 (label_ref (match_dup 3))
1129 operands[4] = GEN_INT (exact_log2 (INTVAL (operands[1]) + 1));
1144 (compare (match_operand:SI 0 "register_operand" "")
1145 (match_operand:SI 1 "const_int_operand" "")))
1147 (if_then_else (match_operator 2 "gtuleu_operator"
1148 [(cc0) (const_int 0)])
1149 (label_ref (match_operand 3 "" ""))
1151 "peep2_reg_dead_p (1, operands[0])
1152 && (INTVAL (operands[1]) == 1
1153 || (TARGET_H8300S && INTVAL (operands[1]) == 3))"
1154 [(parallel [(set (match_dup 0)
1155 (ashiftrt:SI (match_dup 0)
1157 (clobber (scratch:QI))])
1158 (set (cc0) (compare (match_dup 0)
1161 (if_then_else (match_dup 5)
1162 (label_ref (match_dup 3))
1165 operands[4] = GEN_INT (exact_log2 (INTVAL (operands[1]) + 1));
1166 operands[5] = gen_rtx_fmt_ee (GET_CODE (operands[2]) == GTU ? NE : EQ,
1167 VOIDmode, cc0_rtx, const0_rtx);
1183 (compare (match_operand:SI 0 "register_operand" "")
1184 (match_operand:SI 1 "const_int_operand" "")))
1186 (if_then_else (match_operator 2 "gtle_operator"
1187 [(cc0) (const_int 0)])
1188 (label_ref (match_operand 3 "" ""))
1190 "peep2_reg_dead_p (1, operands[0])
1191 && (INTVAL (operands[1]) == 3
1192 || INTVAL (operands[1]) == 7
1193 || INTVAL (operands[1]) == 15
1194 || INTVAL (operands[1]) == 31
1195 || INTVAL (operands[1]) == 63
1196 || INTVAL (operands[1]) == 127
1197 || INTVAL (operands[1]) == 255)"
1199 (and:SI (match_dup 0)
1201 (set (cc0) (compare (match_dup 0)
1204 (if_then_else (match_dup 2)
1205 (label_ref (match_dup 3))
1208 operands[4] = GEN_INT (~INTVAL (operands[1]));
1224 (compare (match_operand:SI 0 "register_operand" "")
1225 (match_operand:SI 1 "const_int_operand" "")))
1227 (if_then_else (match_operator 2 "gtuleu_operator"
1228 [(cc0) (const_int 0)])
1229 (label_ref (match_operand 3 "" ""))
1231 "peep2_reg_dead_p (1, operands[0])
1232 && ((TARGET_H8300H && INTVAL (operands[1]) == 3)
1233 || INTVAL (operands[1]) == 7
1234 || INTVAL (operands[1]) == 15
1235 || INTVAL (operands[1]) == 31
1236 || INTVAL (operands[1]) == 63
1237 || INTVAL (operands[1]) == 127
1238 || INTVAL (operands[1]) == 255)"
1240 (and:SI (match_dup 0)
1242 (set (cc0) (compare (match_dup 0)
1245 (if_then_else (match_dup 5)
1246 (label_ref (match_dup 3))
1249 operands[4] = GEN_INT (~INTVAL (operands[1]));
1250 operands[5] = gen_rtx_fmt_ee (GET_CODE (operands[2]) == GTU ? NE : EQ,
1251 VOIDmode, cc0_rtx, const0_rtx);
1266 (compare (match_operand:SI 0 "register_operand" "")
1269 (if_then_else (match_operator 1 "gtle_operator"
1270 [(cc0) (const_int 0)])
1271 (label_ref (match_operand 2 "" ""))
1274 [(set (cc0) (compare (and:SI (match_dup 0)
1278 (if_then_else (match_dup 1)
1279 (label_ref (match_dup 2))
1295 (compare (match_operand:SI 0 "register_operand" "")
1298 (if_then_else (match_operator 1 "gtuleu_operator"
1299 [(cc0) (const_int 0)])
1300 (label_ref (match_operand 2 "" ""))
1303 [(set (cc0) (compare (and:SI (match_dup 0)
1307 (if_then_else (match_dup 3)
1308 (label_ref (match_dup 2))
1311 operands[3] = gen_rtx_fmt_ee (GET_CODE (operands[1]) == GTU ? NE : EQ,
1312 VOIDmode, cc0_rtx, const0_rtx);
1326 ;; We avoid this transformation if we see more than one copy of the
1327 ;; same compare insn.
1330 [(match_scratch:SI 4 "r")
1332 (compare (match_operand:SI 0 "register_operand" "")
1333 (match_operand:SI 1 "incdec_operand" "")))
1335 (if_then_else (match_operator 3 "eqne_operator"
1336 [(cc0) (const_int 0)])
1337 (label_ref (match_operand 2 "" ""))
1339 "INTVAL (operands[1]) != 0
1340 && !peep2_reg_dead_p (1, operands[0])
1341 && !same_cmp_following_p (insn)"
1345 (unspec:SI [(match_dup 4)
1348 (set (cc0) (compare (match_dup 4)
1351 (if_then_else (match_op_dup 3 [(cc0) (const_int 0)])
1352 (label_ref (match_dup 2))
1355 operands[5] = GEN_INT (- INTVAL (operands[1]));
1358 ;; Narrow the mode of testing if possible.
1361 [(set (match_operand:HSI 0 "register_operand" "")
1362 (and:HSI (match_dup 0)
1363 (match_operand:HSI 1 "const_int_operand" "")))
1364 (set (cc0) (compare (match_dup 0)
1367 (if_then_else (match_operator 3 "eqne_operator"
1368 [(cc0) (const_int 0)])
1369 (label_ref (match_operand 2 "" ""))
1371 "((const_int_qi_operand (operands[1], QImode)
1372 || (GET_MODE (operands[0]) == SImode
1373 && const_int_hi_operand (operands[1], HImode)))
1374 && peep2_reg_dead_p (2, operands[0]))"
1375 [(set (match_dup 4) (match_dup 6))
1376 (set (cc0) (compare (match_dup 4)
1379 (if_then_else (match_op_dup 3 [(cc0) (const_int 0)])
1380 (label_ref (match_dup 2))
1383 enum machine_mode mode;
1385 mode = const_int_qi_operand (operands[1], QImode) ? QImode : HImode;
1386 operands[4] = gen_rtx_REG (mode, REGNO (operands[0]));
1387 operands[5] = gen_int_mode (INTVAL (operands[1]), mode);
1388 operands[6] = gen_rtx_AND (mode, operands[4], operands[5]);
1391 ;; These triggers right at the end of allocation of locals in the
1392 ;; prologue (and possibly at other places).
1394 ;; stack adjustment of -4, generate one push
1400 [(set (reg:SI SP_REG)
1401 (plus:SI (reg:SI SP_REG)
1403 (set (mem:SFI (reg:SI SP_REG))
1404 (match_operand:SFI 0 "register_operand" ""))]
1405 "!TARGET_NORMAL_MODE && REGNO (operands[0]) != SP_REG"
1406 [(set (mem:SFI (pre_dec:SI (reg:SI SP_REG)))
1409 ;; stack adjustment of -8, generate one push
1415 [(set (reg:SI SP_REG)
1416 (plus:SI (reg:SI SP_REG)
1418 (set (mem:SFI (reg:SI SP_REG))
1419 (match_operand:SFI 0 "register_operand" ""))]
1420 "!TARGET_NORMAL_MODE && REGNO (operands[0]) != SP_REG"
1421 [(set (reg:SI SP_REG)
1422 (plus:SI (reg:SI SP_REG)
1424 (set (mem:SFI (pre_dec:SI (reg:SI SP_REG)))
1427 ;; stack adjustment of -12, generate one push
1429 ;; before : 10 bytes
1433 [(set (reg:SI SP_REG)
1434 (plus:SI (reg:SI SP_REG)
1436 (set (mem:SFI (reg:SI SP_REG))
1437 (match_operand:SFI 0 "register_operand" ""))]
1438 "!TARGET_NORMAL_MODE && REGNO (operands[0]) != SP_REG"
1439 [(set (reg:SI SP_REG)
1440 (plus:SI (reg:SI SP_REG)
1442 (set (reg:SI SP_REG)
1443 (plus:SI (reg:SI SP_REG)
1445 (set (mem:SFI (pre_dec:SI (reg:SI SP_REG)))
1458 ;; if "reg" dies at the end of the sequence.
1461 [(set (match_operand 0 "register_operand" "")
1462 (match_operand 1 "memory_operand" ""))
1464 (match_operator 2 "h8sx_unary_memory_operator"
1466 (set (match_operand 3 "memory_operand" "")
1469 && peep2_reg_dead_p (3, operands[0])
1470 && !reg_overlap_mentioned_p (operands[0], operands[3])
1471 && h8sx_mergeable_memrefs_p (operands[3], operands[1])"
1475 operands[4] = shallow_copy_rtx (operands[2]);
1476 XEXP (operands[4], 0) = operands[1];
1488 ;; if "reg" dies in the comparison.
1491 [(set (match_operand 0 "register_operand" "")
1492 (match_operand 1 "h8300_dst_operand" ""))
1494 (compare (match_dup 0)
1495 (match_operand 2 "h8300_src_operand" "")))]
1497 && peep2_reg_dead_p (2, operands[0])
1498 && !reg_overlap_mentioned_p (operands[0], operands[2])
1499 && operands[2] != const0_rtx"
1501 (compare (match_dup 1)
1504 ;; Likewise for the second operand.
1507 [(set (match_operand 0 "register_operand" "")
1508 (match_operand 1 "h8300_src_operand" ""))
1510 (compare (match_operand 2 "h8300_dst_operand" "")
1513 && peep2_reg_dead_p (2, operands[0])
1514 && !reg_overlap_mentioned_p (operands[0], operands[2])"
1516 (compare (match_dup 2)
1519 ;; Combine two moves.
1522 [(set (match_operand 0 "register_operand" "")
1523 (match_operand 1 "h8300_src_operand" ""))
1524 (set (match_operand 2 "h8300_dst_operand" "")
1527 && peep2_reg_dead_p (2, operands[0])
1528 && !reg_overlap_mentioned_p (operands[0], operands[2])"