From patchwork Thu Jan 25 12:09:13 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Sandiford X-Patchwork-Id: 1890673 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=server2.sourceware.org; envelope-from=gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=patchwork.ozlabs.org) Received: from server2.sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4TLKQ94Nt5z23dy for ; Thu, 25 Jan 2024 23:09:53 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 9B2C4385840C for ; Thu, 25 Jan 2024 12:09:51 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by sourceware.org (Postfix) with ESMTP id D22353858284 for ; Thu, 25 Jan 2024 12:09:15 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org D22353858284 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=arm.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org D22353858284 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=217.140.110.172 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1706184560; cv=none; b=WhpYeIgJ0dZVqXXFK6TRnzZliCHbH5Vhcvgq3T47AFjqRE51+FYHPW8hCSdgefyEGw91psFqdV+FtZfNzJniuv8YeTFNzeT7Y8wi73MiUQ5jVZPWg2L3XgFxFMXPVkxB0MqGXu7e5MCwZwUecdLCjb6v17AGGHPZFKzv8pk0GVk= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1706184560; c=relaxed/simple; bh=soRMsv228E2QmUEFkJar3GgfrsDYgwieyEfjygiHNY8=; h=From:To:Subject:Date:Message-ID:MIME-Version; b=a9HCu/Z7gL2Ssxp2vIljG5j5RVXgIQLYdEe5Mmn0U+YYn3L4qgdOS7Fi4qkxBaTjvRs38aWDKeDDSvCVcx2e0Xu3c5p5OnvjoLTQOt1KS2AEQshVvhdpzn2sR+PVQV5dSJ5ZlKLv9wKsHa/J9ntyCWY72njmp2R1Ju3Ne6wKZ/o= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id F33F41FB for ; Thu, 25 Jan 2024 04:09:59 -0800 (PST) Received: from localhost (e121540-lin.manchester.arm.com [10.32.110.72]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 1FA7B3F73F for ; Thu, 25 Jan 2024 04:09:15 -0800 (PST) From: Richard Sandiford To: gcc-patches@gcc.gnu.org Mail-Followup-To: gcc-patches@gcc.gnu.org, richard.sandiford@arm.com Subject: [pushed] aarch64: Fix out-of-bounds ENCODED_ELT access [PR113572] Date: Thu, 25 Jan 2024 12:09:13 +0000 Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.3 (gnu/linux) MIME-Version: 1.0 X-Spam-Status: No, score=-21.2 required=5.0 tests=BAYES_00, GIT_PATCH_0, KAM_DMARC_NONE, KAM_DMARC_STATUS, KAM_LAZY_DOMAIN_SECURITY, KAM_SHORT, SPF_HELO_NONE, SPF_NONE, 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.30 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org When generalising vector_cst_all_same, I'd forgotten to update VECTOR_CST_ENCODED_ELT to VECTOR_CST_ELT. The check deliberately looks at implicitly encoded elements in some cases. Tested on aarch64-linux-gnu & pushed. Richard gcc/ PR target/113572 * config/aarch64/aarch64-sve-builtins.cc (vector_cst_all_same): Check VECTOR_CST_ELT instead of VECTOR_CST_ENCODED_ELT gcc/testsuite/ PR target/113572 * gcc.target/aarch64/sve/pr113572.c: New test. --- gcc/config/aarch64/aarch64-sve-builtins.cc | 2 +- gcc/testsuite/gcc.target/aarch64/sve/pr113572.c | 12 ++++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/gcc.target/aarch64/sve/pr113572.c diff --git a/gcc/config/aarch64/aarch64-sve-builtins.cc b/gcc/config/aarch64/aarch64-sve-builtins.cc index c2f1486315f..11f5c5c500c 100644 --- a/gcc/config/aarch64/aarch64-sve-builtins.cc +++ b/gcc/config/aarch64/aarch64-sve-builtins.cc @@ -3474,7 +3474,7 @@ vector_cst_all_same (tree v, unsigned int step) unsigned int nelts = lcm * VECTOR_CST_NELTS_PER_PATTERN (v); tree first_el = VECTOR_CST_ENCODED_ELT (v, 0); for (unsigned int i = 0; i < nelts; i += step) - if (!operand_equal_p (VECTOR_CST_ENCODED_ELT (v, i), first_el, 0)) + if (!operand_equal_p (VECTOR_CST_ELT (v, i), first_el, 0)) return false; return true; diff --git a/gcc/testsuite/gcc.target/aarch64/sve/pr113572.c b/gcc/testsuite/gcc.target/aarch64/sve/pr113572.c new file mode 100644 index 00000000000..a5e6b7e9907 --- /dev/null +++ b/gcc/testsuite/gcc.target/aarch64/sve/pr113572.c @@ -0,0 +1,12 @@ +#include + +uint64_t u; +struct S { int i; } he; + +void +foo () +{ + svuint64_t vld_clz = svld1_u64 (svwhilelt_b64 (0, 4), (uint64_t *) &he); + vld_clz = svclz_u64_z (svwhilelt_b64 (0, 1), vld_clz); + svst1_u64 (svwhilelt_b64 (0, 1), &u, vld_clz); +}