From patchwork Tue Jun 13 09:14:49 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: 107210 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp405662vqr; Tue, 13 Jun 2023 02:15:41 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7qMTTvz3e1hKOEEyItUUmbkBPRRAqs0xflhd36d/Agq4RYcHlLLsWccu+xFH9QwIYmplhR X-Received: by 2002:a17:907:3da3:b0:971:eb29:a086 with SMTP id he35-20020a1709073da300b00971eb29a086mr12980954ejc.75.1686647741631; Tue, 13 Jun 2023 02:15:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686647741; cv=none; d=google.com; s=arc-20160816; b=CmOPWEs9luIYbUyH9TZJOplQ7XOlR+AMF34/VP/AFWwqgDC4JNb0aoxPFzu9IKE8gF P50C5V9uh5dY3kALax+6aZRackAw/zP10ILN9eL79F4mA/50MlAPBTrPgH+E4NV6UPAB JF2O/8gIZUIQoaiYnFpqOXPVi+h+TIIC/kaDGCfN+S1jss9J0pWjfPIXIsui83gR2Bzi Bp05/AuBqiHnitKyOyW9+nBWCZsBpfQ4NaQbYmwxk4seyvOYiHOPyZHn4oRoV3eeidfN g3VhTsiIJeq4yI1lrTLl6ww7udjEBGNjE4rzg+dsUVHXoTJNfuJ/A1AjNnMWun9+2J9a B2kg== 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=X/7LVHBxydhLTweXDUvmLS48J0ZGlb1N9F2XJB8ee7U=; b=LL7xdw7vR7fNSuzEdwWzuF7W8Zd0/97sNpvPkKEqwu/J1EULRmxaJPHNA40UGOldxN THo/mxZk3z4MQE6lnPcA8bmB3bIYO0ehI07o58XMmDLMwPjo+7FMEgo3yz8B2w2/sWry BAoJhl4U1upOTGHY7E3fOWIfDtJ5V6qOjNr1Q2+oN0RnsL0ozPQK1kzX6hB035DtDSab +sPDh4b0Prb0HzVwNJLKX6L5IQzmBqj7/L6/MTZ1nR2bP6EZy2vOhCm0BYlBj0SvsX/p Tf6+0tjNl47H6LxxZ5skzh/9H5Xw98tdAHFQrn0LZn/vkZKSlMg8mz7hcKALuEdSZ7KS CJTA== 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 sd19-20020a170906ce3300b009788da05d3csi5974045ejb.765.2023.06.13.02.15.41 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Jun 2023 02:15:41 -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 370563858C62 for ; Tue, 13 Jun 2023 09:15:35 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from smtpbg153.qq.com (smtpbg153.qq.com [13.245.218.24]) by sourceware.org (Postfix) with ESMTPS id 164143858414 for ; Tue, 13 Jun 2023 09:15:02 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 164143858414 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: bizesmtp68t1686647692t7zdrplc Received: from server1.localdomain ( [58.60.1.22]) by bizesmtp.qq.com (ESMTP) with id ; Tue, 13 Jun 2023 17:14:51 +0800 (CST) X-QQ-SSF: 01400000000000F0S000000A0000000 X-QQ-FEAT: 90EFqYDyPxCRoXJSCk4gUfCGeuHG3I58xzLv6WQ6Di+ch6SYBf62aA2b7I0ZX CsA4C9npQzX1NcBo9Z/QQ3JUATM+VKtXTyfa2WRRV7lxRhKfML0C4Da9iiUlkX4zCWZUZ1/ MMQ/3uwJ/8SK3JHh3dG2U5SH/6B3lCi7H0kq/zlL7QtC5AD+0Jvy7NW1+AsCCrcPvfAT0s1 z8BQW+9+LI3I/x0s0sM11Xc4ALObeysYE6VMcDm7gJBkYa64tplSd1q4Od1KkpXTBQKKNXV YaktnxapbT2OZh4QSTKy0sNQywG4FbknMULF5hIvzeRGPRExIt6oQKxrLTz6mCrDK4drFmQ V4GnpbsDMotYILg2Bb50GeMW4670ZNjd0oKTEgR7owIZMg8r0kD3IKaNzWgx9KBwaoN9l89 9eWSYarxzgY= X-QQ-GoodBg: 2 X-BIZMAIL-ID: 9659224303416766470 From: juzhe.zhong@rivai.ai To: gcc-patches@gcc.gnu.org Cc: kito.cheng@gmail.com, kito.cheng@sifive.com, palmer@dabbelt.com, palmer@rivosinc.com, jeffreyalaw@gmail.com, rdapp.gcc@gmail.com, Juzhe-Zhong Subject: [PATCH] RISC-V: Add more SLP tests Date: Tue, 13 Jun 2023 17:14:49 +0800 Message-Id: <20230613091449.324764-1-juzhe.zhong@rivai.ai> X-Mailer: git-send-email 2.36.1 MIME-Version: 1.0 X-QQ-SENDSIZE: 520 Feedback-ID: bizesmtp:rivai.ai:qybglogicsvrgz:qybglogicsvrgz7a-one-0 X-Spam-Status: No, score=-10.2 required=5.0 tests=BAYES_00, GIT_PATCH_0, KAM_DMARC_STATUS, KAM_SHORT, RCVD_IN_BARRACUDACENTRAL, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H5, RCVD_IN_MSPIKE_WL, SPF_HELO_PASS, 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+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1768578342211439449?= X-GMAIL-MSGID: =?utf-8?q?1768578342211439449?= From: Juzhe-Zhong gcc/testsuite/ChangeLog: * gcc.target/riscv/rvv/autovec/partial/slp-10.c: New test. * gcc.target/riscv/rvv/autovec/partial/slp-11.c: New test. * gcc.target/riscv/rvv/autovec/partial/slp_run-10.c: New test. * gcc.target/riscv/rvv/autovec/partial/slp_run-11.c: New test. --- .../riscv/rvv/autovec/partial/slp-10.c | 30 ++++++++++++++++++ .../riscv/rvv/autovec/partial/slp-11.c | 31 +++++++++++++++++++ .../riscv/rvv/autovec/partial/slp_run-10.c | 30 ++++++++++++++++++ .../riscv/rvv/autovec/partial/slp_run-11.c | 30 ++++++++++++++++++ 4 files changed, 121 insertions(+) create mode 100644 gcc/testsuite/gcc.target/riscv/rvv/autovec/partial/slp-10.c create mode 100644 gcc/testsuite/gcc.target/riscv/rvv/autovec/partial/slp-11.c create mode 100644 gcc/testsuite/gcc.target/riscv/rvv/autovec/partial/slp_run-10.c create mode 100644 gcc/testsuite/gcc.target/riscv/rvv/autovec/partial/slp_run-11.c diff --git a/gcc/testsuite/gcc.target/riscv/rvv/autovec/partial/slp-10.c b/gcc/testsuite/gcc.target/riscv/rvv/autovec/partial/slp-10.c new file mode 100644 index 00000000000..b33e85c5be2 --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/rvv/autovec/partial/slp-10.c @@ -0,0 +1,30 @@ +/* { dg-do compile } */ +/* { dg-additional-options "-march=rv32gcv -mabi=ilp32d --param riscv-autovec-preference=scalable -fno-vect-cost-model -fdump-tree-optimized-details" } */ + +#include + +#define VEC_PERM(TYPE) \ + TYPE __attribute__ ((noinline, noclone)) \ + vec_slp_##TYPE (TYPE *restrict a, int n) \ + { \ + for (int i = 0; i < n; ++i) \ + { \ + a[i * 2] += 10; \ + a[i * 2 + 1] += 17; \ + } \ + } + +#define TEST_ALL(T) \ + T (int8_t) \ + T (uint8_t) \ + T (int16_t) \ + T (uint16_t) \ + T (int32_t) \ + T (uint32_t) \ + T (int64_t) \ + T (uint64_t) + +TEST_ALL (VEC_PERM) + +/* { dg-final { scan-tree-dump-times "{ 10, 17, ... }" 8 "optimized" } } */ + diff --git a/gcc/testsuite/gcc.target/riscv/rvv/autovec/partial/slp-11.c b/gcc/testsuite/gcc.target/riscv/rvv/autovec/partial/slp-11.c new file mode 100644 index 00000000000..c62eced99f9 --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/rvv/autovec/partial/slp-11.c @@ -0,0 +1,31 @@ +/* { dg-do compile } */ +/* { dg-additional-options "-march=rv32gcv -mabi=ilp32d --param riscv-autovec-preference=scalable -fno-vect-cost-model -fdump-tree-optimized-details" } */ + +#include + +#define VEC_PERM(TYPE) \ + TYPE __attribute__ ((noinline, noclone)) \ + vec_slp_##TYPE (TYPE *restrict a, int n) \ + { \ + for (int i = 0; i < n; ++i) \ + { \ + a[i * 4] += 41; \ + a[i * 4 + 1] += 25; \ + a[i * 4 + 2] += 31; \ + a[i * 4 + 3] += 62; \ + } \ + } + +#define TEST_ALL(T) \ + T (int8_t) \ + T (uint8_t) \ + T (int16_t) \ + T (uint16_t) \ + T (int32_t) \ + T (uint32_t) \ + T (int64_t) \ + T (uint64_t) + +TEST_ALL (VEC_PERM) + +/* { dg-final { scan-tree-dump "{ 41, 25, 31, 62, ... }" "optimized" } } */ diff --git a/gcc/testsuite/gcc.target/riscv/rvv/autovec/partial/slp_run-10.c b/gcc/testsuite/gcc.target/riscv/rvv/autovec/partial/slp_run-10.c new file mode 100644 index 00000000000..24ffc9656b9 --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/rvv/autovec/partial/slp_run-10.c @@ -0,0 +1,30 @@ +/* { dg-do run { target { riscv_vector } } } */ +/* { dg-additional-options "--param riscv-autovec-preference=scalable -fno-vect-cost-model" } */ + +#include "slp-10.c" + +#define N (103 * 2) + +#define HARNESS(TYPE) \ + { \ + TYPE a[N], b[2] = { 10, 17 }; \ + for (unsigned int i = 0; i < N; ++i) \ + { \ + a[i] = i * 2 + i % 5; \ + asm volatile ("" ::: "memory"); \ + } \ + vec_slp_##TYPE (a, N / 2); \ + for (unsigned int i = 0; i < N; ++i) \ + { \ + TYPE orig = i * 2 + i % 5; \ + TYPE expected = orig + b[i % 2]; \ + if (a[i] != expected) \ + __builtin_abort (); \ + } \ + } + +int __attribute__ ((optimize (1))) +main (void) +{ + TEST_ALL (HARNESS) +} diff --git a/gcc/testsuite/gcc.target/riscv/rvv/autovec/partial/slp_run-11.c b/gcc/testsuite/gcc.target/riscv/rvv/autovec/partial/slp_run-11.c new file mode 100644 index 00000000000..3e5fceb7d58 --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/rvv/autovec/partial/slp_run-11.c @@ -0,0 +1,30 @@ +/* { dg-do run { target { riscv_vector } } } */ +/* { dg-additional-options "--param riscv-autovec-preference=scalable -fno-vect-cost-model" } */ + +#include "slp-11.c" + +#define N (77 * 4) + +#define HARNESS(TYPE) \ + { \ + TYPE a[N], b[4] = { 41, 25, 31, 62 }; \ + for (unsigned int i = 0; i < N; ++i) \ + { \ + a[i] = i * 2 + i % 5; \ + asm volatile ("" ::: "memory"); \ + } \ + vec_slp_##TYPE (a, N / 4); \ + for (unsigned int i = 0; i < N; ++i) \ + { \ + TYPE orig = i * 2 + i % 5; \ + TYPE expected = orig + b[i % 4]; \ + if (a[i] != expected) \ + __builtin_abort (); \ + } \ + } + +int __attribute__ ((optimize (1))) +main (void) +{ + TEST_ALL (HARNESS) +}