public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [COMMITTED] PR tree-optimization/111622 - Do not add partial equivalences with no uses.
@ 2023-10-13 13:23 Andrew MacLeod
  2023-10-13 13:25 ` Andrew MacLeod
  0 siblings, 1 reply; 2+ messages in thread
From: Andrew MacLeod @ 2023-10-13 13:23 UTC (permalink / raw)
  To: gcc-patches

Technically PR 111622 exposes a bug in GCC 13, but its been papered over 
on trunk by this:

commit 9ea74d235c7e7816b996a17c61288f02ef767985
Author: Richard Biener <rguenther@suse.de>
Date:   Thu Sep 14 09:31:23 2023 +0200
     
     tree-optimization/111294 - better DCE after forwprop

This removes a lot of dead statements, but those statements were being 
added to the list of partial equivalences and causing some serious 
compile time issues.

Rangers cache loops through equivalences when its propagating on-entry 
values, so if the partial equivalence list is very large, it can consume 
a lot of time.  Typically, partial equivalence lists are small.   In 
this case, a lot of dead stmts were not removed, so there was no 
redundancy elimination and it was causing an issue.   This patch 
actually speeds things up a hair in the normal case too.

Bootstrapped on x86_64-pc-linux-gnu with no regressions.  pushed.

Andrew




^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [COMMITTED] PR tree-optimization/111622 - Do not add partial equivalences with no uses.
  2023-10-13 13:23 [COMMITTED] PR tree-optimization/111622 - Do not add partial equivalences with no uses Andrew MacLeod
@ 2023-10-13 13:25 ` Andrew MacLeod
  0 siblings, 0 replies; 2+ messages in thread
From: Andrew MacLeod @ 2023-10-13 13:25 UTC (permalink / raw)
  To: gcc-patches

[-- Attachment #1: Type: text/plain, Size: 1066 bytes --]

of course the patch would be handy...


On 10/13/23 09:23, Andrew MacLeod wrote:
> Technically PR 111622 exposes a bug in GCC 13, but its been papered 
> over on trunk by this:
>
> commit 9ea74d235c7e7816b996a17c61288f02ef767985
> Author: Richard Biener <rguenther@suse.de>
> Date:   Thu Sep 14 09:31:23 2023 +0200
>         tree-optimization/111294 - better DCE after forwprop
>
> This removes a lot of dead statements, but those statements were being 
> added to the list of partial equivalences and causing some serious 
> compile time issues.
>
> Rangers cache loops through equivalences when its propagating on-entry 
> values, so if the partial equivalence list is very large, it can 
> consume a lot of time.  Typically, partial equivalence lists are 
> small.   In this case, a lot of dead stmts were not removed, so there 
> was no redundancy elimination and it was causing an issue.   This 
> patch actually speeds things up a hair in the normal case too.
>
> Bootstrapped on x86_64-pc-linux-gnu with no regressions.  pushed.
>
> Andrew
>
>
>

[-- Attachment #2: 0001-Do-not-add-partial-equivalences-with-no-uses.patch --]
[-- Type: text/x-patch, Size: 1885 bytes --]

From 4eea3c1872a941089cafa105a11d8e40b1a55929 Mon Sep 17 00:00:00 2001
From: Andrew MacLeod <amacleod@redhat.com>
Date: Thu, 12 Oct 2023 17:06:36 -0400
Subject: [PATCH] Do not add partial equivalences with no uses.

	PR tree-optimization/111622
	* value-relation.cc (equiv_oracle::add_partial_equiv): Do not
	register a partial equivalence if an operand has no uses.
---
 gcc/value-relation.cc | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/gcc/value-relation.cc b/gcc/value-relation.cc
index 0326fe7cde6..c0f513a0eb1 100644
--- a/gcc/value-relation.cc
+++ b/gcc/value-relation.cc
@@ -392,6 +392,9 @@ equiv_oracle::add_partial_equiv (relation_kind r, tree op1, tree op2)
       // In either case, if PE2 has an entry, we simply do nothing.
       if (pe2.members)
 	return;
+      // If there are no uses of op2, do not register.
+      if (has_zero_uses (op2))
+	return;
       // PE1 is the LHS and already has members, so everything in the set
       // should be a slice of PE2 rather than PE1.
       pe2.code = pe_min (r, pe1.code);
@@ -409,6 +412,9 @@ equiv_oracle::add_partial_equiv (relation_kind r, tree op1, tree op2)
     }
   if (pe2.members)
     {
+      // If there are no uses of op1, do not register.
+      if (has_zero_uses (op1))
+	return;
       pe1.ssa_base = pe2.ssa_base;
       // If pe2 is a 16 bit value, but only an 8 bit copy, we can't be any
       // more than an 8 bit equivalence here, so choose MIN value.
@@ -418,6 +424,9 @@ equiv_oracle::add_partial_equiv (relation_kind r, tree op1, tree op2)
     }
   else
     {
+      // If there are no uses of either operand, do not register.
+      if (has_zero_uses (op1) || has_zero_uses (op2))
+	return;
       // Neither name has an entry, simply create op1 as slice of op2.
       pe2.code = bits_to_pe (TYPE_PRECISION (TREE_TYPE (op2)));
       if (pe2.code == VREL_VARYING)
-- 
2.41.0


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2023-10-13 13:25 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-10-13 13:23 [COMMITTED] PR tree-optimization/111622 - Do not add partial equivalences with no uses Andrew MacLeod
2023-10-13 13:25 ` Andrew MacLeod

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).