From patchwork Wed May 10 15:24:50 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Robin Dapp X-Patchwork-Id: 92177 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp3709921vqo; Wed, 10 May 2023 08:27:03 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ70MdJgjSiZWN2PTyUe+39s0DyN98Q85WHDL0SUG6CJkRIPidJ9C1pahbxGJeStKfXMA9WL X-Received: by 2002:aa7:d687:0:b0:4ad:738b:6706 with SMTP id d7-20020aa7d687000000b004ad738b6706mr15353243edr.2.1683732423251; Wed, 10 May 2023 08:27:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1683732423; cv=none; d=google.com; s=arc-20160816; b=bOZXTlvAmpxewJitvqxLEeQV733DU+GlTw9VNuhpK0aP/GHOrMG5e6ooKvQIWO5XRj GKfGwyxh00RFXLTNQtKmMP4ySq6VOGPYpcseV+1M7xge1anTpdHTujaY8qqHWW+h6xJe bZLOdoaFhaKqnQhQOmBlzYi7glxbASxmtmO2Om+SGH19kLdNNNOL/LAcctYkfOfkQKQA KMEv0188FUZMZsmQ3vBuuuZYeuVg5xlnLDcxpBFsAq2fdh3CCJImyk4rSIAHLoHR2Zz/ IhStApmtWm07vZVbAvO30oO0Tuu5pbKY6sawF+rKElxW0jG7shhzPGNPAkXjjBJ1jMB5 XB7w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:reply-to:from:list-subscribe:list-help:list-post :list-archive:list-unsubscribe:list-id:precedence :content-transfer-encoding:cc:subject:to:content-language:user-agent :mime-version:date:message-id:dmarc-filter:delivered-to :dkim-signature:dkim-filter; bh=yRugv9lQpYADQZxgJln+KzkpQq73L0ZS6gGs01w5xe8=; b=kRGy0f4VyygOx+XfilqIGxKWwqy+VWNZ34fwmcg8fzT3PpFIddpZmysb+yDVnuFHgz 39yBhs3z1Kt8UQGm0TD+oGWPHzSh0kn45dO81tT5MAaaFjIxMMyE935qe5wnYVy7MjKN j2FhtzYXhYxf5TUZiYsx02CfkOJDbTHbijXpXLUu+YVJkwLge++j7aYkevsXZCsvLcwW 94cRpyxuzH1x8ri8gpDVbszqRUVcnTQJvqRe9SwiVeDFkpzLkJJ+WpODWkI6zExTo++v uu2PqHe3RoR1PQ3Vr9a70lT+UDDEJZbF6DTgpg5QO1/328ySvcgeXkrwqFIKeb5t5bpQ NOiQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=U99CdjR3; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from sourceware.org (ip-8-43-85-97.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id i7-20020aa7dd07000000b005047b5d4479si3019764edv.415.2023.05.10.08.27.03 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 10 May 2023 08:27:03 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) client-ip=8.43.85.97; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=U99CdjR3; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 8937038306B9 for ; Wed, 10 May 2023 15:25:46 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 8937038306B9 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1683732346; bh=yRugv9lQpYADQZxgJln+KzkpQq73L0ZS6gGs01w5xe8=; h=Date:To:Subject:Cc:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From:Reply-To:From; b=U99CdjR3+kkcY+dY+AqgsljDFY4F3q4SkY+QjSnNc57B1u6Ud3VUnqJ3nRh21TUNy NLiX9ocJdh2bKMxaeOODCUtLdg44Vd3/NUAZJo5saXCy33K1N7joyR1XakshvaOa4N u8pI0qGRAlkANBDM1QiJpcddFx/G7qwbRybM6Rto= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-ed1-x52e.google.com (mail-ed1-x52e.google.com [IPv6:2a00:1450:4864:20::52e]) by sourceware.org (Postfix) with ESMTPS id 1F1803870898 for ; Wed, 10 May 2023 15:24:55 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 1F1803870898 Received: by mail-ed1-x52e.google.com with SMTP id 4fb4d7f45d1cf-50bd37ca954so70067053a12.0 for ; Wed, 10 May 2023 08:24:55 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1683732292; x=1686324292; h=content-transfer-encoding:cc:subject:from:to:content-language :user-agent:mime-version:date:message-id:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to; bh=yRugv9lQpYADQZxgJln+KzkpQq73L0ZS6gGs01w5xe8=; b=BLwNGS2dhOT1hUyJx2/vfpB640MhlFwvFkHuw3EIxRL6HVKGJmnOtQb8sUMobqFNiq idWZYLtWofzDRUmXVAC2wZ5kwy1FkJtAYwXm9EDSUy3IoTb5Q15NW2wYjXQ7WRvJn1aw 9+XYQDxj46FEYivBOQZtQ+xTT8asfz6P3veIOTDYOtycTVQIfTrbnfYwaDh31vdZKnjs 3vw9i6+Gx0cmFm+h/0D6qcyUgvI/j9WBQg5ae5jHFZfUfcmqEu/QDWH6akE3TTB7zwlL cGuM7TG7z/8+ycANAkps5Mo+efDXHU9YjghBYhVPI1ZPrS+U049AarbQ8sacmXdAoroP iW4Q== X-Gm-Message-State: AC+VfDwQHYXd+km/pQwY1ufaEu8whxo6b+Rsw9O11kQgWHz9E7CeTCV/ XYlq9k0PZUPr+JncDd9rp8LbTlriSwY= X-Received: by 2002:a17:907:d0e:b0:94a:57d1:5539 with SMTP id gn14-20020a1709070d0e00b0094a57d15539mr16554882ejc.5.1683732291685; Wed, 10 May 2023 08:24:51 -0700 (PDT) Received: from [192.168.1.23] (ip-046-005-130-086.um12.pools.vodafone-ip.de. [46.5.130.86]) by smtp.gmail.com with ESMTPSA id hg10-20020a1709072cca00b009659c23e78fsm2752658ejc.215.2023.05.10.08.24.50 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 10 May 2023 08:24:51 -0700 (PDT) Message-ID: <75805840-7b6b-7194-cae1-02eea3ea181c@gmail.com> Date: Wed, 10 May 2023 17:24:50 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.10.0 Content-Language: en-US To: gcc-patches , "juzhe.zhong@rivai.ai" , Kito Cheng , Michael Collison , palmer , jeffreyalaw Subject: [PATCH] riscv: Split off shift patterns for autovectorization. Cc: rdapp.gcc@gmail.com X-Spam-Status: No, score=-11.0 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, GIT_PATCH_0, KAM_ASCII_DIVIDERS, KAM_MANYTO, 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: , X-Patchwork-Original-From: Robin Dapp via Gcc-patches From: Robin Dapp Reply-To: Robin Dapp Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1765521409800360687?= X-GMAIL-MSGID: =?utf-8?q?1765521409800360687?= Hi, this patch splits off the shift patterns of the binop patterns. This is necessary as the scalar shifts require a Pmode operand as shift count. To this end, a new iterator any_int_binop_no_shift is introduced. At a later point when the binops are split up further in commutative and non-commutative patterns (which both do not include the shift patterns) we might not need this anymore. Bootstrapped and regtested. Regards Robin --- gcc/ChangeLog: * config/riscv/autovec.md (3): Add scalar shift pattern. (v3): Add vector shift pattern. * config/riscv/vector-iterators.md: New iterator. --- gcc/config/riscv/autovec.md | 40 +++++++++++++++++++++++++++- gcc/config/riscv/vector-iterators.md | 4 +++ 2 files changed, 43 insertions(+), 1 deletion(-) diff --git a/gcc/config/riscv/autovec.md b/gcc/config/riscv/autovec.md index 8347e42bb9c..2da4fc67d51 100644 --- a/gcc/config/riscv/autovec.md +++ b/gcc/config/riscv/autovec.md @@ -65,7 +65,7 @@ (define_expand "movmisalign" (define_expand "3" [(set (match_operand:VI 0 "register_operand") - (any_int_binop:VI + (any_int_binop_no_shift:VI (match_operand:VI 1 "") (match_operand:VI 2 "")))] "TARGET_VECTOR" @@ -91,3 +91,41 @@ (define_expand "3" NULL_RTX, mode); DONE; }) + +;; ========================================================================= +;; == Binary integer shifts by scalar. +;; ========================================================================= + +(define_expand "3" + [(set (match_operand:VI 0 "register_operand") + (any_shift:VI + (match_operand:VI 1 "register_operand") + (match_operand: 2 "csr_operand")))] + "TARGET_VECTOR" +{ + if (!CONST_SCALAR_INT_P (operands[2])) + operands[2] = gen_lowpart (Pmode, operands[2]); + riscv_vector::emit_len_binop (code_for_pred_scalar + (, mode), + operands[0], operands[1], operands[2], + NULL_RTX, mode, Pmode); + DONE; +}) + +;; ========================================================================= +;; == Binary integer shifts by vector. +;; ========================================================================= + +(define_expand "v3" + [(set (match_operand:VI 0 "register_operand") + (any_shift:VI + (match_operand:VI 1 "register_operand") + (match_operand:VI 2 "vector_shift_operand")))] + "TARGET_VECTOR" +{ + riscv_vector::emit_len_binop (code_for_pred + (, mode), + operands[0], operands[1], operands[2], + NULL_RTX, mode); + DONE; +}) diff --git a/gcc/config/riscv/vector-iterators.md b/gcc/config/riscv/vector-iterators.md index 42848627c8c..fdb0bfbe3b1 100644 --- a/gcc/config/riscv/vector-iterators.md +++ b/gcc/config/riscv/vector-iterators.md @@ -1429,6 +1429,10 @@ (define_code_iterator any_commutative_binop [plus and ior xor (define_code_iterator any_non_commutative_binop [minus div udiv mod umod]) +(define_code_iterator any_int_binop_no_shift + [plus minus and ior xor smax umax smin umin mult div udiv mod umod +]) + (define_code_iterator any_immediate_binop [plus minus and ior xor]) (define_code_iterator any_sat_int_binop [ss_plus ss_minus us_plus us_minus])