| 1 |
;; Machine description for short forward branches(SFB). |
| 2 |
;; Copyright (C) 2023-2025 Free Software Foundation, Inc. |
| 3 |
|
| 4 |
;; This file is part of GCC. |
| 5 |
|
| 6 |
;; GCC is free software; you can redistribute it and/or modify |
| 7 |
;; it under the terms of the GNU General Public License as published by |
| 8 |
;; the Free Software Foundation; either version 3, or (at your option) |
| 9 |
;; any later version. |
| 10 |
|
| 11 |
;; GCC is distributed in the hope that it will be useful, |
| 12 |
;; but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 |
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 14 |
;; GNU General Public License for more details. |
| 15 |
|
| 16 |
;; You should have received a copy of the GNU General Public License |
| 17 |
;; along with GCC; see the file COPYING3. If not see |
| 18 |
;; <http://www.gnu.org/licenses/>. |
| 19 |
|
| 20 |
|
| 21 |
;; Patterns for implementations that optimize short forward branches. |
| 22 |
|
| 23 |
(define_insn "*mov<GPR:mode><X:mode>cc" |
| 24 |
[(set (match_operand:GPR 0 "register_operand" "=r,r") |
| 25 |
(if_then_else:GPR |
| 26 |
(match_operator 5 "ordered_comparison_operator" |
| 27 |
[(match_operand:X 1 "register_operand" "r,r") |
| 28 |
(match_operand:X 2 "reg_or_0_operand" "rJ,rJ")]) |
| 29 |
(match_operand:GPR 3 "register_operand" "0,0") |
| 30 |
(match_operand:GPR 4 "sfb_alu_operand" "rJ,IL")))] |
| 31 |
"TARGET_SFB_ALU" |
| 32 |
"@ |
| 33 |
b%C5\t%1,%z2,1f\t# movcc\;mv\t%0,%z4\n1: |
| 34 |
b%C5\t%1,%z2,1f\t# movcc\;li\t%0,%4\n1:" |
| 35 |
[(set_attr "length" "8") |
| 36 |
(set_attr "type" "sfb_alu") |
| 37 |
(set_attr "mode" "<GPR:MODE>")]) |
| 38 |
|
| 39 |
;; Combine creates this form ((typeof(y))zero_one * z) <op> y |
| 40 |
;; for SiFive short forward branches. |
| 41 |
|
| 42 |
(define_split |
| 43 |
[(set (match_operand:X 0 "register_operand") |
| 44 |
(and:X (sign_extract:X (match_operand:X 1 "register_operand") |
| 45 |
(const_int 1) |
| 46 |
(match_operand 2 "immediate_operand")) |
| 47 |
(match_operand:X 3 "register_operand"))) |
| 48 |
(clobber (match_operand:X 4 "register_operand"))] |
| 49 |
"TARGET_SFB_ALU" |
| 50 |
[(set (match_dup 4) (zero_extract:X (match_dup 1) (const_int 1) (match_dup 2))) |
| 51 |
(set (match_dup 0) (if_then_else:X (ne (match_dup 4) (const_int 0)) |
| 52 |
(match_dup 3) |
| 53 |
(const_int 0)))]) |
| 54 |
|
| 55 |
(define_split |
| 56 |
[(set (match_operand:X 0 "register_operand") |
| 57 |
(and:X (sign_extract:X (match_operand:X 1 "register_operand") |
| 58 |
(const_int 1) |
| 59 |
(match_operand 2 "immediate_operand")) |
| 60 |
(match_operand:X 3 "register_operand"))) |
| 61 |
(clobber (match_operand:X 4 "register_operand"))] |
| 62 |
"TARGET_SFB_ALU && (UINTVAL (operands[2]) < 11)" |
| 63 |
[(set (match_dup 4) (and:X (match_dup 1) (match_dup 2))) |
| 64 |
(set (match_dup 0) (if_then_else:X (ne (match_dup 4) (const_int 0)) |
| 65 |
(match_dup 3) |
| 66 |
(const_int 0)))] |
| 67 |
{ |
| 68 |
operands[2] = GEN_INT (1 << UINTVAL(operands[2])); |
| 69 |
}) |