From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from NAM12-BN8-obe.outbound.protection.outlook.com (mail-bn8nam12olkn2025.outbound.protection.outlook.com [40.92.21.25]) by sourceware.org (Postfix) with ESMTPS id B8CDE3858D33 for ; Thu, 16 Feb 2023 15:12:09 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org B8CDE3858D33 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=outlook.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=outlook.com ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=GxagU8w7COZ5qkv0xf4w3Mmi2QRguwKVauRBGh0V+f2fXj4GxyrR2xCPBjPI586xzdJljU4x/7XL/w5NV1zBTUNkP8XGQqzIcniB9dyPkW9czwXOyACnsfl6COfFKmyj7cDHhvTcmabPjM2BYLWSIjsLhm10KiSq7hRl7GhE8AKMEX0mVY5trWaAOY8Ionqg16ePzyKxL7gSLH6qhuRs+iV5oaHXCa4qmyc5NBjMzI3iy7Tdr1ZjVekGmpQ9WGSDc/FyAoRgo29D4W6x1ruV5En9fjCBs0ggjyB5UJHSjB9ENDssmUbvHUOXRq6KIxwHJ6EB0tGML+XviY199CiHcA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=HLJm40KWKCwpRdJACXRjrojvzbDhijJTbhmTu8mVcI8=; b=fwFI7bMOFskBN3Thhi7aCNqFqlfJA+FBmZ7/w52uP9exEWquzgDcJOtDmtvHMG91U/Z02h1gYofKL5D8c04ZxFtwPEqIshDesHCnoHZ5dxi7SBGHscjyHNmFCAeMOe0Rk00Y/GuvCgfQpZyskxmbmaHVL5u+jIj3xZFWhlT7svsNShz13ehXPz9Msn+VWoqUIFblvzgiuuq8HLUJ8fertueJGhmgEOKXITs8s99NtLFZixA+zxVpzlfaLKR+5sb+iYBMgsGycqjxyF/uafPm5QqcgAVSoZ6j1nRC59p51MnoOlEkoVhF2zd5yZD8/PLBO01r8oYs2zDiQXsrcGiEwQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=outlook.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=HLJm40KWKCwpRdJACXRjrojvzbDhijJTbhmTu8mVcI8=; b=uZCuWy+zUaNCyn6gMBWncruc9vS5d1eS3EN7NyV0QUS1s7P7zDlUE6pLLAp8RcPb7pZsneVBUxB9AZYBGKZc4s7uCt13vV6IxxtSRD0QifMpKiX0FN3bWDQtPkcQOoYkR2tA7c88vhelnmO5sQPWjUvRn0nZt0QLLMY1nk26gnM5uaC2p0BPYR2iCqk1WYGXgrdPPQrLniaY+D3W8GGMaRsuT66XsafT1F08B0Kvervx+Jev1eW+G+KGSXaO5xQjdCjf4R4PjW7MSPWliI/Qqz1XU0GgTQKyPJmXJNvkH+QLq5jQxnOOzY75iMTfC8Mq/YtDcZwk/cyH42GfeOZGeA== Received: from BYAPR04MB4824.namprd04.prod.outlook.com (2603:10b6:a03:5e::19) by BY5PR04MB6770.namprd04.prod.outlook.com (2603:10b6:a03:220::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6086.26; Thu, 16 Feb 2023 15:12:06 +0000 Received: from BYAPR04MB4824.namprd04.prod.outlook.com ([fe80::3a96:d832:ac44:1c25]) by BYAPR04MB4824.namprd04.prod.outlook.com ([fe80::3a96:d832:ac44:1c25%7]) with mapi id 15.20.6086.023; Thu, 16 Feb 2023 15:12:06 +0000 From: incarnation.p.lee@outlook.com To: gcc-patches@gcc.gnu.org Cc: juzhe.zhong@rivai.ai, kito.cheng@sifive.com, rguenther@suse.de, pan2.li@intel.com Subject: [PATCH] RISC-V: Bugfix for rvv bool mode precision adjustment Date: Thu, 16 Feb 2023 23:11:50 +0800 Message-ID: X-Mailer: git-send-email 2.34.1 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-TMN: [ShOrg8tzZ4ppWtGiU8NjMaKcyhBmYApn] X-ClientProxiedBy: SG2PR04CA0170.apcprd04.prod.outlook.com (2603:1096:4::32) To BYAPR04MB4824.namprd04.prod.outlook.com (2603:10b6:a03:5e::19) X-Microsoft-Original-Message-ID: <20230216151150.1192493-1-incarnation.p.lee@outlook.com> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BYAPR04MB4824:EE_|BY5PR04MB6770:EE_ X-MS-Office365-Filtering-Correlation-Id: 12235378-f377-41f9-47b9-08db10302a88 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: CDwXY1aAuCRqJeeC7A+wOLQQhgeKd1V8gQhtKwo3T6fKzbPHzH2hpU0qJJGkNwzdwUmQdvOoozJfbXWqZVQKCSDHdwXyNXXG+QRjAi+4RMY8GBeuKD/vJx4n88MgTSkKbF6Mm2rTSya9ZVeZKp3AGoRL5RgefnljSMPKeMp2tn0nCJ/nsaE9jYHTjnzHsrD8761L0GjGwrEU2DN1RtBTcIM0qrsD/UJvreuNYXkUKKnEkdXcuB0uLd2upt6Q83icPgJyj9GAYaJgv2OS743DyVbkxScUr6XCqBMlkHtVAHtovD9UolCWFyRAnuAQdRrg6EkgSRtStbbJkyJOnGJ+Z44Rfj70J7DooMxRd0MavdSovZr8RiyLzPAtEBdxbJF4zcSMeMqCVWxZWxRKpXyQs898WjcndoG7bV1LXr0q83umJCWjErOQN1YUQIUIMB5NJ5xrQxEGvvzkhLUojydkbN20jIyGp+x7TqE5n2XuJOlsULJytbYr8gNiEYcfhUdTYGD6w7UbXhPFl+csd3r6AuDCeEqIF3YGO28qedOLyONXsJ/rJhW4walkJo+6Id5FrMwEBGqWmNYLUJ9XVrEmoA== X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?cItmbjpYzB+GgFS7CIaAKiB3zEZus7CFuH3BYqPouDzxHE1v1x6U1H3cbNsh?= =?us-ascii?Q?zaWXQJueqCWx1vyAh/LvZ40kqjqsuE7fsODJgzvba2TvOB2NaIf/VU3drLWE?= =?us-ascii?Q?16dYNqYvaqaT/WO796la7x2eJSUs0owKM1A2czZTFax8bsx/VPiO2MPxs9SZ?= =?us-ascii?Q?CbP7L3Xq7eBlnONTEnzxHNRoI/sPmEJvOF+ZxEBMPfWF5AuzKd7IFNb8OiVe?= =?us-ascii?Q?UVG3aGPBDI6jJ04lk+/pvk8i1kGaxEUzzn9+fokyQtchirpDnyFZDFL8fwJI?= =?us-ascii?Q?VKi5opPPcK0LrcHOGFmpM3NXTQP5axToRess+bM65LSsz8pMvb+3VOfK08R4?= =?us-ascii?Q?YMAKql+FPlaL+esaKAOd4tMF8IpKnf4PeSuy9cOm7OxbcrJhCW+JPYsPgtAM?= =?us-ascii?Q?wAricOeQu5AP/84RWbwMqZ0Ij8BTOQMoxjcr/0BgjKv+GoZseX7SF/c2OAyF?= =?us-ascii?Q?isvgudMfvtTFdNVl4Ntix0tjcc3ySGrujud5MJ8inVzu6f9r76EAV8fgqLxi?= =?us-ascii?Q?9wfM9i2fiNPvwEAckuu7eBJjXrGxk2SI55EXV0JMMaecOhQuD9ut1pMD+Gxa?= =?us-ascii?Q?kRUixaseLN/SYZR+YTsRoT3lQbpE4oOYLs8oScj/QupgQI+q8YG6Za8pTzra?= =?us-ascii?Q?QeIZ3RLId08Qqjl1BFKGqFbAKeUvRiS/2Ryq/sMr57t4Cri0aKjAKasau/do?= =?us-ascii?Q?Z11SB2yCnkJdVvplczr13tpYmBTLMe1tB2zdEqMc+y6B8RAeBqOxTljIjuS6?= =?us-ascii?Q?ZegUAw/7Luan4qdjKaGQSrKVGrrAXSI58SEx3LZoUkhjHoJMr3uuKxNrUwNc?= =?us-ascii?Q?eg7EdedR6z3jiG/W/qK5yWWxMY+I5Y5bNDvqZxHv0bphmRP4Zs99vuLIjXMg?= =?us-ascii?Q?O+bjOdtTcSZasCHY46pk5Vn32/xlPCMfrOzZYy3oMrQ+lOjksdOTTD90SWkg?= =?us-ascii?Q?F9IEGobx80cHrPVhoEuIUA6Y4orWw0uADV8EIT6ZzhJmR7c6TuKhbOKOKHOR?= =?us-ascii?Q?M92QSHoEz2iTUiM893cHPAm5GLjz5ikq06A4Ba+iBXyNQHTNHahokZ7pU2X+?= =?us-ascii?Q?U+xVKHKQdUsmkaj8bRKgiJwrUvUiqtjJrKqITyv6KKTKpeLCopLRu+4aOhZ1?= =?us-ascii?Q?8y6Dec+fD6PT9/JwFgHvhigLEo4XnqoIO2LYQ9WwgYxZhMBP/AoyMq84ZE+e?= =?us-ascii?Q?TfPSp6BFFwQV0dV0IE2RED6Y8Dn7J278qGh3Ba/GVeFpKPe/yDC4yF9Mmp5q?= =?us-ascii?Q?K3btu/jpswdPyz6m8md+OZT63LVDldI8WlE/iB74N23WJhOPHb/IA39dLyOR?= =?us-ascii?Q?ttQ=3D?= X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 12235378-f377-41f9-47b9-08db10302a88 X-MS-Exchange-CrossTenant-AuthSource: BYAPR04MB4824.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Feb 2023 15:12:06.6730 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-CrossTenant-RMS-PersistedConsumerOrg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY5PR04MB6770 X-Spam-Status: No, score=-9.0 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,GIT_PATCH_0,KAM_SHORT,RCVD_IN_DNSWL_NONE,SCC_10_SHORT_WORD_LINES,SCC_20_SHORT_WORD_LINES,SCC_35_SHORT_WORD_LINES,SCC_5_SHORT_WORD_LINES,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 List-Id: From: Pan Li Fix the bug of the rvv bool mode precision with the adjustment. The bits size of vbool*_t will be adjusted to [1, 2, 4, 8, 16, 32, 64] according to the rvv spec 1.0 isa. The adjusted mode precison of vbool*_t will help underlying pass to make the right decision for both the correctness and optimization. Given below sample code: void test_1(int8_t * restrict in, int8_t * restrict out) { vbool8_t v2 = *(vbool8_t*)in; vbool16_t v5 = *(vbool16_t*)in; *(vbool16_t*)(out + 200) = v5; *(vbool8_t*)(out + 100) = v2; } Before the precision adjustment: addi a4,a1,100 vsetvli a5,zero,e8,m1,ta,ma addi a1,a1,200 vlm.v v24,0(a0) vsm.v v24,0(a4) // Need one vsetvli and vlm.v for correctness here. vsm.v v24,0(a1) After the precision adjustment: csrr t0,vlenb slli t1,t0,1 csrr a3,vlenb sub sp,sp,t1 slli a4,a3,1 add a4,a4,sp sub a3,a4,a3 vsetvli a5,zero,e8,m1,ta,ma addi a2,a1,200 vlm.v v24,0(a0) vsm.v v24,0(a3) addi a1,a1,100 vsetvli a4,zero,e8,mf2,ta,ma csrr t0,vlenb vlm.v v25,0(a3) vsm.v v25,0(a2) slli t1,t0,1 vsetvli a5,zero,e8,m1,ta,ma vsm.v v24,0(a1) add sp,sp,t1 jr ra However, there may be some optimization opportunates after the mode precision adjustment. It can be token care of in the RISC-V backend in the underlying separted PR(s). PR 108185 PR 108654 gcc/ChangeLog: * config/riscv/riscv-modes.def (ADJUST_PRECISION): * config/riscv/riscv.cc (riscv_v_adjust_precision): * config/riscv/riscv.h (riscv_v_adjust_precision): * genmodes.cc (ADJUST_PRECISION): (emit_mode_adjustments): gcc/testsuite/ChangeLog: * gcc.target/riscv/pr108185-1.c: New test. * gcc.target/riscv/pr108185-2.c: New test. * gcc.target/riscv/pr108185-3.c: New test. * gcc.target/riscv/pr108185-4.c: New test. * gcc.target/riscv/pr108185-5.c: New test. * gcc.target/riscv/pr108185-6.c: New test. * gcc.target/riscv/pr108185-7.c: New test. * gcc.target/riscv/pr108185-8.c: New test. Signed-off-by: Pan Li --- gcc/config/riscv/riscv-modes.def | 8 +++ gcc/config/riscv/riscv.cc | 12 ++++ gcc/config/riscv/riscv.h | 1 + gcc/genmodes.cc | 25 ++++++- gcc/testsuite/gcc.target/riscv/pr108185-1.c | 68 ++++++++++++++++++ gcc/testsuite/gcc.target/riscv/pr108185-2.c | 68 ++++++++++++++++++ gcc/testsuite/gcc.target/riscv/pr108185-3.c | 68 ++++++++++++++++++ gcc/testsuite/gcc.target/riscv/pr108185-4.c | 68 ++++++++++++++++++ gcc/testsuite/gcc.target/riscv/pr108185-5.c | 68 ++++++++++++++++++ gcc/testsuite/gcc.target/riscv/pr108185-6.c | 68 ++++++++++++++++++ gcc/testsuite/gcc.target/riscv/pr108185-7.c | 68 ++++++++++++++++++ gcc/testsuite/gcc.target/riscv/pr108185-8.c | 77 +++++++++++++++++++++ 12 files changed, 598 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/gcc.target/riscv/pr108185-1.c create mode 100644 gcc/testsuite/gcc.target/riscv/pr108185-2.c create mode 100644 gcc/testsuite/gcc.target/riscv/pr108185-3.c create mode 100644 gcc/testsuite/gcc.target/riscv/pr108185-4.c create mode 100644 gcc/testsuite/gcc.target/riscv/pr108185-5.c create mode 100644 gcc/testsuite/gcc.target/riscv/pr108185-6.c create mode 100644 gcc/testsuite/gcc.target/riscv/pr108185-7.c create mode 100644 gcc/testsuite/gcc.target/riscv/pr108185-8.c diff --git a/gcc/config/riscv/riscv-modes.def b/gcc/config/riscv/riscv-modes.def index d5305efa8a6..110bddce851 100644 --- a/gcc/config/riscv/riscv-modes.def +++ b/gcc/config/riscv/riscv-modes.def @@ -72,6 +72,14 @@ ADJUST_BYTESIZE (VNx16BI, riscv_vector_chunks * riscv_bytes_per_vector_chunk); ADJUST_BYTESIZE (VNx32BI, riscv_vector_chunks * riscv_bytes_per_vector_chunk); ADJUST_BYTESIZE (VNx64BI, riscv_v_adjust_nunits (VNx64BImode, 8)); +ADJUST_PRECISION (VNx1BI, riscv_v_adjust_precision (VNx1BImode, 1)); +ADJUST_PRECISION (VNx2BI, riscv_v_adjust_precision (VNx2BImode, 2)); +ADJUST_PRECISION (VNx4BI, riscv_v_adjust_precision (VNx4BImode, 4)); +ADJUST_PRECISION (VNx8BI, riscv_v_adjust_precision (VNx8BImode, 8)); +ADJUST_PRECISION (VNx16BI, riscv_v_adjust_precision (VNx16BImode, 16)); +ADJUST_PRECISION (VNx32BI, riscv_v_adjust_precision (VNx32BImode, 32)); +ADJUST_PRECISION (VNx64BI, riscv_v_adjust_precision (VNx64BImode, 64)); + /* | Mode | MIN_VLEN=32 | MIN_VLEN=32 | MIN_VLEN=64 | MIN_VLEN=64 | | | LMUL | SEW/LMUL | LMUL | SEW/LMUL | diff --git a/gcc/config/riscv/riscv.cc b/gcc/config/riscv/riscv.cc index de3e1f903c7..cbe66c0e35b 100644 --- a/gcc/config/riscv/riscv.cc +++ b/gcc/config/riscv/riscv.cc @@ -1003,6 +1003,18 @@ riscv_v_adjust_nunits (machine_mode mode, int scale) return scale; } +/* Call from ADJUST_PRECISION in riscv-modes.def. Return the correct + PRECISION size for corresponding machine_mode. */ + +poly_int64 +riscv_v_adjust_precision (machine_mode mode, int scale) +{ + if (riscv_v_ext_vector_mode_p (mode)) + return riscv_vector_chunks * scale; + + return scale; +} + /* Return true if X is a valid address for machine mode MODE. If it is, fill in INFO appropriately. STRICT_P is true if REG_OK_STRICT is in effect. */ diff --git a/gcc/config/riscv/riscv.h b/gcc/config/riscv/riscv.h index 5bc7f2f467d..15b9317a8ce 100644 --- a/gcc/config/riscv/riscv.h +++ b/gcc/config/riscv/riscv.h @@ -1025,6 +1025,7 @@ extern unsigned riscv_stack_boundary; extern unsigned riscv_bytes_per_vector_chunk; extern poly_uint16 riscv_vector_chunks; extern poly_int64 riscv_v_adjust_nunits (enum machine_mode, int); +extern poly_int64 riscv_v_adjust_precision (enum machine_mode, int); /* The number of bits and bytes in a RVV vector. */ #define BITS_PER_RISCV_VECTOR (poly_uint16 (riscv_vector_chunks * riscv_bytes_per_vector_chunk * 8)) #define BYTES_PER_RISCV_VECTOR (poly_uint16 (riscv_vector_chunks * riscv_bytes_per_vector_chunk)) diff --git a/gcc/genmodes.cc b/gcc/genmodes.cc index 2d418f09aab..12f4e6335e6 100644 --- a/gcc/genmodes.cc +++ b/gcc/genmodes.cc @@ -114,6 +114,7 @@ static struct mode_adjust *adj_alignment; static struct mode_adjust *adj_format; static struct mode_adjust *adj_ibit; static struct mode_adjust *adj_fbit; +static struct mode_adjust *adj_precision; /* Mode class operations. */ static enum mode_class @@ -819,6 +820,7 @@ make_vector_mode (enum mode_class bclass, #define ADJUST_NUNITS(M, X) _ADD_ADJUST (nunits, M, X, RANDOM, RANDOM) #define ADJUST_BYTESIZE(M, X) _ADD_ADJUST (bytesize, M, X, RANDOM, RANDOM) #define ADJUST_ALIGNMENT(M, X) _ADD_ADJUST (alignment, M, X, RANDOM, RANDOM) +#define ADJUST_PRECISION(M, X) _ADD_ADJUST (precision, M, X, RANDOM, RANDOM) #define ADJUST_FLOAT_FORMAT(M, X) _ADD_ADJUST (format, M, X, FLOAT, FLOAT) #define ADJUST_IBIT(M, X) _ADD_ADJUST (ibit, M, X, ACCUM, UACCUM) #define ADJUST_FBIT(M, X) _ADD_ADJUST (fbit, M, X, FRACT, UACCUM) @@ -1829,7 +1831,15 @@ emit_mode_adjustments (void) " (mode_precision[E_%smode], mode_nunits[E_%smode]);\n", m->name, m->name); printf (" mode_precision[E_%smode] = ps * old_factor;\n", m->name); - printf (" mode_size[E_%smode] = exact_div (mode_precision[E_%smode]," + /* Normalize the size to 1 if precison is less than BITS_PER_UNIT. */ + printf (" poly_uint16 size_one = " + "mode_precision[E_%smode].is_constant ()\n", m->name); + printf (" ? poly_uint16 (1, 0) : poly_uint16 (1, 1);\n"); + printf (" if (known_lt (mode_precision[E_%smode], " + "size_one * BITS_PER_UNIT))\n", m->name); + printf (" mode_size[E_%smode] = size_one;\n", m->name); + printf (" else\n"); + printf (" mode_size[E_%smode] = exact_div (mode_precision[E_%smode]," " BITS_PER_UNIT);\n", m->name, m->name); printf (" mode_nunits[E_%smode] = ps;\n", m->name); printf (" adjust_mode_mask (E_%smode);\n", m->name); @@ -1963,6 +1973,19 @@ emit_mode_adjustments (void) printf ("\n /* %s:%d */\n REAL_MODE_FORMAT (E_%smode) = %s;\n", a->file, a->line, a->mode->name, a->adjustment); + /* Adjust precision to the actual bits size. */ + for (a = adj_precision; a; a = a->next) + switch (a->mode->cl) + { + case MODE_VECTOR_BOOL: + printf ("\n /* %s:%d. */\n ps = %s;\n", a->file, a->line, + a->adjustment); + printf (" mode_precision[E_%smode] = ps;\n", a->mode->name); + break; + default: + break; + } + puts ("}"); } diff --git a/gcc/testsuite/gcc.target/riscv/pr108185-1.c b/gcc/testsuite/gcc.target/riscv/pr108185-1.c new file mode 100644 index 00000000000..e70960c5b6d --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/pr108185-1.c @@ -0,0 +1,68 @@ +/* { dg-do compile } */ +/* { dg-options "-march=rv64gcv -mabi=lp64 -O3" } */ + +#include "riscv_vector.h" + +void +test_vbool1_then_vbool2(int8_t * restrict in, int8_t * restrict out) { + vbool1_t v1 = *(vbool1_t*)in; + vbool2_t v2 = *(vbool2_t*)in; + + *(vbool1_t*)(out + 100) = v1; + *(vbool2_t*)(out + 200) = v2; +} + +void +test_vbool1_then_vbool4(int8_t * restrict in, int8_t * restrict out) { + vbool1_t v1 = *(vbool1_t*)in; + vbool4_t v2 = *(vbool4_t*)in; + + *(vbool1_t*)(out + 100) = v1; + *(vbool4_t*)(out + 200) = v2; +} + +void +test_vbool1_then_vbool8(int8_t * restrict in, int8_t * restrict out) { + vbool1_t v1 = *(vbool1_t*)in; + vbool8_t v2 = *(vbool8_t*)in; + + *(vbool1_t*)(out + 100) = v1; + *(vbool8_t*)(out + 200) = v2; +} + +void +test_vbool1_then_vbool16(int8_t * restrict in, int8_t * restrict out) { + vbool1_t v1 = *(vbool1_t*)in; + vbool16_t v2 = *(vbool16_t*)in; + + *(vbool1_t*)(out + 100) = v1; + *(vbool16_t*)(out + 200) = v2; +} + +void +test_vbool1_then_vbool32(int8_t * restrict in, int8_t * restrict out) { + vbool1_t v1 = *(vbool1_t*)in; + vbool32_t v2 = *(vbool32_t*)in; + + *(vbool1_t*)(out + 100) = v1; + *(vbool32_t*)(out + 200) = v2; +} + +void +test_vbool1_then_vbool64(int8_t * restrict in, int8_t * restrict out) { + vbool1_t v1 = *(vbool1_t*)in; + vbool64_t v2 = *(vbool64_t*)in; + + *(vbool1_t*)(out + 100) = v1; + *(vbool64_t*)(out + 200) = v2; +} + +/* { dg-final { scan-assembler-times {vsetvli\s+[a-x][0-9]+,\s*zero,\s*e8,\s*m8,\s*ta,\s*ma} 6 } } */ +/* { dg-final { scan-assembler-times {vsetvli\s+[a-x][0-9]+,\s*zero,\s*e8,\s*m4,\s*ta,\s*ma} 1 } } */ +/* { dg-final { scan-assembler-times {vsetvli\s+[a-x][0-9]+,\s*zero,\s*e8,\s*m2,\s*ta,\s*ma} 1 } } */ +/* { dg-final { scan-assembler-times {vsetvli\s+[a-x][0-9]+,\s*zero,\s*e8,\s*m1,\s*ta,\s*ma} 1 } } */ +/* { dg-final { scan-assembler-times {vsetvli\s+[a-x][0-9]+,\s*zero,\s*e8,\s*mf2,\s*ta,\s*ma} 1 } } */ +/* { dg-final { scan-assembler-times {vsetvli\s+[a-x][0-9]+,\s*zero,\s*e8,\s*mf4,\s*ta,\s*ma} 1 } } */ +/* { dg-final { scan-assembler-times {vsetvli\s+[a-x][0-9]+,\s*zero,\s*e8,\s*mf8,\s*ta,\s*ma} 1 } } */ +/* { dg-final { scan-assembler-times {vlm\.v\s+v[0-9]+,\s*0\([a-x][0-9]+\)} 12 } } */ +/* { dg-final { scan-assembler-times {vsm\.v\s+v[0-9]+,\s*0\([a-x][0-9]+\)} 18 } } */ diff --git a/gcc/testsuite/gcc.target/riscv/pr108185-2.c b/gcc/testsuite/gcc.target/riscv/pr108185-2.c new file mode 100644 index 00000000000..dcc7a644a88 --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/pr108185-2.c @@ -0,0 +1,68 @@ +/* { dg-do compile } */ +/* { dg-options "-march=rv64gcv -mabi=lp64 -O3" } */ + +#include "riscv_vector.h" + +void +test_vbool2_then_vbool1(int8_t * restrict in, int8_t * restrict out) { + vbool2_t v1 = *(vbool2_t*)in; + vbool1_t v2 = *(vbool1_t*)in; + + *(vbool2_t*)(out + 100) = v1; + *(vbool1_t*)(out + 200) = v2; +} + +void +test_vbool2_then_vbool4(int8_t * restrict in, int8_t * restrict out) { + vbool2_t v1 = *(vbool2_t*)in; + vbool4_t v2 = *(vbool4_t*)in; + + *(vbool2_t*)(out + 100) = v1; + *(vbool4_t*)(out + 200) = v2; +} + +void +test_vbool2_then_vbool8(int8_t * restrict in, int8_t * restrict out) { + vbool2_t v1 = *(vbool2_t*)in; + vbool8_t v2 = *(vbool8_t*)in; + + *(vbool2_t*)(out + 100) = v1; + *(vbool8_t*)(out + 200) = v2; +} + +void +test_vbool2_then_vbool16(int8_t * restrict in, int8_t * restrict out) { + vbool2_t v1 = *(vbool2_t*)in; + vbool16_t v2 = *(vbool16_t*)in; + + *(vbool2_t*)(out + 100) = v1; + *(vbool16_t*)(out + 200) = v2; +} + +void +test_vbool2_then_vbool32(int8_t * restrict in, int8_t * restrict out) { + vbool2_t v1 = *(vbool2_t*)in; + vbool32_t v2 = *(vbool32_t*)in; + + *(vbool2_t*)(out + 100) = v1; + *(vbool32_t*)(out + 200) = v2; +} + +void +test_vbool2_then_vbool64(int8_t * restrict in, int8_t * restrict out) { + vbool2_t v1 = *(vbool2_t*)in; + vbool64_t v2 = *(vbool64_t*)in; + + *(vbool2_t*)(out + 100) = v1; + *(vbool64_t*)(out + 200) = v2; +} + +/* { dg-final { scan-assembler-times {vsetvli\s+[a-x][0-9]+,\s*zero,\s*e8,\s*m4,\s*ta,\s*ma} 6 } } */ +/* { dg-final { scan-assembler-times {vsetvli\s+[a-x][0-9]+,\s*zero,\s*e8,\s*m2,\s*ta,\s*ma} 1 } } */ +/* { dg-final { scan-assembler-times {vsetvli\s+[a-x][0-9]+,\s*zero,\s*e8,\s*m1,\s*ta,\s*ma} 1 } } */ +/* { dg-final { scan-assembler-times {vsetvli\s+[a-x][0-9]+,\s*zero,\s*e8,\s*m8,\s*ta,\s*ma} 1 } } */ +/* { dg-final { scan-assembler-times {vsetvli\s+[a-x][0-9]+,\s*zero,\s*e8,\s*mf2,\s*ta,\s*ma} 1 } } */ +/* { dg-final { scan-assembler-times {vsetvli\s+[a-x][0-9]+,\s*zero,\s*e8,\s*mf4,\s*ta,\s*ma} 1 } } */ +/* { dg-final { scan-assembler-times {vsetvli\s+[a-x][0-9]+,\s*zero,\s*e8,\s*mf8,\s*ta,\s*ma} 1 } } */ +/* { dg-final { scan-assembler-times {vlm\.v\s+v[0-9]+,\s*0\([a-x][0-9]+\)} 12 } } */ +/* { dg-final { scan-assembler-times {vsm\.v\s+v[0-9]+,\s*0\([a-x][0-9]+\)} 17 } } */ diff --git a/gcc/testsuite/gcc.target/riscv/pr108185-3.c b/gcc/testsuite/gcc.target/riscv/pr108185-3.c new file mode 100644 index 00000000000..3af0513e006 --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/pr108185-3.c @@ -0,0 +1,68 @@ +/* { dg-do compile } */ +/* { dg-options "-march=rv64gcv -mabi=lp64 -O3" } */ + +#include "riscv_vector.h" + +void +test_vbool4_then_vbool1(int8_t * restrict in, int8_t * restrict out) { + vbool4_t v1 = *(vbool4_t*)in; + vbool1_t v2 = *(vbool1_t*)in; + + *(vbool4_t*)(out + 100) = v1; + *(vbool1_t*)(out + 200) = v2; +} + +void +test_vbool4_then_vbool2(int8_t * restrict in, int8_t * restrict out) { + vbool4_t v1 = *(vbool4_t*)in; + vbool2_t v2 = *(vbool2_t*)in; + + *(vbool4_t*)(out + 100) = v1; + *(vbool2_t*)(out + 200) = v2; +} + +void +test_vbool4_then_vbool8(int8_t * restrict in, int8_t * restrict out) { + vbool4_t v1 = *(vbool4_t*)in; + vbool8_t v2 = *(vbool8_t*)in; + + *(vbool4_t*)(out + 100) = v1; + *(vbool8_t*)(out + 200) = v2; +} + +void +test_vbool4_then_vbool16(int8_t * restrict in, int8_t * restrict out) { + vbool4_t v1 = *(vbool4_t*)in; + vbool16_t v2 = *(vbool16_t*)in; + + *(vbool4_t*)(out + 100) = v1; + *(vbool16_t*)(out + 200) = v2; +} + +void +test_vbool4_then_vbool32(int8_t * restrict in, int8_t * restrict out) { + vbool4_t v1 = *(vbool4_t*)in; + vbool32_t v2 = *(vbool32_t*)in; + + *(vbool4_t*)(out + 100) = v1; + *(vbool32_t*)(out + 200) = v2; +} + +void +test_vbool4_then_vbool64(int8_t * restrict in, int8_t * restrict out) { + vbool4_t v1 = *(vbool4_t*)in; + vbool64_t v2 = *(vbool64_t*)in; + + *(vbool4_t*)(out + 100) = v1; + *(vbool64_t*)(out + 200) = v2; +} + +/* { dg-final { scan-assembler-times {vsetvli\s+[a-x][0-9]+,\s*zero,\s*e8,\s*m2,\s*ta,\s*ma} 6 } } */ +/* { dg-final { scan-assembler-times {vsetvli\s+[a-x][0-9]+,\s*zero,\s*e8,\s*m8,\s*ta,\s*ma} 1 } } */ +/* { dg-final { scan-assembler-times {vsetvli\s+[a-x][0-9]+,\s*zero,\s*e8,\s*m4,\s*ta,\s*ma} 1 } } */ +/* { dg-final { scan-assembler-times {vsetvli\s+[a-x][0-9]+,\s*zero,\s*e8,\s*m1,\s*ta,\s*ma} 1 } } */ +/* { dg-final { scan-assembler-times {vsetvli\s+[a-x][0-9]+,\s*zero,\s*e8,\s*mf2,\s*ta,\s*ma} 1 } } */ +/* { dg-final { scan-assembler-times {vsetvli\s+[a-x][0-9]+,\s*zero,\s*e8,\s*mf4,\s*ta,\s*ma} 1 } } */ +/* { dg-final { scan-assembler-times {vsetvli\s+[a-x][0-9]+,\s*zero,\s*e8,\s*mf8,\s*ta,\s*ma} 1 } } */ +/* { dg-final { scan-assembler-times {vlm\.v\s+v[0-9]+,\s*0\([a-x][0-9]+\)} 12 } } */ +/* { dg-final { scan-assembler-times {vsm\.v\s+v[0-9]+,\s*0\([a-x][0-9]+\)} 16 } } */ diff --git a/gcc/testsuite/gcc.target/riscv/pr108185-4.c b/gcc/testsuite/gcc.target/riscv/pr108185-4.c new file mode 100644 index 00000000000..ea3c360d756 --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/pr108185-4.c @@ -0,0 +1,68 @@ +/* { dg-do compile } */ +/* { dg-options "-march=rv64gcv -mabi=lp64 -O3" } */ + +#include "riscv_vector.h" + +void +test_vbool8_then_vbool1(int8_t * restrict in, int8_t * restrict out) { + vbool8_t v1 = *(vbool8_t*)in; + vbool1_t v2 = *(vbool1_t*)in; + + *(vbool8_t*)(out + 100) = v1; + *(vbool1_t*)(out + 200) = v2; +} + +void +test_vbool8_then_vbool2(int8_t * restrict in, int8_t * restrict out) { + vbool8_t v1 = *(vbool8_t*)in; + vbool2_t v2 = *(vbool2_t*)in; + + *(vbool8_t*)(out + 100) = v1; + *(vbool2_t*)(out + 200) = v2; +} + +void +test_vbool8_then_vbool4(int8_t * restrict in, int8_t * restrict out) { + vbool8_t v1 = *(vbool8_t*)in; + vbool4_t v2 = *(vbool4_t*)in; + + *(vbool8_t*)(out + 100) = v1; + *(vbool4_t*)(out + 200) = v2; +} + +void +test_vbool8_then_vbool16(int8_t * restrict in, int8_t * restrict out) { + vbool8_t v1 = *(vbool8_t*)in; + vbool16_t v2 = *(vbool16_t*)in; + + *(vbool8_t*)(out + 100) = v1; + *(vbool16_t*)(out + 200) = v2; +} + +void +test_vbool8_then_vbool32(int8_t * restrict in, int8_t * restrict out) { + vbool8_t v1 = *(vbool8_t*)in; + vbool32_t v2 = *(vbool32_t*)in; + + *(vbool8_t*)(out + 100) = v1; + *(vbool32_t*)(out + 200) = v2; +} + +void +test_vbool8_then_vbool64(int8_t * restrict in, int8_t * restrict out) { + vbool8_t v1 = *(vbool8_t*)in; + vbool64_t v2 = *(vbool64_t*)in; + + *(vbool8_t*)(out + 100) = v1; + *(vbool64_t*)(out + 200) = v2; +} + +/* { dg-final { scan-assembler-times {vsetvli\s+[a-x][0-9]+,\s*zero,\s*e8,\s*m1,\s*ta,\s*ma} 6 } } */ +/* { dg-final { scan-assembler-times {vsetvli\s+[a-x][0-9]+,\s*zero,\s*e8,\s*m2,\s*ta,\s*ma} 1 } } */ +/* { dg-final { scan-assembler-times {vsetvli\s+[a-x][0-9]+,\s*zero,\s*e8,\s*m8,\s*ta,\s*ma} 1 } } */ +/* { dg-final { scan-assembler-times {vsetvli\s+[a-x][0-9]+,\s*zero,\s*e8,\s*m4,\s*ta,\s*ma} 1 } } */ +/* { dg-final { scan-assembler-times {vsetvli\s+[a-x][0-9]+,\s*zero,\s*e8,\s*mf2,\s*ta,\s*ma} 1 } } */ +/* { dg-final { scan-assembler-times {vsetvli\s+[a-x][0-9]+,\s*zero,\s*e8,\s*mf4,\s*ta,\s*ma} 1 } } */ +/* { dg-final { scan-assembler-times {vsetvli\s+[a-x][0-9]+,\s*zero,\s*e8,\s*mf8,\s*ta,\s*ma} 1 } } */ +/* { dg-final { scan-assembler-times {vlm\.v\s+v[0-9]+,\s*0\([a-x][0-9]+\)} 12 } } */ +/* { dg-final { scan-assembler-times {vsm\.v\s+v[0-9]+,\s*0\([a-x][0-9]+\)} 15 } } */ diff --git a/gcc/testsuite/gcc.target/riscv/pr108185-5.c b/gcc/testsuite/gcc.target/riscv/pr108185-5.c new file mode 100644 index 00000000000..9fc659d2402 --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/pr108185-5.c @@ -0,0 +1,68 @@ +/* { dg-do compile } */ +/* { dg-options "-march=rv64gcv -mabi=lp64 -O3" } */ + +#include "riscv_vector.h" + +void +test_vbool16_then_vbool1(int8_t * restrict in, int8_t * restrict out) { + vbool16_t v1 = *(vbool16_t*)in; + vbool1_t v2 = *(vbool1_t*)in; + + *(vbool16_t*)(out + 100) = v1; + *(vbool1_t*)(out + 200) = v2; +} + +void +test_vbool16_then_vbool2(int8_t * restrict in, int8_t * restrict out) { + vbool16_t v1 = *(vbool16_t*)in; + vbool2_t v2 = *(vbool2_t*)in; + + *(vbool16_t*)(out + 100) = v1; + *(vbool2_t*)(out + 200) = v2; +} + +void +test_vbool16_then_vbool4(int8_t * restrict in, int8_t * restrict out) { + vbool16_t v1 = *(vbool16_t*)in; + vbool4_t v2 = *(vbool4_t*)in; + + *(vbool16_t*)(out + 100) = v1; + *(vbool4_t*)(out + 200) = v2; +} + +void +test_vbool16_then_vbool8(int8_t * restrict in, int8_t * restrict out) { + vbool16_t v1 = *(vbool16_t*)in; + vbool8_t v2 = *(vbool8_t*)in; + + *(vbool16_t*)(out + 100) = v1; + *(vbool8_t*)(out + 200) = v2; +} + +void +test_vbool16_then_vbool32(int8_t * restrict in, int8_t * restrict out) { + vbool16_t v1 = *(vbool16_t*)in; + vbool32_t v2 = *(vbool32_t*)in; + + *(vbool16_t*)(out + 100) = v1; + *(vbool32_t*)(out + 200) = v2; +} + +void +test_vbool16_then_vbool64(int8_t * restrict in, int8_t * restrict out) { + vbool16_t v1 = *(vbool16_t*)in; + vbool64_t v2 = *(vbool64_t*)in; + + *(vbool16_t*)(out + 100) = v1; + *(vbool64_t*)(out + 200) = v2; +} + +/* { dg-final { scan-assembler-times {vsetvli\s+[a-x][0-9]+,\s*zero,\s*e8,\s*mf2,\s*ta,\s*ma} 6 } } */ +/* { dg-final { scan-assembler-times {vsetvli\s+[a-x][0-9]+,\s*zero,\s*e8,\s*m2,\s*ta,\s*ma} 1 } } */ +/* { dg-final { scan-assembler-times {vsetvli\s+[a-x][0-9]+,\s*zero,\s*e8,\s*m8,\s*ta,\s*ma} 1 } } */ +/* { dg-final { scan-assembler-times {vsetvli\s+[a-x][0-9]+,\s*zero,\s*e8,\s*m4,\s*ta,\s*ma} 1 } } */ +/* { dg-final { scan-assembler-times {vsetvli\s+[a-x][0-9]+,\s*zero,\s*e8,\s*m1,\s*ta,\s*ma} 1 } } */ +/* { dg-final { scan-assembler-times {vsetvli\s+[a-x][0-9]+,\s*zero,\s*e8,\s*mf4,\s*ta,\s*ma} 1 } } */ +/* { dg-final { scan-assembler-times {vsetvli\s+[a-x][0-9]+,\s*zero,\s*e8,\s*mf8,\s*ta,\s*ma} 1 } } */ +/* { dg-final { scan-assembler-times {vlm\.v\s+v[0-9]+,\s*0\([a-x][0-9]+\)} 12 } } */ +/* { dg-final { scan-assembler-times {vsm\.v\s+v[0-9]+,\s*0\([a-x][0-9]+\)} 14 } } */ diff --git a/gcc/testsuite/gcc.target/riscv/pr108185-6.c b/gcc/testsuite/gcc.target/riscv/pr108185-6.c new file mode 100644 index 00000000000..98275e5267d --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/pr108185-6.c @@ -0,0 +1,68 @@ +/* { dg-do compile } */ +/* { dg-options "-march=rv64gcv -mabi=lp64 -O3" } */ + +#include "riscv_vector.h" + +void +test_vbool32_then_vbool1(int8_t * restrict in, int8_t * restrict out) { + vbool32_t v1 = *(vbool32_t*)in; + vbool1_t v2 = *(vbool1_t*)in; + + *(vbool32_t*)(out + 100) = v1; + *(vbool1_t*)(out + 200) = v2; +} + +void +test_vbool32_then_vbool2(int8_t * restrict in, int8_t * restrict out) { + vbool32_t v1 = *(vbool32_t*)in; + vbool2_t v2 = *(vbool2_t*)in; + + *(vbool32_t*)(out + 100) = v1; + *(vbool2_t*)(out + 200) = v2; +} + +void +test_vbool32_then_vbool4(int8_t * restrict in, int8_t * restrict out) { + vbool32_t v1 = *(vbool32_t*)in; + vbool4_t v2 = *(vbool4_t*)in; + + *(vbool32_t*)(out + 100) = v1; + *(vbool4_t*)(out + 200) = v2; +} + +void +test_vbool32_then_vbool8(int8_t * restrict in, int8_t * restrict out) { + vbool32_t v1 = *(vbool32_t*)in; + vbool8_t v2 = *(vbool8_t*)in; + + *(vbool32_t*)(out + 100) = v1; + *(vbool8_t*)(out + 200) = v2; +} + +void +test_vbool32_then_vbool16(int8_t * restrict in, int8_t * restrict out) { + vbool32_t v1 = *(vbool32_t*)in; + vbool16_t v2 = *(vbool16_t*)in; + + *(vbool32_t*)(out + 100) = v1; + *(vbool16_t*)(out + 200) = v2; +} + +void +test_vbool32_then_vbool64(int8_t * restrict in, int8_t * restrict out) { + vbool32_t v1 = *(vbool32_t*)in; + vbool64_t v2 = *(vbool64_t*)in; + + *(vbool32_t*)(out + 100) = v1; + *(vbool64_t*)(out + 200) = v2; +} + +/* { dg-final { scan-assembler-times {vsetvli\s+[a-x][0-9]+,\s*zero,\s*e8,\s*mf4,\s*ta,\s*ma} 6 } } */ +/* { dg-final { scan-assembler-times {vsetvli\s+[a-x][0-9]+,\s*zero,\s*e8,\s*m8,\s*ta,\s*ma} 1 } } */ +/* { dg-final { scan-assembler-times {vsetvli\s+[a-x][0-9]+,\s*zero,\s*e8,\s*m4,\s*ta,\s*ma} 1 } } */ +/* { dg-final { scan-assembler-times {vsetvli\s+[a-x][0-9]+,\s*zero,\s*e8,\s*m2,\s*ta,\s*ma} 1 } } */ +/* { dg-final { scan-assembler-times {vsetvli\s+[a-x][0-9]+,\s*zero,\s*e8,\s*m1,\s*ta,\s*ma} 1 } } */ +/* { dg-final { scan-assembler-times {vsetvli\s+[a-x][0-9]+,\s*zero,\s*e8,\s*mf2,\s*ta,\s*ma} 1 } } */ +/* { dg-final { scan-assembler-times {vsetvli\s+[a-x][0-9]+,\s*zero,\s*e8,\s*mf8,\s*ta,\s*ma} 1 } } */ +/* { dg-final { scan-assembler-times {vlm\.v\s+v[0-9]+,\s*0\([a-x][0-9]+\)} 12 } } */ +/* { dg-final { scan-assembler-times {vsm\.v\s+v[0-9]+,\s*0\([a-x][0-9]+\)} 13 } } */ diff --git a/gcc/testsuite/gcc.target/riscv/pr108185-7.c b/gcc/testsuite/gcc.target/riscv/pr108185-7.c new file mode 100644 index 00000000000..8f6f0b11f09 --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/pr108185-7.c @@ -0,0 +1,68 @@ +/* { dg-do compile } */ +/* { dg-options "-march=rv64gcv -mabi=lp64 -O3" } */ + +#include "riscv_vector.h" + +void +test_vbool64_then_vbool1(int8_t * restrict in, int8_t * restrict out) { + vbool64_t v1 = *(vbool64_t*)in; + vbool1_t v2 = *(vbool1_t*)in; + + *(vbool64_t*)(out + 100) = v1; + *(vbool1_t*)(out + 200) = v2; +} + +void +test_vbool64_then_vbool2(int8_t * restrict in, int8_t * restrict out) { + vbool64_t v1 = *(vbool64_t*)in; + vbool2_t v2 = *(vbool2_t*)in; + + *(vbool64_t*)(out + 100) = v1; + *(vbool2_t*)(out + 200) = v2; +} + +void +test_vbool64_then_vbool4(int8_t * restrict in, int8_t * restrict out) { + vbool64_t v1 = *(vbool64_t*)in; + vbool4_t v2 = *(vbool4_t*)in; + + *(vbool64_t*)(out + 100) = v1; + *(vbool4_t*)(out + 200) = v2; +} + +void +test_vbool64_then_vbool8(int8_t * restrict in, int8_t * restrict out) { + vbool64_t v1 = *(vbool64_t*)in; + vbool8_t v2 = *(vbool8_t*)in; + + *(vbool64_t*)(out + 100) = v1; + *(vbool8_t*)(out + 200) = v2; +} + +void +test_vbool64_then_vbool16(int8_t * restrict in, int8_t * restrict out) { + vbool64_t v1 = *(vbool64_t*)in; + vbool16_t v2 = *(vbool16_t*)in; + + *(vbool64_t*)(out + 100) = v1; + *(vbool16_t*)(out + 200) = v2; +} + +void +test_vbool64_then_vbool32(int8_t * restrict in, int8_t * restrict out) { + vbool64_t v1 = *(vbool64_t*)in; + vbool32_t v2 = *(vbool32_t*)in; + + *(vbool64_t*)(out + 100) = v1; + *(vbool32_t*)(out + 200) = v2; +} + +/* { dg-final { scan-assembler-times {vsetvli\s+[a-x][0-9]+,\s*zero,\s*e8,\s*mf8,\s*ta,\s*ma} 6 } } */ +/* { dg-final { scan-assembler-times {vsetvli\s+[a-x][0-9]+,\s*zero,\s*e8,\s*m8,\s*ta,\s*ma} 1 } } */ +/* { dg-final { scan-assembler-times {vsetvli\s+[a-x][0-9]+,\s*zero,\s*e8,\s*m4,\s*ta,\s*ma} 1 } } */ +/* { dg-final { scan-assembler-times {vsetvli\s+[a-x][0-9]+,\s*zero,\s*e8,\s*m2,\s*ta,\s*ma} 1 } } */ +/* { dg-final { scan-assembler-times {vsetvli\s+[a-x][0-9]+,\s*zero,\s*e8,\s*m1,\s*ta,\s*ma} 1 } } */ +/* { dg-final { scan-assembler-times {vsetvli\s+[a-x][0-9]+,\s*zero,\s*e8,\s*mf2,\s*ta,\s*ma} 1 } } */ +/* { dg-final { scan-assembler-times {vsetvli\s+[a-x][0-9]+,\s*zero,\s*e8,\s*mf4,\s*ta,\s*ma} 1 } } */ +/* { dg-final { scan-assembler-times {vlm\.v\s+v[0-9]+,\s*0\([a-x][0-9]+\)} 12 } } */ +/* { dg-final { scan-assembler-times {vsm\.v\s+v[0-9]+,\s*0\([a-x][0-9]+\)} 12 } } */ diff --git a/gcc/testsuite/gcc.target/riscv/pr108185-8.c b/gcc/testsuite/gcc.target/riscv/pr108185-8.c new file mode 100644 index 00000000000..d96959dd064 --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/pr108185-8.c @@ -0,0 +1,77 @@ +/* { dg-do compile } */ +/* { dg-options "-march=rv64gcv -mabi=lp64 -O3" } */ + +#include "riscv_vector.h" + +void +test_vbool1_then_vbool1(int8_t * restrict in, int8_t * restrict out) { + vbool1_t v1 = *(vbool1_t*)in; + vbool1_t v2 = *(vbool1_t*)in; + + *(vbool1_t*)(out + 100) = v1; + *(vbool1_t*)(out + 200) = v2; +} + +void +test_vbool2_then_vbool2(int8_t * restrict in, int8_t * restrict out) { + vbool2_t v1 = *(vbool2_t*)in; + vbool2_t v2 = *(vbool2_t*)in; + + *(vbool2_t*)(out + 100) = v1; + *(vbool2_t*)(out + 200) = v2; +} + +void +test_vbool4_then_vbool4(int8_t * restrict in, int8_t * restrict out) { + vbool4_t v1 = *(vbool4_t*)in; + vbool4_t v2 = *(vbool4_t*)in; + + *(vbool4_t*)(out + 100) = v1; + *(vbool4_t*)(out + 200) = v2; +} + +void +test_vbool8_then_vbool8(int8_t * restrict in, int8_t * restrict out) { + vbool8_t v1 = *(vbool8_t*)in; + vbool8_t v2 = *(vbool8_t*)in; + + *(vbool8_t*)(out + 100) = v1; + *(vbool8_t*)(out + 200) = v2; +} + +void +test_vbool16_then_vbool16(int8_t * restrict in, int8_t * restrict out) { + vbool16_t v1 = *(vbool16_t*)in; + vbool16_t v2 = *(vbool16_t*)in; + + *(vbool16_t*)(out + 100) = v1; + *(vbool16_t*)(out + 200) = v2; +} + +void +test_vbool32_then_vbool32(int8_t * restrict in, int8_t * restrict out) { + vbool32_t v1 = *(vbool32_t*)in; + vbool32_t v2 = *(vbool32_t*)in; + + *(vbool32_t*)(out + 100) = v1; + *(vbool32_t*)(out + 200) = v2; +} + +void +test_vbool64_then_vbool64(int8_t * restrict in, int8_t * restrict out) { + vbool64_t v1 = *(vbool64_t*)in; + vbool64_t v2 = *(vbool64_t*)in; + + *(vbool64_t*)(out + 100) = v1; + *(vbool64_t*)(out + 200) = v2; +} + +/* { dg-final { scan-assembler-times {vsetvli\s+[a-x][0-9]+,\s*zero,\s*e8,\s*m8,\s*ta,\s*ma} 1 } } */ +/* { dg-final { scan-assembler-times {vsetvli\s+[a-x][0-9]+,\s*zero,\s*e8,\s*m4,\s*ta,\s*ma} 1 } } */ +/* { dg-final { scan-assembler-times {vsetvli\s+[a-x][0-9]+,\s*zero,\s*e8,\s*m2,\s*ta,\s*ma} 1 } } */ +/* { dg-final { scan-assembler-times {vsetvli\s+[a-x][0-9]+,\s*zero,\s*e8,\s*m1,\s*ta,\s*ma} 1 } } */ +/* { dg-final { scan-assembler-times {vsetvli\s+[a-x][0-9]+,\s*zero,\s*e8,\s*mf2,\s*ta,\s*ma} 1 } } */ +/* { dg-final { scan-assembler-times {vsetvli\s+[a-x][0-9]+,\s*zero,\s*e8,\s*mf4,\s*ta,\s*ma} 1 } } */ +/* { dg-final { scan-assembler-times {vsetvli\s+[a-x][0-9]+,\s*zero,\s*e8,\s*mf8,\s*ta,\s*ma} 1 } } */ +/* { dg-final { scan-assembler-times {vlm\.v\s+v[0-9]+,\s*0\([a-x][0-9]+\)} 7 } } */ +/* { dg-final { scan-assembler-times {vsm\.v\s+v[0-9]+,\s*0\([a-x][0-9]+\)} 14 } } */ -- 2.34.1