From patchwork Tue Apr 4 08:46:30 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "juzhe.zhong@rivai.ai" X-Patchwork-Id: 78928 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp2870654vqo; Tue, 4 Apr 2023 01:47:13 -0700 (PDT) X-Google-Smtp-Source: AKy350ZY/zB+21Q1EEEuQEzjNnqWTscJHbVy7hXHo9irPjDHQnQyOcd1ofmtYlVPWmHaZ2aKWjSg X-Received: by 2002:aa7:cf86:0:b0:502:9aef:6f18 with SMTP id z6-20020aa7cf86000000b005029aef6f18mr1901728edx.31.1680598033184; Tue, 04 Apr 2023 01:47:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680598033; cv=none; d=google.com; s=arc-20160816; b=BTleqI20IsNdFJ9e16pMEU0PFX6uRNA5k0QfevD0oQ+4Lv1NOfArmTF6XyAgmdQUW0 GYnrGbWVbdKGbm3nr61cBsb+2AH19vjISvdow25ZDQTEDygCHZ4QDwRBX+yzM9y1QFNg Vcv3zCTmG3pPdpmbP9VvXuAXse1YUPanzTomqQeeFqmD8Cz47wTDpyEbDDunkUNUVlJk 1vjV7+GDcdwvcExvkgmR7r4DMPvYqAkC1Sz+OSpoL+ocHx0bWwWNBHcTfLvRrDbTDx+4 pD2W5PYdcZgLAjXTnU0JJm5O4e9PH0BlEvqqYw3m+M0mssjtQwF0hL/W8YDEh2qLrpHD cDDA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:feedback-id :content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:dmarc-filter:delivered-to; bh=m64FOZxKAzPQr8BMQ68WX/emTNkgRSAatmXQ2+wh1nM=; b=T21jbWmF0tEyUjqa8QX5uujuVAGz8SXwUNOZ/aV9WgkBrbJZ8W7C5NPqgIXgwKPgTU UPG8mXvPBsOaK1EWpPDKs05kfkHOeeiG+kT4Z9s6wGDrqhWEb7LxZ0+0p4nzIP6dtp7s zowYJQwD01f/pOXQ+KAqatLhjRZDOVAvwQQvX//2k7sEu4BBv0BywOMueC8OQFY7iGwX cQ39l43V12OA5tXeIpvrNQ6rE+HX7YkqBncEENrrl+5NjOpaW3sErnfUMufK07DuSUhO PI8QIDU0MDvxJPxEvxngXcmWOjNFiFZn+geLn1DOxg56HT8gWUMTMNCBodGFuMeMdfwW +9zw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org" Received: from sourceware.org (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id y2-20020aa7ccc2000000b004bcedde1496si8224071edt.287.2023.04.04.01.47.12 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 04 Apr 2023 01:47:13 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) client-ip=2620:52:3:1:0:246e:9693:128c; Authentication-Results: mx.google.com; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org" Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 39CA33858296 for ; Tue, 4 Apr 2023 08:47:10 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from smtpbgsg1.qq.com (smtpbgsg1.qq.com [54.254.200.92]) by sourceware.org (Postfix) with ESMTPS id 24A013858D1E for ; Tue, 4 Apr 2023 08:46:41 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 24A013858D1E Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=rivai.ai Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=rivai.ai X-QQ-mid: bizesmtp79t1680597995tb8ajz2j Received: from rios-cad5.localdomain ( [58.60.1.11]) by bizesmtp.qq.com (ESMTP) with id ; Tue, 04 Apr 2023 16:46:33 +0800 (CST) X-QQ-SSF: 01400000000000F0O000000A0000000 X-QQ-FEAT: bw4fXkvfu8sLB57uRs2Y/od52SVbymXa+SGMU8U6HaeiTqfSyF6sTv01Yg5GD zQD+d7iPc/sOIiDEK/YiFo1OeNUyozLkUdyUEn6SMW0W0EqAGyWVfHnZ5xsYSywWHSXYiZ2 RKi9QhVoF4yRRu1tLPgcoHn4hbRt846UgKFTHPgTPsiQRHXsXrlOQFEO7MCznPY8r3mVYA1 Hr65MjQ5vT1HpOhFaZpSXgDLT/5oCo0X9YxTO+0/UfmAs6/d0ZtvaZYil8cOOTCmLJKYrBS zHrtzeE/4qtcMtq+BbJhrrzAnsm4powixF5yvQfB8vFlH+ZJ77JIZl5S9qBq7k78vy5BxfV Mpq4tGhzJj7YDtqH+y80Y3jGfo8NyBPP6KQQKJCzcOayaVhbszkv9W1RTi9tfumQZBDF1Vf X-QQ-GoodBg: 2 X-BIZMAIL-ID: 15275796072041165749 From: juzhe.zhong@rivai.ai To: gcc-patches@gcc.gnu.org Cc: kito.cheng@gmail.com, palmer@dabbelt.com, Juzhe-Zhong Subject: [PATCH] RISC-V: Fix PR109399 VSETVL PASS bug Date: Tue, 4 Apr 2023 16:46:30 +0800 Message-Id: <20230404084630.48657-1-juzhe.zhong@rivai.ai> X-Mailer: git-send-email 2.36.3 MIME-Version: 1.0 X-QQ-SENDSIZE: 520 Feedback-ID: bizesmtp:rivai.ai:qybglogicsvr:qybglogicsvr7 X-Spam-Status: No, score=-11.8 required=5.0 tests=BAYES_00, GIT_PATCH_0, KAM_DMARC_STATUS, KAM_SHORT, LIKELY_SPAM_BODY, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_PASS, SPF_PASS, TXREP 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+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1762234763463202558?= X-GMAIL-MSGID: =?utf-8?q?1762234763463202558?= From: Juzhe-Zhong This patch fix bug: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109399 PR 109399 gcc/ChangeLog: * config/riscv/riscv-vsetvl.cc (pass_vsetvl::compute_local_backward_infos): Update user vsetvl in local demand fusion. gcc/testsuite/ChangeLog: * gcc.target/riscv/rvv/vsetvl/pr109399.c: New test. --- gcc/config/riscv/riscv-vsetvl.cc | 8 +++++++- .../gcc.target/riscv/rvv/vsetvl/pr109399.c | 14 ++++++++++++++ 2 files changed, 21 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/gcc.target/riscv/rvv/vsetvl/pr109399.c diff --git a/gcc/config/riscv/riscv-vsetvl.cc b/gcc/config/riscv/riscv-vsetvl.cc index 4d043c0645b..7e8a5376705 100644 --- a/gcc/config/riscv/riscv-vsetvl.cc +++ b/gcc/config/riscv/riscv-vsetvl.cc @@ -2715,7 +2715,13 @@ pass_vsetvl::compute_local_backward_infos (const bb_info *bb) if (!(propagate_avl_across_demands_p (change, info) && !reg_available_p (insn, change)) && change.compatible_p (info)) - info = change.merge (info); + { + info = change.merge (info); + /* Fix PR109399, we should update user vsetvl instruction + if there is a change in demand fusion. */ + if (vsetvl_insn_p (insn->rtl ())) + change_vsetvl_insn (insn, info); + } } change = info; } diff --git a/gcc/testsuite/gcc.target/riscv/rvv/vsetvl/pr109399.c b/gcc/testsuite/gcc.target/riscv/rvv/vsetvl/pr109399.c new file mode 100644 index 00000000000..b3abad7a8bf --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/rvv/vsetvl/pr109399.c @@ -0,0 +1,14 @@ +/* { dg-do compile } */ +/* { dg-options "-march=rv32gcv -mabi=ilp32 -fno-tree-vectorize -fno-schedule-insns -fno-schedule-insns2" } */ + +#include "riscv_vector.h" + +void foo(void *in1, void *in2, void *in3, void *out, size_t n) { + size_t vl = __riscv_vsetvlmax_e32m1(); + vint32m1_t a = __riscv_vle32_v_i32m1(in1, vl); + vint32m1_t b = __riscv_vle32_v_i32m1_tu(a, in2, vl); + vint32m1_t c = __riscv_vle32_v_i32m1_tu(b, in3, vl); + __riscv_vse32_v_i32m1(out, c, vl); +} + +/* { dg-final { scan-assembler-times {vsetvli\s+[a-x0-9]+,\s*zero,\s*e32,\s*m1,\s*tu,\s*m[au]} 1 { target { no-opts "-O0" no-opts "-Os" no-opts "-Oz" no-opts "-funroll-loops" no-opts "-g" } } } } */