From patchwork Wed Aug 9 10:51:42 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: 133158 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:c44e:0:b0:3f2:4152:657d with SMTP id w14csp2709211vqr; Wed, 9 Aug 2023 03:52:34 -0700 (PDT) X-Google-Smtp-Source: AGHT+IE4XURgeljAuN9ERxmp3wTSgH8H3uhKv5YuSyiDtuVkKt7rEotR1F/QTpUs3aw4eT/LLCcJ X-Received: by 2002:aa7:d1d0:0:b0:522:cc6c:e25e with SMTP id g16-20020aa7d1d0000000b00522cc6ce25emr1938014edp.3.1691578354536; Wed, 09 Aug 2023 03:52:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1691578354; cv=none; d=google.com; s=arc-20160816; b=pWUcgA+kRiHS7x0Wbs/5AD6f0u2Ly+bISCXJs0iM5sZIG2+5+4qt/ScIVMl5OCJcB3 cDb7s3W2b2N4SYVqr/P31YadQd4zQhXlu0e45uMSW5vI5LV79BaFK//Kr4oseezCiu0D FdMzJ2ZuKD+ZHaJtMAyA8T3v3je55949Jd3FKg5HmrPE/+C9JWChpAHdu5b8OGzRgo/x b2zi7nKMo611WO/WXmF31uy3wF7QbJ1MW2OWqRWGGU/MKK/0jirrEj+Bvu01dwPU/7JI DhWJIja+fqtK0DreURq5euSfe8Dvb5i0Bb238iYf+dkkavDAbQ/xd59Db0f0yk6QzR4l SL9A== 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=Awge1uvIg2Mp0AZrxjtnCfk8HXCxp+91e7neNbtfkys=; fh=SuV1mxSfYh/fFJBV6FW8ZDQUWC7OLSIDYxyJSOKFLBQ=; b=aRqVeBK0s12YPuoCkitrqt6EaJqY3B+4IY1yV2dxOfGxuSK8K8Pjh+pL0QqfG3AiX7 d9VULf4F0Fsjd/QKno+QWXzv5QIjol1scBeM5228MRYsxiNvlSo+CrMxX+MnVr+nCD1Z IRtdkVVw3bv0NSBkiqURqcelUM43kNJMXcahMf89RuyHF9oBAfYCgW9sRjFzV1fUlSBy ZG8n7xqYbtD0btbLGPJ5xPLsJkGW8y6qRAhwJqhQ/2VydTrJgty+LwEO2WXVJS5jee/c 48JHZYRjrYLHdPCJDpfkflaAwwBjdlZuOUHpHcs3sgD1VoTeE3Nlot2fNk7N0LHfU+AI MGzw== 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 server2.sourceware.org (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id v6-20020a056402184600b0052286405b7dsi8213625edy.387.2023.08.09.03.52.34 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 09 Aug 2023 03:52:34 -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 645F23857737 for ; Wed, 9 Aug 2023 10:52:23 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from smtpbgeu1.qq.com (smtpbgeu1.qq.com [52.59.177.22]) by sourceware.org (Postfix) with ESMTPS id 385753858D20 for ; Wed, 9 Aug 2023 10:51:50 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 385753858D20 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: bizesmtp82t1691578305tup7wjrz Received: from rios-cad5.localdomain ( [58.60.1.11]) by bizesmtp.qq.com (ESMTP) with id ; Wed, 09 Aug 2023 18:51:44 +0800 (CST) X-QQ-SSF: 01400000000000G0V000000A0000000 X-QQ-FEAT: ZkxZBO9qcf5E7o4waONpmaAWfmVtr8rO6bOIq1yf/GZ0t1f9eIhFq2NHBucHn B1Q6vajJO1NHt/oCLJSBdJrfE+WeVLnFE/Su4Mg76JT3shwC+00jDa6hkCWQLtaepdSoyob JmBz3cN/BLCmXgE7HGapHQywWpztNiUjyRgngoioU8Ibo18DmlUUFcw5IZud+zA4xgylPTV 5DQDhxqDXoZdK9KgWxDMEkpp8hfGqJqlLdKWFr5bJOGDdSnK+6Xw3VeTZB6vvi1tlC+PnuR J7aRv/ZyWnJPay5haqM4XEObUcDpooDMjBwvbZHg8l/j/NjsvFxLp3lkBJDO5Cjh8aHxXjC qh5eEDinGSf9qkJXQqdCaH/WUG9WUT0tY3BZmZPEsnexGwbySUgALKsPiuFXYyca/3qvwb4 9teH9agdXII= X-QQ-GoodBg: 2 X-BIZMAIL-ID: 10138245458194763328 From: Juzhe-Zhong To: gcc-patches@gcc.gnu.org Cc: kito.cheng@gmail.com, kito.cheng@sifive.com, jeffreyalaw@gmail.com, rdapp.gcc@gmail.com, Juzhe-Zhong Subject: [PATCH] RISC-V: Fix VLMAX AVL incorrect local anticipate [VSETVL PASS] Date: Wed, 9 Aug 2023 18:51:42 +0800 Message-Id: <20230809105142.3163887-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:qybglogicsvrgz:qybglogicsvrgz7a-one-0 X-Spam-Status: No, score=-9.6 required=5.0 tests=BAYES_00, GIT_PATCH_0, KAM_DMARC_STATUS, KAM_SHORT, LIKELY_SPAM_BODY, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SCC_10_SHORT_WORD_LINES, SCC_20_SHORT_WORD_LINES, SCC_5_SHORT_WORD_LINES, SPF_PASS, TXREP, T_SPF_HELO_TEMPERROR 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: INBOX X-GMAIL-THRID: 1773748464783933070 X-GMAIL-MSGID: 1773748464783933070 Realize we have a bug in VSETVL PASS which is triggered by strided_load_run-1.c in RV32 system. FAIL: gcc.target/riscv/rvv/autovec/gather-scatter/strided_load_run-1.c execution test FAIL: gcc.target/riscv/rvv/autovec/gather-scatter/strided_load_run-1.c execution test FAIL: gcc.target/riscv/rvv/autovec/gather-scatter/strided_load_run-1.c execution test FAIL: gcc.target/riscv/rvv/autovec/gather-scatter/strided_load_run-1.c execution test This is because VSETVL PASS incorrect hoist vsetvl instruction: ... 10156: 0d9075d7 vsetvli a1,zero,e64,m2,ta,ma ---> pollute 'a1' register which will be used by following insns. 1015a: 01d586b3 add a3,a1,t4 --------> use 'a1' 1015e: 5e070257 vmv.v.v v4,v14 10162: b7032257 vmacc.vv v4,v6,v16 10166: 26440257 vand.vv v4,v4,v8 1016a: 22880227 vs2r.v v4,(a6) 1016e: 00b6b7b3 sltu a5,a3,a1 10172: 22888227 vs2r.v v4,(a7) 10176: 9e60b157 vmv2r.v v2,v6 1017a: 97ba add a5,a5,a4 1017c: a6a62157 vmadd.vv v2,v12,v10 10180: 26240157 vand.vv v2,v2,v8 10184: 22830127 vs2r.v v2,(t1) 10188: 873e mv a4,a5 1018a: 982a add a6,a6,a0 1018c: 98aa add a7,a7,a0 1018e: 932a add t1,t1,a0 10190: 85b6 mv a1,a3 -----> set 'a1' ... gcc/ChangeLog: * config/riscv/riscv-vsetvl.cc (anticipatable_occurrence_p): Fix incorrect anticipate info. gcc/testsuite/ChangeLog: * gcc.target/riscv/rvv/autovec/gather-scatter/strided_load_run-1.c: Adapt test. * gcc.target/riscv/rvv/vsetvl/vlmax_back_prop-24.c: Ditto. * gcc.target/riscv/rvv/vsetvl/vlmax_back_prop-25.c: Ditto. * gcc.target/riscv/rvv/vsetvl/vlmax_back_prop-26.c: Ditto. * gcc.target/riscv/rvv/vsetvl/vlmax_back_prop-36.c: Ditto. * gcc.target/riscv/rvv/vsetvl/vlmax_switch_vtype-14.c: Ditto. * gcc.target/riscv/rvv/vsetvl/vlmax_switch_vtype-15.c: Ditto. --- gcc/config/riscv/riscv-vsetvl.cc | 4 ++- .../gather-scatter/strided_load_run-1.c | 1 + .../riscv/rvv/vsetvl/vlmax_back_prop-24.c | 2 +- .../riscv/rvv/vsetvl/vlmax_back_prop-25.c | 31 +++++++++---------- .../riscv/rvv/vsetvl/vlmax_back_prop-26.c | 30 +++++++++--------- .../riscv/rvv/vsetvl/vlmax_back_prop-36.c | 2 +- .../riscv/rvv/vsetvl/vlmax_switch_vtype-14.c | 10 +++--- .../riscv/rvv/vsetvl/vlmax_switch_vtype-15.c | 14 ++++----- 8 files changed, 47 insertions(+), 47 deletions(-) diff --git a/gcc/config/riscv/riscv-vsetvl.cc b/gcc/config/riscv/riscv-vsetvl.cc index 628bf116db0..08c487d82c0 100644 --- a/gcc/config/riscv/riscv-vsetvl.cc +++ b/gcc/config/riscv/riscv-vsetvl.cc @@ -333,7 +333,9 @@ anticipatable_occurrence_p (const bb_info *bb, const vector_insn_info dem) if (dem.has_avl_reg ()) { /* rs1 (avl) are not modified in the basic block prior to the VSETVL. */ - if (!vlmax_avl_p (dem.get_avl ())) + rtx avl + = has_vl_op (insn->rtl ()) ? get_vl (insn->rtl ()) : dem.get_avl (); + if (!vlmax_avl_p (avl)) { set_info *set = dem.get_avl_source (); /* If it's undefined, it's not anticipatable conservatively. */ diff --git a/gcc/testsuite/gcc.target/riscv/rvv/autovec/gather-scatter/strided_load_run-1.c b/gcc/testsuite/gcc.target/riscv/rvv/autovec/gather-scatter/strided_load_run-1.c index 4b03c25a907..7ffa93bf13f 100644 --- a/gcc/testsuite/gcc.target/riscv/rvv/autovec/gather-scatter/strided_load_run-1.c +++ b/gcc/testsuite/gcc.target/riscv/rvv/autovec/gather-scatter/strided_load_run-1.c @@ -1,4 +1,5 @@ /* { dg-do run { target { riscv_vector } } } */ +/* { dg-additional-options "-mcmodel=medany" } */ #include "strided_load-1.c" #include diff --git a/gcc/testsuite/gcc.target/riscv/rvv/vsetvl/vlmax_back_prop-24.c b/gcc/testsuite/gcc.target/riscv/rvv/vsetvl/vlmax_back_prop-24.c index bc98e5f8269..fe41d15cb28 100644 --- a/gcc/testsuite/gcc.target/riscv/rvv/vsetvl/vlmax_back_prop-24.c +++ b/gcc/testsuite/gcc.target/riscv/rvv/vsetvl/vlmax_back_prop-24.c @@ -30,7 +30,7 @@ void f (int32_t * restrict in, int32_t * restrict out, int n, int cond) *(vint32mf2_t*)(out + 7000) = v; for (int i = 0; i < n; i++) { - vbool64_t v; + vbool64_t v = *(vbool64_t*)(in + i + 9000); *(vbool64_t*)(out + i + 700) = v; } } diff --git a/gcc/testsuite/gcc.target/riscv/rvv/vsetvl/vlmax_back_prop-25.c b/gcc/testsuite/gcc.target/riscv/rvv/vsetvl/vlmax_back_prop-25.c index 0a10827daf5..c566f8a4751 100644 --- a/gcc/testsuite/gcc.target/riscv/rvv/vsetvl/vlmax_back_prop-25.c +++ b/gcc/testsuite/gcc.target/riscv/rvv/vsetvl/vlmax_back_prop-25.c @@ -10,7 +10,7 @@ void f (void * restrict in, void * restrict out, int n, int cond) *(vint8mf8_t*)(out + 100) = v; for (int i = 0; i < n; i++) { - vint16mf4_t v2; + vint16mf4_t v2 = __riscv_vmv_v_x_i16mf4 (0, __riscv_vsetvlmax_e16mf4 ()); *(vint16mf4_t*)(out + i + 100) = v2; } } else if (cond == 1) { @@ -18,7 +18,7 @@ void f (void * restrict in, void * restrict out, int n, int cond) *(vint8mf8_t*)(out + 200) = v; for (int i = 0; i < n; i++) { - vint32mf2_t v2; + vint32mf2_t v2 = __riscv_vmv_v_x_i32mf2 (0, __riscv_vsetvlmax_e32mf2 ()); *(vint32mf2_t*)(out + i + 200) = v2; } } else if (cond == 2) { @@ -26,7 +26,7 @@ void f (void * restrict in, void * restrict out, int n, int cond) *(vint8mf8_t*)(out + 300) = v; for (int i = 0; i < n; i++) { - vint8mf8_t v2; + vint8mf8_t v2 = __riscv_vmv_v_x_i8mf8 (0, __riscv_vsetvlmax_e8mf8 ()); *(vint8mf8_t*)(out + i + 300) = v2; } } else if (cond == 3) { @@ -34,7 +34,7 @@ void f (void * restrict in, void * restrict out, int n, int cond) *(vint8mf8_t*)(out + 400) = v; for (int i = 0; i < n; i++) { - vint64m1_t v2; + vint64m1_t v2 = __riscv_vmv_v_x_i64m1 (0, __riscv_vsetvlmax_e64m1 ()); *(vint64m1_t*)(out + i + 400) = v2; } } else if (cond == 4) { @@ -42,7 +42,7 @@ void f (void * restrict in, void * restrict out, int n, int cond) *(vint8mf8_t*)(out + 500) = v; for (int i = 0; i < n; i++) { - vfloat32mf2_t v2; + vfloat32mf2_t v2 = __riscv_vfmv_v_f_f32mf2 (0, __riscv_vsetvlmax_e32mf2 ()); *(vfloat32mf2_t*)(out + i + 500) = v2; } } else if (cond == 5) { @@ -50,7 +50,7 @@ void f (void * restrict in, void * restrict out, int n, int cond) *(vuint8mf8_t*)(out + 600) = v; for (int i = 0; i < n; i++) { - vuint16mf4_t v2; + vuint16mf4_t v2 = __riscv_vmv_v_x_u16mf4 (0, __riscv_vsetvlmax_e16mf4 ()); *(vuint16mf4_t*)(out + i + 600) = v2; } } else if (cond == 6) { @@ -58,7 +58,7 @@ void f (void * restrict in, void * restrict out, int n, int cond) *(vuint8mf8_t*)(out + 700) = v; for (int i = 0; i < n; i++) { - vuint32mf2_t v2; + vuint32mf2_t v2 = __riscv_vmv_v_x_u32mf2 (0, __riscv_vsetvlmax_e32mf2 ()); *(vuint32mf2_t*)(out + i + 700) = v2; } } else if (cond == 7) { @@ -66,7 +66,7 @@ void f (void * restrict in, void * restrict out, int n, int cond) *(vuint8mf8_t*)(out + 800) = v; for (int i = 0; i < n; i++) { - vuint8mf8_t v2; + vuint8mf8_t v2 = __riscv_vmv_v_x_u8mf8 (0, __riscv_vsetvlmax_e8mf8 ()); *(vuint8mf8_t*)(out + i + 800) = v2; } } else if (cond == 8) { @@ -74,7 +74,7 @@ void f (void * restrict in, void * restrict out, int n, int cond) *(vuint8mf8_t*)(out + 900) = v; for (int i = 0; i < n; i++) { - vuint64m1_t v2; + vuint64m1_t v2 = __riscv_vmv_v_x_u64m1 (0, __riscv_vsetvlmax_e64m1 ()); *(vuint64m1_t*)(out + i + 900) = v2; } } else { @@ -82,15 +82,14 @@ void f (void * restrict in, void * restrict out, int n, int cond) *(vuint8mf8_t*)(out + 1000) = v; for (int i = 0; i < n; i++) { - vfloat32mf2_t v2; + vfloat32mf2_t v2 = *(vfloat32mf2_t*)(in + i + 9000); *(vfloat32mf2_t*)(out + i + 1000) = v2; } } } -/* { dg-final { scan-assembler-times {vsetvli\s+zero,\s*zero,\s*e32,\s*mf2,\s*t[au],\s*m[au]} 4 { target { no-opts "-O0" no-opts "-O1" no-opts "-Os" no-opts "-Oz" no-opts "-funroll-loops" no-opts "-g" } } } } */ -/* { dg-final { scan-assembler-times {vsetvli\s+zero,\s*zero,\s*e16,\s*mf4,\s*t[au],\s*m[au]} 2 { target { no-opts "-O0" no-opts "-O1" no-opts "-Os" no-opts "-Oz" no-opts "-funroll-loops" no-opts "-g" } } } } */ -/* { dg-final { scan-assembler-times {vsetvli\s+zero,\s*zero,\s*e64,\s*m1,\s*t[au],\s*m[au]} 2 { target { no-opts "-O0" no-opts "-O1" no-opts "-Os" no-opts "-Oz" no-opts "-funroll-loops" no-opts "-g" } } } } */ -/* { dg-final { scan-assembler-times {vsetvli\s+[a-x0-9]+,\s*zero,\s*e8,\s*mf8,\s*t[au],\s*m[au]} 10 { target { no-opts "-O0" no-opts "-O1" no-opts "-Os" no-opts "-Oz" no-opts "-funroll-loops" no-opts "-g" } } } } */ -/* { dg-final { scan-assembler-times {vsetvli\s+zero,\s*zero,\s*e8,\s*mf8,\s*t[au],\s*m[au]} 2 { target { no-opts "-O0" no-opts "-O1" no-opts "-Os" no-opts "-Oz" no-opts "-funroll-loops" no-opts "-g" } } } } */ -/* { dg-final { scan-assembler-times {vsetvli} 20 { target { no-opts "-O0" no-opts "-O1" no-opts "-Os" no-opts "-Oz" no-opts "-funroll-loops" no-opts "-g" } } } } */ +/* { dg-final { scan-assembler-times {vsetvli\s+[a-x0-9]+,\s*zero,\s*e8,\s*mf8,\s*t[au],\s*m[au]} 3 { target { no-opts "-O0" no-opts "-O1" no-opts "-Os" no-opts "-Oz" no-opts "-funroll-loops" no-opts "-g" } } } } */ +/* { dg-final { scan-assembler-times {vsetvli\s+[a-x0-9]+,\s*zero,\s*e16,\s*mf4,\s*t[au],\s*m[au]} 2 { target { no-opts "-O0" no-opts "-O1" no-opts "-Os" no-opts "-Oz" no-opts "-funroll-loops" no-opts "-g" } } } } */ +/* { dg-final { scan-assembler-times {vsetvli\s+[a-x0-9]+,\s*zero,\s*e32,\s*mf2,\s*t[au],\s*m[au]} 3 { target { no-opts "-O0" no-opts "-O1" no-opts "-Os" no-opts "-Oz" no-opts "-funroll-loops" no-opts "-g" } } } } */ +/* { dg-final { scan-assembler-times {vsetvli\s+[a-x0-9]+,\s*zero,\s*e64,\s*m1,\s*t[au],\s*m[au]} 2 { target { no-opts "-O0" no-opts "-O1" no-opts "-Os" no-opts "-Oz" no-opts "-funroll-loops" no-opts "-g" } } } } */ +/* { dg-final { scan-assembler-times {vsetvli} 10 { target { no-opts "-O0" no-opts "-O1" no-opts "-Os" no-opts "-Oz" no-opts "-funroll-loops" no-opts "-g" } } } } */ diff --git a/gcc/testsuite/gcc.target/riscv/rvv/vsetvl/vlmax_back_prop-26.c b/gcc/testsuite/gcc.target/riscv/rvv/vsetvl/vlmax_back_prop-26.c index a6540751398..d0e75258188 100644 --- a/gcc/testsuite/gcc.target/riscv/rvv/vsetvl/vlmax_back_prop-26.c +++ b/gcc/testsuite/gcc.target/riscv/rvv/vsetvl/vlmax_back_prop-26.c @@ -10,7 +10,7 @@ void f (void * restrict in, void * restrict out, int n, int cond) *(vint8mf8_t*)(out + 100) = v; for (int i = 0; i < n; i++) { - vint16mf4_t v2; + vint16mf4_t v2 = __riscv_vmv_v_x_i16mf4 (0, __riscv_vsetvlmax_e16mf4 ()); *(vint16mf4_t*)(out + i + 100) = v2; } } else if (cond == 1) { @@ -18,7 +18,7 @@ void f (void * restrict in, void * restrict out, int n, int cond) *(vint8mf8_t*)(out + 200) = v; for (int i = 0; i < n; i++) { - vint32mf2_t v2; + vint32mf2_t v2 = __riscv_vmv_v_x_i32mf2 (0, __riscv_vsetvlmax_e32mf2 ()); *(vint32mf2_t*)(out + i + 200) = v2; } } else if (cond == 2) { @@ -26,7 +26,7 @@ void f (void * restrict in, void * restrict out, int n, int cond) *(vint8mf8_t*)(out + 300) = v; for (int i = 0; i < n; i++) { - vint8mf8_t v2; + vint8mf8_t v2 = __riscv_vmv_v_x_i8mf8 (0, __riscv_vsetvlmax_e8mf8 ()); *(vint8mf8_t*)(out + i + 300) = v2; } } else if (cond == 3) { @@ -34,7 +34,7 @@ void f (void * restrict in, void * restrict out, int n, int cond) *(vint8mf8_t*)(out + 400) = v; for (int i = 0; i < n; i++) { - vint64m1_t v2; + vint64m1_t v2 = __riscv_vmv_v_x_i64m1 (0, __riscv_vsetvlmax_e64m1 ()); *(vint64m1_t*)(out + i + 400) = v2; } } else if (cond == 4) { @@ -42,7 +42,7 @@ void f (void * restrict in, void * restrict out, int n, int cond) *(vint8mf8_t*)(out + 500) = v; for (int i = 0; i < n; i++) { - vfloat32mf2_t v2; + vfloat32mf2_t v2 = __riscv_vfmv_v_f_f32mf2 (0, __riscv_vsetvlmax_e32mf2 ()); *(vfloat32mf2_t*)(out + i + 500) = v2; } } else if (cond == 5) { @@ -50,7 +50,7 @@ void f (void * restrict in, void * restrict out, int n, int cond) *(vuint8mf8_t*)(out + 600) = v; for (int i = 0; i < n; i++) { - vuint16mf4_t v2; + vuint16mf4_t v2 = __riscv_vmv_v_x_u16mf4 (0, __riscv_vsetvlmax_e16mf4 ()); *(vuint16mf4_t*)(out + i + 600) = v2; } } else if (cond == 6) { @@ -58,7 +58,7 @@ void f (void * restrict in, void * restrict out, int n, int cond) *(vuint8mf8_t*)(out + 700) = v; for (int i = 0; i < n; i++) { - vuint32mf2_t v2; + vuint32mf2_t v2 = __riscv_vmv_v_x_u32mf2 (0, __riscv_vsetvlmax_e32mf2 ()); *(vuint32mf2_t*)(out + i + 700) = v2; } } else if (cond == 7) { @@ -66,7 +66,7 @@ void f (void * restrict in, void * restrict out, int n, int cond) *(vuint8mf8_t*)(out + 800) = v; for (int i = 0; i < n; i++) { - vuint8mf8_t v2; + vuint8mf8_t v2 = __riscv_vmv_v_x_u8mf8 (0, __riscv_vsetvlmax_e8mf8 ()); *(vuint8mf8_t*)(out + i + 800) = v2; } } else if (cond == 8) { @@ -74,16 +74,14 @@ void f (void * restrict in, void * restrict out, int n, int cond) *(vuint8mf8_t*)(out + 900) = v; for (int i = 0; i < n; i++) { - vuint64m1_t v2; + vuint64m1_t v2 = *(vuint64m1_t*)(in + i + 9000); *(vuint64m1_t*)(out + i + 900) = v2; } } } -/* { dg-final { scan-assembler-times {vsetvli\s+zero,\s*zero,\s*e32,\s*mf2,\s*t[au],\s*m[au]} 3 { target { no-opts "-O0" no-opts "-O1" no-opts "-Os" no-opts "-Oz" no-opts "-funroll-loops" no-opts "-g" } } } } */ -/* { dg-final { scan-assembler-times {vsetvli\s+zero,\s*zero,\s*e16,\s*mf4,\s*t[au],\s*m[au]} 1 { target { no-opts "-O0" no-opts "-O1" no-opts "-Os" no-opts "-Oz" no-opts "-funroll-loops" no-opts "-g" } } } } */ -/* { dg-final { scan-assembler-times {vsetvli\s+zero,\s*zero,\s*e64,\s*m1,\s*t[au],\s*m[au]} 2 { target { no-opts "-O0" no-opts "-O1" no-opts "-Os" no-opts "-Oz" no-opts "-funroll-loops" no-opts "-g" } } } } */ -/* { dg-final { scan-assembler-times {vsetvli\s+zero,\s*zero,\s*e8,\s*mf8,\s*t[au],\s*m[au]} 2 { target { no-opts "-O0" no-opts "-O1" no-opts "-Os" no-opts "-Oz" no-opts "-funroll-loops" no-opts "-g" } } } } */ -/* { dg-final { scan-assembler-times {vsetvli\s+[a-x0-9]+,\s*zero,\s*e16,\s*mf4,\s*t[au],\s*m[au]} 1 { target { no-opts "-O0" no-opts "-O1" no-opts "-Os" no-opts "-Oz" no-opts "-funroll-loops" no-opts "-g" } } } } */ -/* { dg-final { scan-assembler-times {vsetvli\s+[a-x0-9]+,\s*zero,\s*e8,\s*mf8,\s*t[au],\s*m[au]} 8 { target { no-opts "-O0" no-opts "-O1" no-opts "-Os" no-opts "-Oz" no-opts "-funroll-loops" no-opts "-g" } } } } */ -/* { dg-final { scan-assembler-times {vsetvli} 17 { target { no-opts "-O0" no-opts "-O1" no-opts "-Os" no-opts "-Oz" no-opts "-funroll-loops" no-opts "-g" } } } } */ +/* { dg-final { scan-assembler-times {vsetvli\s+[a-x0-9]+,\s*zero,\s*e8,\s*mf8,\s*t[au],\s*m[au]} 3 { target { no-opts "-O0" no-opts "-O1" no-opts "-Os" no-opts "-Oz" no-opts "-funroll-loops" no-opts "-g" } } } } */ +/* { dg-final { scan-assembler-times {vsetvli\s+[a-x0-9]+,\s*zero,\s*e16,\s*mf4,\s*t[au],\s*m[au]} 2 { target { no-opts "-O0" no-opts "-O1" no-opts "-Os" no-opts "-Oz" no-opts "-funroll-loops" no-opts "-g" } } } } */ +/* { dg-final { scan-assembler-times {vsetvli\s+[a-x0-9]+,\s*zero,\s*e32,\s*mf2,\s*t[au],\s*m[au]} 3 { target { no-opts "-O0" no-opts "-O1" no-opts "-Os" no-opts "-Oz" no-opts "-funroll-loops" no-opts "-g" } } } } */ +/* { dg-final { scan-assembler-times {vsetvli\s+[a-x0-9]+,\s*zero,\s*e64,\s*m1,\s*t[au],\s*m[au]} 1 { target { no-opts "-O0" no-opts "-O1" no-opts "-Os" no-opts "-Oz" no-opts "-funroll-loops" no-opts "-g" } } } } */ +/* { dg-final { scan-assembler-times {vsetvli} 9 { target { no-opts "-O0" no-opts "-O1" no-opts "-Os" no-opts "-Oz" no-opts "-funroll-loops" no-opts "-g" } } } } */ diff --git a/gcc/testsuite/gcc.target/riscv/rvv/vsetvl/vlmax_back_prop-36.c b/gcc/testsuite/gcc.target/riscv/rvv/vsetvl/vlmax_back_prop-36.c index a6009b74101..9be774c958b 100644 --- a/gcc/testsuite/gcc.target/riscv/rvv/vsetvl/vlmax_back_prop-36.c +++ b/gcc/testsuite/gcc.target/riscv/rvv/vsetvl/vlmax_back_prop-36.c @@ -37,7 +37,7 @@ void f (int32_t * restrict in, int32_t * restrict out, int32_t * restrict in2, i } for (int i = 0; i < n; i++) { - vint8mf8_t v1; + vint8mf8_t v1 = *(vint8mf8_t*)(in2 + i + 20); *(vint8mf8_t*)(out + i + 10) = v1; } } diff --git a/gcc/testsuite/gcc.target/riscv/rvv/vsetvl/vlmax_switch_vtype-14.c b/gcc/testsuite/gcc.target/riscv/rvv/vsetvl/vlmax_switch_vtype-14.c index f416a231f0e..1fc97f8b6f2 100644 --- a/gcc/testsuite/gcc.target/riscv/rvv/vsetvl/vlmax_switch_vtype-14.c +++ b/gcc/testsuite/gcc.target/riscv/rvv/vsetvl/vlmax_switch_vtype-14.c @@ -6,7 +6,7 @@ void f (void * restrict in, void * restrict out, int32_t * a, int32_t * b, int n, int cond) { for (int i = 0; i < n; i++) { - vint16mf4_t v; + vint16mf4_t v = __riscv_vmv_v_x_i16mf4 (0, __riscv_vsetvlmax_e16mf4 ()); *(vint16mf4_t*)(out + i + 700) = v; } for (int i = 0; i < n; i++) { @@ -19,15 +19,15 @@ void f (void * restrict in, void * restrict out, int32_t * a, int32_t * b, int n a[i] = a[i] - b[i]; } for (int i = 0; i < n; i++) { - vint32mf2_t v; + vint32mf2_t v = __riscv_vmv_v_x_i32mf2 (0, __riscv_vsetvlmax_e32mf2 ()); *(vint32mf2_t*)(out + i + 7000) = v; } for (int i = 0; i < n; i++) { - vint64m1_t v; + vint64m1_t v = __riscv_vmv_v_x_i64m1 (0, __riscv_vsetvlmax_e64m1 ()); *(vint64m1_t*)(out + i + 8000) = v; } for (int i = 0; i < n; i++) { - vint8mf8_t v; + vint8mf8_t v = __riscv_vmv_v_x_i8mf8 (0, __riscv_vsetvlmax_e8mf8 ()); *(vint8mf8_t*)(out + i + 9000) = v; } } @@ -36,4 +36,4 @@ void f (void * restrict in, void * restrict out, int32_t * a, int32_t * b, int n /* { dg-final { scan-assembler-times {vsetvli\s+zero,\s*zero,\s*e32,\s*mf2,\s*t[au],\s*m[au]} 1 { target { no-opts "-O0" no-opts "-funroll-loops" no-opts "-O1" no-opts "-Os" no-opts "-Oz" no-opts "-flto" no-opts "-g" } } } } */ /* { dg-final { scan-assembler-times {vsetvli\s+zero,\s*zero,\s*e64,\s*m1,\s*t[au],\s*m[au]} 1 { target { no-opts "-O0" no-opts "-funroll-loops" no-opts "-O1" no-opts "-Os" no-opts "-Oz" no-opts "-flto" no-opts "-g" } } } } */ /* { dg-final { scan-assembler-times {vsetvli\s+zero,\s*zero,\s*e8,\s*mf8,\s*t[au],\s*m[au]} 1 { target { no-opts "-O0" no-opts "-funroll-loops" no-opts "-O1" no-opts "-Os" no-opts "-Oz" no-opts "-flto" no-opts "-g" } } } } */ -/* { dg-final { scan-assembler-times {vsetvli} 4 { target { no-opts "-O0" no-opts "-funroll-loops" no-opts "-Os" no-opts "-Oz" no-opts "-flto" no-opts "-g" } } } } */ +/* { dg-final { scan-assembler-times {vsetvli} 4 { target { no-opts "-O0" "-O1" no-opts "-funroll-loops" no-opts "-Os" no-opts "-Oz" no-opts "-flto" no-opts "-g" } } } } */ diff --git a/gcc/testsuite/gcc.target/riscv/rvv/vsetvl/vlmax_switch_vtype-15.c b/gcc/testsuite/gcc.target/riscv/rvv/vsetvl/vlmax_switch_vtype-15.c index a39b48ccb99..f3b37661fbe 100644 --- a/gcc/testsuite/gcc.target/riscv/rvv/vsetvl/vlmax_switch_vtype-15.c +++ b/gcc/testsuite/gcc.target/riscv/rvv/vsetvl/vlmax_switch_vtype-15.c @@ -6,7 +6,7 @@ void f (void * restrict in, void * restrict out, int32_t * a, int32_t * b, int n, int cond) { for (int i = 0; i < n; i++) { - vint16mf4_t v; + vint16mf4_t v = __riscv_vmv_v_x_i16mf4 (0, __riscv_vsetvlmax_e16mf4 ()); *(vint16mf4_t*)(out + i + 700) = v; } for (int i = 0; i < n; i++) { @@ -19,27 +19,27 @@ void f (void * restrict in, void * restrict out, int32_t * a, int32_t * b, int n a[i] = a[i] - b[i]; } for (int i = 0; i < n; i++) { - vint32mf2_t v; + vint32mf2_t v = __riscv_vmv_v_x_i32mf2 (0, __riscv_vsetvlmax_e32mf2 ()); *(vint32mf2_t*)(out + i + 7000) = v; } for (int i = 0; i < n; i++) { - vint16mf2_t v; + vint16mf2_t v = __riscv_vmv_v_x_i16mf2 (0, __riscv_vsetvlmax_e16mf2 ()); *(vint16mf2_t*)(out + i + 777) = v; } for (int i = 0; i < n; i++) { - vint64m1_t v; + vint64m1_t v = __riscv_vmv_v_x_i64m1 (0, __riscv_vsetvlmax_e64m1 ()); *(vint64m1_t*)(out + i + 8000) = v; } for (int i = 0; i < n; i++) { - vfloat32mf2_t v; + vfloat32mf2_t v = __riscv_vfmv_v_f_f32mf2 (0, __riscv_vsetvlmax_e32mf2 ()); *(vfloat32mf2_t*)(out + i + 7777) = v; } for (int i = 0; i < n; i++) { - vuint16mf2_t v; + vuint16mf2_t v = __riscv_vmv_v_x_u16mf2 (0, __riscv_vsetvlmax_e16mf2 ()); *(vuint16mf2_t*)(out + i + 888) = v; } for (int i = 0; i < n; i++) { - vint8mf8_t v; + vint8mf8_t v = __riscv_vmv_v_x_i8mf8 (0, __riscv_vsetvlmax_e8mf8 ()); *(vint8mf8_t*)(out + i + 9000) = v; } }