From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-yw1-x1135.google.com (mail-yw1-x1135.google.com [IPv6:2607:f8b0:4864:20::1135]) by sourceware.org (Postfix) with ESMTPS id 5C9A03858C66 for ; Wed, 26 Apr 2023 21:45:18 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 5C9A03858C66 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=rivosinc.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=rivosinc.com Received: by mail-yw1-x1135.google.com with SMTP id 00721157ae682-54f945a7bddso91236957b3.0 for ; Wed, 26 Apr 2023 14:45:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rivosinc-com.20221208.gappssmtp.com; s=20221208; t=1682545517; x=1685137517; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=l5XYWjoWq6ORh8+SQndB8lcKhJ0q15pqKP8X7CJXwE0=; b=iJ93//31to9qIamTsKiPxBfKzJG5wKu3GJOG5ovlr0r3A6mkCbLIp0orXQo1EVyy/f fcxrCnx7eUOxxP6s3FAJ87b3c0D3vwabE6tTN+pXO4ClYpR9TVpKK6k35oJQqLSG/m2X V1Fb0attJ1Fg1UcX3SmCiXmyQj5jduLVS1/6453qRHhTmcsUPeJZoKY4Hm55kRRNBZyC kfJlW4R8bAH9im3sZgXXRBt9EOAkiJrExdnghXNO5M7BN6J8oFzC4KYIitp41zw8eVRO 8Edz1+CzUJD22goQBL8Zr5aCg8fd4msr1nHf86R6e0BF4wJLRkoe9l1lqn6ucTEtJybx 1ynA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1682545517; x=1685137517; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=l5XYWjoWq6ORh8+SQndB8lcKhJ0q15pqKP8X7CJXwE0=; b=dim2YkppIy4m1j87cpOTvt19NKj50bTtSJ2xhd9pMT6wtC2z01RLvEUAYAIbMAhyQU QudVH0YrttI6p58RF8uSdZ30eBDoBVBtW6ttcP/MrH49/D9BTX0rnpuGMBJrK2EtrmCB oQS/h9QMRukBWV0T2T59uBq0fG5gJamBHjgV2liQvNajIZVRrtjdGAlsAls+RUZyDFQH GzmfN2/GQI1JQV4LUTpj9bCuFE8sGL4xoivAeIm+5edfIRbhxecNG3L0hmPVLYUGsUD4 P9OhEATpQ74zq/G0aB0jytD+vdsCgjCgntN1OdJVdcJpVygH/19PUkHEv95NRNYZznGo FJhg== X-Gm-Message-State: AAQBX9eHUB1R6DzmDyx1R0knoWfY7xxjj2ceGMGWhN9I5n1pwC2iFMbZ Gju8xeOjt4DB0WI7uRIO4Q6YpfwZLb5tYYalCZM= X-Google-Smtp-Source: AKy350bBi9UWFLNV91/0hXFyys+KGr2twgQH/MCtKhYMU/CIYq3zQDyVXS708nseRxf3OwPdyBJ3YA== X-Received: by 2002:a81:72c3:0:b0:54f:b4cc:cdb7 with SMTP id n186-20020a8172c3000000b0054fb4cccdb7mr14305169ywc.29.1682545517623; Wed, 26 Apr 2023 14:45:17 -0700 (PDT) Received: from system76-pc.ba.rivosinc.com ([136.57.172.92]) by smtp.gmail.com with ESMTPSA id n12-20020a0dcb0c000000b00552e32354f8sm4469824ywd.32.2023.04.26.14.45.17 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 26 Apr 2023 14:45:17 -0700 (PDT) From: Michael Collison To: gcc-patches@gcc.gnu.org Subject: [PATCH v5 05/10] RISC-V:autovec: Add autovectorization patterns for binary integer & len_load/store Date: Wed, 26 Apr 2023 17:45:09 -0400 Message-Id: <20230426214514.3355280-6-collison@rivosinc.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230426214514.3355280-1-collison@rivosinc.com> References: <20230426214514.3355280-1-collison@rivosinc.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-12.8 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,GIT_PATCH_0,KAM_ASCII_DIVIDERS,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 List-Id: 2023-04-25 Michael Collison Juzhe Zhong * config/riscv/riscv.md (riscv_vector_preferred_simd_mode): Include vector-iterators.md. * config/riscv/vector-auto.md: New file containing autovectorization patterns. * config/riscv/vector.md: Remove include of vector-iterators.md and include vector-auto.md. --- gcc/config/riscv/riscv.md | 1 + gcc/config/riscv/vector-auto.md | 74 +++++++++++++++++++++++++++++++++ gcc/config/riscv/vector.md | 4 +- 3 files changed, 77 insertions(+), 2 deletions(-) create mode 100644 gcc/config/riscv/vector-auto.md diff --git a/gcc/config/riscv/riscv.md b/gcc/config/riscv/riscv.md index bc384d9aedf..7f8f3a6cb18 100644 --- a/gcc/config/riscv/riscv.md +++ b/gcc/config/riscv/riscv.md @@ -135,6 +135,7 @@ (include "predicates.md") (include "constraints.md") (include "iterators.md") +(include "vector-iterators.md") ;; .................... ;; diff --git a/gcc/config/riscv/vector-auto.md b/gcc/config/riscv/vector-auto.md new file mode 100644 index 00000000000..83d2ab6957a --- /dev/null +++ b/gcc/config/riscv/vector-auto.md @@ -0,0 +1,74 @@ +;; Machine description for RISC-V 'V' Extension for GNU compiler. +;; Copyright (C) 2022-2023 Free Software Foundation, Inc. +;; Contributed by Juzhe Zhong (juzhe.zhong@rivai.ai), RiVAI Technologies Ltd. +;; Contributed by Michael Collison (collison@rivosinc.com, Rivos 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 +;; . + +;; len_load/len_store is a sub-optimal pattern for RVV auto-vectorization support. +;; We will replace them when len_maskload/len_maskstore is supported in loop vectorizer. +(define_expand "len_load_" + [(match_operand:V 0 "register_operand") + (match_operand:V 1 "memory_operand") + (match_operand 2 "vector_length_operand") + (match_operand 3 "const_0_operand")] + "TARGET_VECTOR" +{ + riscv_vector::emit_nonvlmax_op (code_for_pred_mov (mode), operands[0], + operands[1], operands[2], mode); + DONE; +}) + +(define_expand "len_store_" + [(match_operand:V 0 "memory_operand") + (match_operand:V 1 "register_operand") + (match_operand 2 "vector_length_operand") + (match_operand 3 "const_0_operand")] + "TARGET_VECTOR" +{ + riscv_vector::emit_nonvlmax_op (code_for_pred_mov (mode), operands[0], + operands[1], operands[2], mode); + DONE; +}) + +;; ------------------------------------------------------------------------- +;; ---- [INT] Vector binary patterns +;; ------------------------------------------------------------------------- + +(define_expand "3" + [(set (match_operand:VI 0 "register_operand") + (any_int_binop:VI (match_operand:VI 1 "") + (match_operand:VI 2 "")))] + "TARGET_VECTOR" +{ + using namespace riscv_vector; + + rtx merge = RVV_VUNDEF (mode); + rtx vl = gen_reg_rtx (Pmode); + emit_vlmax_vsetvl (mode, vl); + rtx mask_policy = get_mask_policy_no_pred (); + rtx tail_policy = get_tail_policy_no_pred (); + rtx mask = CONSTM1_RTX(mode); + rtx vlmax_avl_p = get_avl_type_rtx (NONVLMAX); + + emit_insn (gen_pred_ (operands[0], mask, merge, operands[1], operands[2], + vl, tail_policy, mask_policy, vlmax_avl_p)); + + DONE; +}) + + diff --git a/gcc/config/riscv/vector.md b/gcc/config/riscv/vector.md index 0ecca98f20c..2ac5b744503 100644 --- a/gcc/config/riscv/vector.md +++ b/gcc/config/riscv/vector.md @@ -26,8 +26,6 @@ ;; - Auto-vectorization (TBD) ;; - Combine optimization (TBD) -(include "vector-iterators.md") - (define_constants [ (INVALID_ATTRIBUTE 255) (X0_REGNUM 0) @@ -351,6 +349,8 @@ (symbol_ref "INTVAL (operands[4])")] (const_int INVALID_ATTRIBUTE))) +(include "vector-auto.md") + ;; ----------------------------------------------------------------- ;; ---- Miscellaneous Operations ;; ----------------------------------------------------------------- -- 2.34.1