From patchwork Fri Apr 28 06:12:10 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Christoph_M=C3=BCllner?= X-Patchwork-Id: 68437 X-Patchwork-Delegate: kito.cheng@gmail.com Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 134393854142 for ; Fri, 28 Apr 2023 06:13:20 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-ed1-x52a.google.com (mail-ed1-x52a.google.com [IPv6:2a00:1450:4864:20::52a]) by sourceware.org (Postfix) with ESMTPS id B7140385843A for ; Fri, 28 Apr 2023 06:12:28 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org B7140385843A Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=vrull.eu Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=vrull.eu Received: by mail-ed1-x52a.google.com with SMTP id 4fb4d7f45d1cf-505035e3368so16368566a12.0 for ; Thu, 27 Apr 2023 23:12:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=vrull.eu; s=google; t=1682662347; x=1685254347; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=AOMvpaRB7JwuHoTJjmK0Tm82n/ZGehm3uadhCC4HgV0=; b=TIhL1+KErLFHtstqa90KGLiYUOrwbqxe5NhB/eQOTs5Sjw7eX+5sIj9R5BOS84HRMf zbal5kGMn0eVoKRwaCxm5D++WYsWhkh0qrg76VpkG5OwW7eFZCAzghzKM0XePwAcgcm2 Ep7GOvoOkDkfnUq1koZ/lkFgYEjOAFjJGEsi2Hj4OPRoNdj6VZpMDxlbh08vf7LOEIoN l8wY73tchcwdB0X1qF78/7dPQbW6SQV4BJaP0Xs2lfaBft7igpBdiYVnz60yhygsj3Bh /vRatcCE9QoFfwn1yRWbeo7+LaEKXj03lXRKHntENNNvr9ftk7YwQh0kP+fmayvQGW/J YveQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1682662347; x=1685254347; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=AOMvpaRB7JwuHoTJjmK0Tm82n/ZGehm3uadhCC4HgV0=; b=jGn+JVQp5WZRBDK5vI0YSE/xhcizeb0e6rZF7MH8ZAC8TtlRGk9Uy1paYlAA5kM98M YsTtAEkgpCE5pTXnZzfMqUv1NWP3NLlvLwDw23E48mVp1HBZiFzavoNgEMdUWceo9h1Z AI9+mqlF6IHuyDeSxiCqSiBe5msTVChMyzp5FmKuEzVgLjkwLSPKj9HQLq6nIme0sk2V 0onWF4HDQpsj+MAVDR+GYs5tHicvvtz6XEy8/XJrB08TmTfG7kN3YtLrHzHeuuHvJGhQ VmF35l6i2v3p9uq7MomO3Z2he16+f/0NIS3i89YbWqjRzEjFEAOcpKhf5OlgAydKxwWK Cccw== X-Gm-Message-State: AC+VfDwTrsmmdnSos/5K3Z/Lb2NlKZROz11WY7fGl+2MHMoY+/ZuLhhG ZCR+Z+RSDO2rsjUQ0Tu/sJpt0ZvldmHdy1PApz4= X-Google-Smtp-Source: ACHHUZ57xATjyljv6MpVhXVdx7j8oB4G+UvaDBzjfQkJ2ICxRBRaIR6H26blnOdxTTyXUkDgyu0Lqg== X-Received: by 2002:aa7:d6cf:0:b0:509:f490:2968 with SMTP id x15-20020aa7d6cf000000b00509f4902968mr3650893edr.11.1682662346954; Thu, 27 Apr 2023 23:12:26 -0700 (PDT) Received: from beast.fritz.box (62-178-148-172.cable.dynamic.surfer.at. [62.178.148.172]) by smtp.gmail.com with ESMTPSA id x20-20020aa7d394000000b00504803f4071sm8669431edq.44.2023.04.27.23.12.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 27 Apr 2023 23:12:26 -0700 (PDT) From: Christoph Muellner To: gcc-patches@gcc.gnu.org, Kito Cheng , Jim Wilson , Palmer Dabbelt , Andrew Waterman , Philipp Tomsich , Cooper Qu , Lifang Xia , Yunhai Shang , Zhiwei Liu Cc: =?utf-8?q?Christoph_M=C3=BCllner?= Subject: [PATCH 09/11] riscv: thead: Factor out XThead*-specific peepholes Date: Fri, 28 Apr 2023 08:12:10 +0200 Message-Id: <20230428061210.2988035-10-christoph.muellner@vrull.eu> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230428061210.2988035-1-christoph.muellner@vrull.eu> References: <20230428061210.2988035-1-christoph.muellner@vrull.eu> MIME-Version: 1.0 X-Spam-Status: No, score=-12.7 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, JMQ_SPF_NEUTRAL, KAM_MANYTO, KAM_SHORT, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gcc-patches-bounces+patchwork=sourceware.org@gcc.gnu.org Sender: "Gcc-patches" From: Christoph Müllner This patch moves the XThead*-specific peephole passes into thead-peephole.md with the intend to keep vendor-specific code separated from RISC-V standard code. This patch does not contain any functional changes. gcc/ChangeLog: * config/riscv/peephole.md: Remove XThead* peephole passes. * config/riscv/thead.md: Include thead-peephole.md. * config/riscv/thead-peephole.md: New file. Signed-off-by: Christoph Müllner --- gcc/config/riscv/peephole.md | 56 ---------------------- gcc/config/riscv/thead-peephole.md | 74 ++++++++++++++++++++++++++++++ gcc/config/riscv/thead.md | 2 + 3 files changed, 76 insertions(+), 56 deletions(-) create mode 100644 gcc/config/riscv/thead-peephole.md diff --git a/gcc/config/riscv/peephole.md b/gcc/config/riscv/peephole.md index 67e7046d7e6..0ef0c04410b 100644 --- a/gcc/config/riscv/peephole.md +++ b/gcc/config/riscv/peephole.md @@ -38,59 +38,3 @@ (define_peephole2 { operands[5] = GEN_INT (INTVAL (operands[2]) - INTVAL (operands[5])); }) - -;; XTheadMemPair: merge two SI or DI loads -(define_peephole2 - [(set (match_operand:GPR 0 "register_operand" "") - (match_operand:GPR 1 "memory_operand" "")) - (set (match_operand:GPR 2 "register_operand" "") - (match_operand:GPR 3 "memory_operand" ""))] - "TARGET_XTHEADMEMPAIR - && th_mempair_operands_p (operands, true, mode)" - [(parallel [(set (match_dup 0) (match_dup 1)) - (set (match_dup 2) (match_dup 3))])] -{ - th_mempair_order_operands (operands, true, mode); -}) - -;; XTheadMemPair: merge two SI or DI stores -(define_peephole2 - [(set (match_operand:GPR 0 "memory_operand" "") - (match_operand:GPR 1 "register_operand" "")) - (set (match_operand:GPR 2 "memory_operand" "") - (match_operand:GPR 3 "register_operand" ""))] - "TARGET_XTHEADMEMPAIR - && th_mempair_operands_p (operands, false, mode)" - [(parallel [(set (match_dup 0) (match_dup 1)) - (set (match_dup 2) (match_dup 3))])] -{ - th_mempair_order_operands (operands, false, mode); -}) - -;; XTheadMemPair: merge two SI loads with sign-extension -(define_peephole2 - [(set (match_operand:DI 0 "register_operand" "") - (sign_extend:DI (match_operand:SI 1 "memory_operand" ""))) - (set (match_operand:DI 2 "register_operand" "") - (sign_extend:DI (match_operand:SI 3 "memory_operand" "")))] - "TARGET_XTHEADMEMPAIR && TARGET_64BIT - && th_mempair_operands_p (operands, true, SImode)" - [(parallel [(set (match_dup 0) (sign_extend:DI (match_dup 1))) - (set (match_dup 2) (sign_extend:DI (match_dup 3)))])] -{ - th_mempair_order_operands (operands, true, SImode); -}) - -;; XTheadMemPair: merge two SI loads with zero-extension -(define_peephole2 - [(set (match_operand:DI 0 "register_operand" "") - (zero_extend:DI (match_operand:SI 1 "memory_operand" ""))) - (set (match_operand:DI 2 "register_operand" "") - (zero_extend:DI (match_operand:SI 3 "memory_operand" "")))] - "TARGET_XTHEADMEMPAIR && TARGET_64BIT - && th_mempair_operands_p (operands, true, SImode)" - [(parallel [(set (match_dup 0) (zero_extend:DI (match_dup 1))) - (set (match_dup 2) (zero_extend:DI (match_dup 3)))])] -{ - th_mempair_order_operands (operands, true, SImode); -}) diff --git a/gcc/config/riscv/thead-peephole.md b/gcc/config/riscv/thead-peephole.md new file mode 100644 index 00000000000..5b829b5b968 --- /dev/null +++ b/gcc/config/riscv/thead-peephole.md @@ -0,0 +1,74 @@ +;; Machine description for T-Head vendor extensions +;; Copyright (C) 2023 Free Software Foundation, Inc. + +;; This file is part of GCC. + +;; GCC is free software; you can redistribute it and/or modify +;; it under the terms of the GNU General Public License as published by +;; the Free Software Foundation; either version 3, or (at your option) +;; any later version. + +;; GCC is distributed in the hope that it will be useful, +;; but WITHOUT ANY WARRANTY; without even the implied warranty of +;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +;; GNU General Public License for more details. + +;; You should have received a copy of the GNU General Public License +;; along with GCC; see the file COPYING3. If not see +;; . + +;; XTheadMemPair: merge two SI or DI loads +(define_peephole2 + [(set (match_operand:GPR 0 "register_operand" "") + (match_operand:GPR 1 "memory_operand" "")) + (set (match_operand:GPR 2 "register_operand" "") + (match_operand:GPR 3 "memory_operand" ""))] + "TARGET_XTHEADMEMPAIR + && th_mempair_operands_p (operands, true, mode)" + [(parallel [(set (match_dup 0) (match_dup 1)) + (set (match_dup 2) (match_dup 3))])] +{ + th_mempair_order_operands (operands, true, mode); +}) + +;; XTheadMemPair: merge two SI or DI stores +(define_peephole2 + [(set (match_operand:GPR 0 "memory_operand" "") + (match_operand:GPR 1 "register_operand" "")) + (set (match_operand:GPR 2 "memory_operand" "") + (match_operand:GPR 3 "register_operand" ""))] + "TARGET_XTHEADMEMPAIR + && th_mempair_operands_p (operands, false, mode)" + [(parallel [(set (match_dup 0) (match_dup 1)) + (set (match_dup 2) (match_dup 3))])] +{ + th_mempair_order_operands (operands, false, mode); +}) + +;; XTheadMemPair: merge two SI loads with sign-extension +(define_peephole2 + [(set (match_operand:DI 0 "register_operand" "") + (sign_extend:DI (match_operand:SI 1 "memory_operand" ""))) + (set (match_operand:DI 2 "register_operand" "") + (sign_extend:DI (match_operand:SI 3 "memory_operand" "")))] + "TARGET_XTHEADMEMPAIR && TARGET_64BIT + && th_mempair_operands_p (operands, true, SImode)" + [(parallel [(set (match_dup 0) (sign_extend:DI (match_dup 1))) + (set (match_dup 2) (sign_extend:DI (match_dup 3)))])] +{ + th_mempair_order_operands (operands, true, SImode); +}) + +;; XTheadMemPair: merge two SI loads with zero-extension +(define_peephole2 + [(set (match_operand:DI 0 "register_operand" "") + (zero_extend:DI (match_operand:SI 1 "memory_operand" ""))) + (set (match_operand:DI 2 "register_operand" "") + (zero_extend:DI (match_operand:SI 3 "memory_operand" "")))] + "TARGET_XTHEADMEMPAIR && TARGET_64BIT + && th_mempair_operands_p (operands, true, SImode)" + [(parallel [(set (match_dup 0) (zero_extend:DI (match_dup 1))) + (set (match_dup 2) (zero_extend:DI (match_dup 3)))])] +{ + th_mempair_order_operands (operands, true, SImode); +}) diff --git a/gcc/config/riscv/thead.md b/gcc/config/riscv/thead.md index aa933960a98..1ac4dd9b462 100644 --- a/gcc/config/riscv/thead.md +++ b/gcc/config/riscv/thead.md @@ -374,3 +374,5 @@ (define_insn "*th_mempair_load_zero_extendsidi2" [(set_attr "move_type" "load") (set_attr "mode" "DI") (set_attr "length" "8")]) + +(include "thead-peephole.md")