1 ;; Peephole optimizations for RISC-V for GNU compiler.
2 ;; Copyright (C) 2011-2024 Free Software Foundation, Inc.
3 ;; Contributed by Andrew Waterman (andrew@sifive.com).
5 ;; This file is part of GCC.
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 3, or (at your option)
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 COPYING3. If not see
19 ;; <http://www.gnu.org/licenses/>.
21 ;; Simplify (unsigned long)(unsigned int)a << const
23 [(set (match_operand:DI 0 "register_operand")
24 (ashift:DI (match_operand:DI 1 "register_operand")
25 (match_operand 2 "const_int_operand")))
26 (set (match_operand:DI 3 "register_operand")
27 (lshiftrt:DI (match_dup 0) (match_dup 2)))
28 (set (match_operand:DI 4 "register_operand")
29 (ashift:DI (match_dup 3) (match_operand 5 "const_int_operand")))]
31 && INTVAL (operands[5]) < INTVAL (operands[2])
32 && (REGNO (operands[3]) == REGNO (operands[4])
33 || peep2_reg_dead_p (3, operands[3]))"
35 (ashift:DI (match_dup 1) (match_dup 2)))
37 (lshiftrt:DI (match_dup 0) (match_operand 5)))]
39 operands[5] = GEN_INT (INTVAL (operands[2]) - INTVAL (operands[5]));
44 [(set (match_operand:X 0 "a0a1_reg_operand")
45 (match_operand:X 1 "zcmp_mv_sreg_operand"))
46 (set (match_operand:X 2 "a0a1_reg_operand")
47 (match_operand:X 3 "zcmp_mv_sreg_operand"))]
49 && (REGNO (operands[2]) != REGNO (operands[0]))"
50 [(parallel [(set (match_dup 0)
57 [(set (match_operand:X 0 "zcmp_mv_sreg_operand")
58 (match_operand:X 1 "a0a1_reg_operand"))
59 (set (match_operand:X 2 "zcmp_mv_sreg_operand")
60 (match_operand:X 3 "a0a1_reg_operand"))]
62 && (REGNO (operands[0]) != REGNO (operands[2]))
63 && (REGNO (operands[1]) != REGNO (operands[3]))"
64 [(parallel [(set (match_dup 0)