1;; Peephole optimizations for RISC-V for GNU compiler. 2;; Copyright (C) 2011-2019 Free Software Foundation, Inc. 3;; Contributed by Andrew Waterman (andrew@sifive.com). 4 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 3, or (at your option) 10;; any later version. 11 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. 16 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/>. 20 21;; Simplify (unsigned long)(unsigned int)a << const 22(define_peephole2 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")))] 30 "TARGET_64BIT 31 && INTVAL (operands[5]) < INTVAL (operands[2]) 32 && (REGNO (operands[3]) == REGNO (operands[4]) 33 || peep2_reg_dead_p (3, operands[3]))" 34 [(set (match_dup 0) 35 (ashift:DI (match_dup 1) (match_dup 2))) 36 (set (match_dup 4) 37 (lshiftrt:DI (match_dup 0) (match_operand 5)))] 38{ 39 operands[5] = GEN_INT (INTVAL (operands[2]) - INTVAL (operands[5])); 40}) 41