From patchwork Thu Dec 21 10:21:54 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Sandiford X-Patchwork-Id: 182143 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:2483:b0:fb:cd0c:d3e with SMTP id q3csp312265dyi; Thu, 21 Dec 2023 02:22:19 -0800 (PST) X-Google-Smtp-Source: AGHT+IESGX5+QyWG9nM6pB1g6F3zLtTYg7aXP3H3KgDC9ors2ttNcMhb2Jv7Vtrv4PJq4m3tmL9C X-Received: by 2002:a05:620a:2012:b0:781:2160:13db with SMTP id c18-20020a05620a201200b00781216013dbmr389422qka.90.1703154138989; Thu, 21 Dec 2023 02:22:18 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1703154138; cv=pass; d=google.com; s=arc-20160816; b=NhK7E3E0vjKLuToSuLF7qmOiPlHvmDDrPDLvLj3cLbVY8SR0dIOtBAe+6V98YfozV/ ybqRDkrW3YrCAsybI1DTrVt68pieeIjzDZk8v/DePZPUIrVtpxzHTLydsY8UXkHtws/S kFaxWw2zqIWrXPmla0+mVahAG3VnIYQn98j2f1wNYeCO4sfv5ob7Mh6HkvF0v70V2H3H dSa+nIqmTQ+7vcmXb3fWa7/9BZiYmk5joq102Asej8svmswoS+hvv4ZWUmmVVCPogwC0 CJ66qCW76ahTRJEKLeQN5tumz4XKw0MxE4xnnzJnLpF8zl63/ixhuOxK+Ii0Zv5uQGeT dmqw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:mime-version:user-agent :message-id:date:subject:mail-followup-to:to:from:arc-filter :dmarc-filter:delivered-to; bh=kZQZjUujSvPmhgYWqzI/XAVMyNmy6itjph5YUgJ0Uz0=; fh=hPrbWPhweUx4V0GV9uXJqbyAzg2ABmTz7kczrAQqMmM=; b=WQPaN4ALnVMv00TJrhVrcQ+xh/AzqDV7Dytiu8W7F081jLDRtIMPQegw3QDDawTBUJ kbeuQm5PSmZDbd/vdCnK60RpRXhXnoputwoqg/4d5hM3jaYvhRxQaWTAM8pBEde9/OmM CUBE3NdJXqd0WJfTtS+ki9URH2ovEm2EC9IRD0eKG6FjeLvmqVpJjPBzux5SiVo90OBE fit7Wzqw57HqUFLETpuZumtwuC+Ec7c8B0yiyAOdYB7ESEtlzwMeDSmOJ9mHTNZ1fvmT LiwLUy+4QyXpbni4scVZAK1ZT3jaVK2Ze0AITbdQk15dIthraiLK6b6eHP/lOsMRwC11 7rvQ== ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1); spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: from server2.sourceware.org (server2.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id q17-20020a05620a039100b00778a5708429si1629219qkm.724.2023.12.21.02.22.18 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 Dec 2023 02:22:18 -0800 (PST) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) client-ip=8.43.85.97; Authentication-Results: mx.google.com; arc=pass (i=1); spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id AC06A3861869 for ; Thu, 21 Dec 2023 10:22:18 +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 12FF53858407 for ; Thu, 21 Dec 2023 10:21:56 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 12FF53858407 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 12FF53858407 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=1703154117; cv=none; b=LRZQJolhnWQFGaTzDEm87r1FLnXaYyjajLwPN7bFsvJ6uHsvtiwWyqv446viqGmvFE/AdSKOk/NjnKFuj4+pYiknMwdJhxbRxOlPdkKLn4u40ybE2KawNFK08rDTo5U6eNNuFWXvBRwQORpYQpuCxf+Q1y35/pNNOJF4kCE3eLw= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1703154117; c=relaxed/simple; bh=qAjauNxv4j2DiWIJJ+nwpvXw1jXw5E6wT+WDmTtHh/M=; h=From:To:Subject:Date:Message-ID:MIME-Version; b=IUkcqQA9+B3fzxUlBUul/obTQ9Fjnq8CTipu/IjU5BCcH6wdMt1AMLnJ6B5nHoBGi3mYf5aPWtj8glr3jlM05xbk446TL74ihXIl+/Q0SFWiYbJrJrfDp4N7ULcVsSg8LDNgBL5rf70wO8iQe49bvCts1TnviOb/DBRWsenhBlU= 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 91E492F4 for ; Thu, 21 Dec 2023 02:22:40 -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 62C823F5A1 for ; Thu, 21 Dec 2023 02:21:55 -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 early RA handling of deleted insns [PR113094] Date: Thu, 21 Dec 2023 10:21:54 +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.6 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+ouuuleilei=gmail.com@gcc.gnu.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1785886554404656472 X-GMAIL-MSGID: 1785886554404656472 The testcase constructs a sequence of insns that are fully dead and yet (due to forced options) are not removed as such. This triggered a case where we would emit a meaningless reload for a to-be-deleted insn. We can't delete the insns first because that might disrupt the iteration ranges. So this patch turns them into notes before the walk and then continues to delete them properly afterwards. Tested on aarch64-linux-gnu & pushed. Richard gcc/ PR target/113094 * config/aarch64/aarch64-early-ra.cc (apply_allocation): Stub out instructions that are going to be deleted before iterating over the rest. gcc/testsuite/ PR target/113094 * gcc.target/aarch64/pr113094.c: New test. --- gcc/config/aarch64/aarch64-early-ra.cc | 3 +++ gcc/testsuite/gcc.target/aarch64/pr113094.c | 10 ++++++++++ 2 files changed, 13 insertions(+) create mode 100644 gcc/testsuite/gcc.target/aarch64/pr113094.c diff --git a/gcc/config/aarch64/aarch64-early-ra.cc b/gcc/config/aarch64/aarch64-early-ra.cc index 24415bd829c..5d2da3e1110 100644 --- a/gcc/config/aarch64/aarch64-early-ra.cc +++ b/gcc/config/aarch64/aarch64-early-ra.cc @@ -3210,6 +3210,9 @@ early_ra::maybe_convert_to_strided_access (rtx_insn *insn) void early_ra::apply_allocation () { + for (auto *insn : m_dead_insns) + set_insn_deleted (insn); + rtx_insn *prev; for (auto insn_range : m_insn_ranges) for (rtx_insn *insn = insn_range.first; diff --git a/gcc/testsuite/gcc.target/aarch64/pr113094.c b/gcc/testsuite/gcc.target/aarch64/pr113094.c new file mode 100644 index 00000000000..b79e1f744ed --- /dev/null +++ b/gcc/testsuite/gcc.target/aarch64/pr113094.c @@ -0,0 +1,10 @@ +/* { dg-options "-fno-tree-dse -Ofast -fno-tree-coalesce-vars -fno-dce -fno-tree-dce" } */ + +struct TV4 { + __attribute__((vector_size(sizeof(int) * 4))) int v; +}; +void modify() { + struct TV4 __trans_tmp_1, temp; + temp.v[0] = temp.v[3] = 0; + __trans_tmp_1 = temp; +}