| Message ID | orms6vveu6.fsf_-_@lxoliva.fsfla.org |
|---|---|
| State | Committed |
| Commit | 12992edaa96897d4ce26c3d48fa19c142b0aef28 |
| Headers |
Return-Path: <gcc-patches-bounces~patchwork=sourceware.org@gcc.gnu.org> X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 826423858407 for <patchwork@sourceware.org>; Mon, 15 Sep 2025 16:55:59 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 826423858407 Authentication-Results: sourceware.org; dkim=pass (2048-bit key, secure) header.d=adacore.com header.i=@adacore.com header.a=rsa-sha256 header.s=google header.b=NAzPYZgt X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-pl1-x632.google.com (mail-pl1-x632.google.com [IPv6:2607:f8b0:4864:20::632]) by sourceware.org (Postfix) with ESMTPS id C9A6C3858C55 for <gcc-patches@gcc.gnu.org>; Mon, 15 Sep 2025 16:53:11 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org C9A6C3858C55 Authentication-Results: sourceware.org; dmarc=pass (p=quarantine dis=none) header.from=adacore.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=adacore.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org C9A6C3858C55 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::632 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1757955192; cv=none; b=ppt1YK8d33dCuGHziZZIbji/5put6JZln2AjxPwybW4fLH4W1HkU7fMCwdFCdldGX+pLZ0VeXKq50LIOfx5F5+rsmbSFYaWwk22yVEA27cT3a3gvLWFRFC6hYAL72fY9meFl6WHVV0FNnvw6fYg5sGScsCEZfvOovX1zua7e6dw= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1757955192; c=relaxed/simple; bh=IbqDvBXpgR7cJm7KDwpiH1NbafvfO3m3Tu3gFEgnVHM=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=wy/5lIFaf0EE6gtgFvHx5vTkWTl2Hm7ApYfDAYrQGfuFQpn2PKie4v2BGURCxgFO3D9tfY0dZ/di4xxcS4bJMivjA7AgrBIFhdAFz90ZgXW0+wgLjJqEf29Fm3iIZCq6H7X17CeBLUz/QdN4uwJqNGL343tNPOU9DOjYLnOgYTc= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org C9A6C3858C55 Received: by mail-pl1-x632.google.com with SMTP id d9443c01a7336-251fc032d1fso48983125ad.3 for <gcc-patches@gcc.gnu.org>; Mon, 15 Sep 2025 09:53:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=adacore.com; s=google; t=1757955191; x=1758559991; darn=gcc.gnu.org; h=mime-version:user-agent:message-id:in-reply-to:date:references :organization:subject:cc:to:from:from:to:cc:subject:date:message-id :reply-to; bh=phcx5sNEK1rBsOPwW4Wr7McGvzoeabDmVwpGFs2QHEo=; b=NAzPYZgtsX8VEZucmxvlgouROZAxzF/HBgqgJD3qiLIXvLIgH25mA7esMQGazlLh5b EWDCuKeA2C6grW7Qsw1nXdI0llA7rFMZqyDemo6D9gmdjAA3r5hseLWSJx7+Px7PPR2D mUxPmFFAYQJ0JjlCNnXtkuBbrPp9yv4sVIX1L+S+3kK2Emqu/DOD6erpv42SLXtbbQIK PwSx6JBNuXtxIl30vjsWnim9ahh4297jofgqAm2x+JDRxx5fWTcu0cJ1emDNd52fbLWJ f51Bc2gcnJwTcWMSMRyaZrllg18Dwip8q3Y81aguI2JmYAKT7jyCQMwvfRCxLQ8rBesf MXwA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1757955191; x=1758559991; h=mime-version:user-agent:message-id:in-reply-to:date:references :organization:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=phcx5sNEK1rBsOPwW4Wr7McGvzoeabDmVwpGFs2QHEo=; b=aZHkNOOQptFw8hcnAcNKRGXK5mGYAoQdoXp7+ws0n1xkHW0Yv8GmZlsB6ulg3GF+oU pAq5mljzu7TaR173olqoxgbVL0S+6wFzwczBjtkV0m68vmasx2nFkkbbL/1HqJlzh5HQ DnvDGG43/Yqj+0ZERlTXLbJrDmQsQheXiAYZRC+NdK2+PAtPHFFheZGoGcuKsAt9y3SD aT7deCxNNF0+VlgccAd4bYbJi6NHblN9cDqCZpRST5IIanzIGpqce9eAy7wRherqp+8N QLtWD/b2nZJU6v2BHykOAPibvxfWsDJYz3Xtelord7/mwlYUmHsobom9ytqimx+8KnCm siog== X-Gm-Message-State: AOJu0YwoBQORVZdsgByV5crhf6dG78k0prJlsu820N4qPOwI0Z84nSL4 9DAMaVeMQMX1CFaeiA+eBODqt64ULIl752n4W5ZqRfoiYjTB1BRU1TogKTLZjuKKSuNtQ9JTZrx /Wdk= X-Gm-Gg: ASbGncu4Snqnca3icw+fE/2D0psih5NZEn4ssLqt0azVL4IDhBbU9VBeAt2X2lQc0qE qZnDqc3eSU271K5stjDEUEzPBZ0HVy9kibvZUP/mjR6E5Dl9Sx7efIlnOQapokY5svnaYCVf5F7 MwgOhpEA4VHWGnJTQ8/+U2vfk0XrLOXNwGHex/y6d30cjOt8PAfdsMMD4+ZF9SQb16w9yyE9Bdk RY9mIb9/whpQODZ6e19uNthIISRKWadYbto1bC71DclVBUzRNcJ28A7ey9EOSQVT14aaS1lgm8+ TF42nrK74q4QbYp8Tfg6oT1VUxUPnrBW6sUtju1pd637LuX/YRg5Tf8OnwHVaBFjXOErXlILnUm EEk2j8XRZUhJLqkBDVC8IT5Yyn0n1vFzuasrevg== X-Google-Smtp-Source: AGHT+IFmYuqfxsM2LNQnb1PkS/N0tvExuCmz1ldm5HnSYBGOty7fWzbcJ0LBMdEu+RtBVtqncxLFWw== X-Received: by 2002:a17:902:cecf:b0:24d:a3a0:5230 with SMTP id d9443c01a7336-25d27131d84mr208440585ad.58.1757955190390; Mon, 15 Sep 2025 09:53:10 -0700 (PDT) Received: from free.home ([187.106.43.153]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-2677a5cf655sm26289965ad.4.2025.09.15.09.53.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 Sep 2025 09:53:09 -0700 (PDT) Received: from livre (livre.home [172.31.160.2]) by free.home (8.15.2/8.15.2) with ESMTPS id 58FGpjoC2168892 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Mon, 15 Sep 2025 13:51:48 -0300 From: Alexandre Oliva <oliva@adacore.com> To: gcc-patches@gcc.gnu.org Cc: Vladimir Makarov <vmakarov@redhat.com>, Rainer Orth <ro@CeBiTec.Uni-Bielefeld.DE>, Mike Stump <mikestump@comcast.net>, Richard Earnshaw <richard.earnshaw@arm.com>, Tamar Christina <tamar.christina@arm.com>, Kyrylo Tkachov <ktkachov@nvidia.com> Subject: [PATCH 2/2v2] [ira] avoid resetting ira_reg_equiv for function invariants Organization: Free thinker, does not speak for AdaCore References: <orldmix3cw.fsf@lxoliva.fsfla.org> <or8qiix24c.fsf@lxoliva.fsfla.org> Date: Mon, 15 Sep 2025 13:51:45 -0300 In-Reply-To: <or8qiix24c.fsf@lxoliva.fsfla.org> (Alexandre Oliva's message of "Sat, 13 Sep 2025 04:06:43 -0300") Message-ID: <orms6vveu6.fsf_-_@lxoliva.fsfla.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.1 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Scanned-By: MIMEDefang 2.84 X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_SHORT, RCVD_IN_ABUSEAT, RCVD_IN_BARRACUDACENTRAL, RCVD_IN_DNSWL_NONE, RCVD_IN_SBL_CSS, SPF_HELO_NONE, SPF_PASS, TXREP, WEIRD_QUOTING 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 <gcc-patches.gcc.gnu.org> List-Unsubscribe: <https://gcc.gnu.org/mailman/options/gcc-patches>, <mailto:gcc-patches-request@gcc.gnu.org?subject=unsubscribe> List-Archive: <https://gcc.gnu.org/pipermail/gcc-patches/> List-Post: <mailto:gcc-patches@gcc.gnu.org> List-Help: <mailto:gcc-patches-request@gcc.gnu.org?subject=help> List-Subscribe: <https://gcc.gnu.org/mailman/listinfo/gcc-patches>, <mailto:gcc-patches-request@gcc.gnu.org?subject=subscribe> Errors-To: gcc-patches-bounces~patchwork=sourceware.org@gcc.gnu.org |
| Series |
[2/2v2,ira] avoid resetting ira_reg_equiv for function invariants
|
|
Commit Message
Alexandre Oliva
Sept. 15, 2025, 4:51 p.m. UTC
An aarch64 toolchain built with --enable-default-pie fails gcc.target/aarch64/sme/nonlocal_goto_[123].c because the register allocator ends up resetting equivalences, so it concludes it needs to preserve a rematerializable function invariant across a call instead of rematerializing it. Restore the find_reg_equiv_invariant_const logic that was in place before commit 55a2c3226a3e90a6d65f19710bab1ac377054234 rewrote it and added a (spurious?) requirement for non-function-invariants to retain an equivalence when other PIC-related conditions didn't apply. That requirement seems either reversed or unnecessary. Regstrapped on x86_64-linux-gnu, with and without --enable-host-pie, and on aarch64-linux-gnu, with --enable-host-pie --enable-default-pie. This version of the patch even makes sense to me! :-) Ok to install? for gcc/ChangeLog * ira.cc (setup_reg_equiv): Retain function invariant equivalences. --- gcc/ira.cc | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
Comments
On 9/15/25 12:51 PM, Alexandre Oliva wrote: > An aarch64 toolchain built with --enable-default-pie fails > gcc.target/aarch64/sme/nonlocal_goto_[123].c because the register > allocator ends up resetting equivalences, so it concludes it needs to > preserve a rematerializable function invariant across a call instead > of rematerializing it. > > Restore the find_reg_equiv_invariant_const logic that was in place > before commit 55a2c3226a3e90a6d65f19710bab1ac377054234 rewrote it and > added a (spurious?) requirement for non-function-invariants to retain > an equivalence when other PIC-related conditions didn't apply. That > requirement seems either reversed or unnecessary. > > Regstrapped on x86_64-linux-gnu, with and without --enable-host-pie, and > on aarch64-linux-gnu, with --enable-host-pie --enable-default-pie. This > version of the patch even makes sense to me! :-) Ok to install? > Yes, I guess it is my 13 years old mistake. The code you are proposing is the same existed in the old reload pass. The patch is ok for me. Than you for fixing this up, Alex. > for gcc/ChangeLog > > * ira.cc (setup_reg_equiv): Retain function invariant > equivalences. > --- > gcc/ira.cc | 6 ++++-- > 1 file changed, 4 insertions(+), 2 deletions(-) > > diff --git a/gcc/ira.cc b/gcc/ira.cc > index 4eebc9c4c50fb..3e15966558edf 100644 > --- a/gcc/ira.cc > +++ b/gcc/ira.cc > @@ -4233,12 +4233,14 @@ setup_reg_equiv (void) > && REGNO (SET_SRC (set)) == (unsigned int) i); > x = SET_DEST (set); > } > - if (! function_invariant_p (x) > + /* If PIC is enabled and the equiv is not a LEGITIMATE_PIC_OPERAND, > + we can't use it. */ > + if (! CONSTANT_P (x) > || ! flag_pic > /* A function invariant is often CONSTANT_P but may > include a register. We promise to only pass > CONSTANT_P objects to LEGITIMATE_PIC_OPERAND_P. */ > - || (CONSTANT_P (x) && LEGITIMATE_PIC_OPERAND_P (x))) > + || LEGITIMATE_PIC_OPERAND_P (x)) > { > /* It can happen that a REG_EQUIV note contains a MEM > that is not a legitimate memory operand. As later >
diff --git a/gcc/ira.cc b/gcc/ira.cc index 4eebc9c4c50fb..3e15966558edf 100644 --- a/gcc/ira.cc +++ b/gcc/ira.cc @@ -4233,12 +4233,14 @@ setup_reg_equiv (void) && REGNO (SET_SRC (set)) == (unsigned int) i); x = SET_DEST (set); } - if (! function_invariant_p (x) + /* If PIC is enabled and the equiv is not a LEGITIMATE_PIC_OPERAND, + we can't use it. */ + if (! CONSTANT_P (x) || ! flag_pic /* A function invariant is often CONSTANT_P but may include a register. We promise to only pass CONSTANT_P objects to LEGITIMATE_PIC_OPERAND_P. */ - || (CONSTANT_P (x) && LEGITIMATE_PIC_OPERAND_P (x))) + || LEGITIMATE_PIC_OPERAND_P (x)) { /* It can happen that a REG_EQUIV note contains a MEM that is not a legitimate memory operand. As later