public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] ipa: ICF should check SSA_NAME_IS_DEFAULT_DEF
@ 2021-08-13 13:47 Martin Liška
  2021-08-13 16:56 ` Jeff Law
  0 siblings, 1 reply; 2+ messages in thread
From: Martin Liška @ 2021-08-13 13:47 UTC (permalink / raw)
  To: gcc-patches

Hello.

Currently, the IPA ICF pass optimistically assumes that SSA NAMES do match.
It's fine, but we should match SSA_NAME_IS_DEFAULT_DEF, otherwise we get
the verification error where a pair of SSA_NAMEs is equal, but hash values
do differ.

Patch can bootstrap on x86_64-linux-gnu and survives regression tests.

Ready to be installed?
Thanks,
Martin

	PR ipa/100600

gcc/ChangeLog:

	* ipa-icf-gimple.c (func_checker::compare_ssa_name): Do not
	  consider equal SSA_NAMEs when one is a param.

gcc/testsuite/ChangeLog:

	* gcc.dg/ipa/pr100600.c: New test.
---
  gcc/ipa-icf-gimple.c                |  3 +++
  gcc/testsuite/gcc.dg/ipa/pr100600.c | 22 ++++++++++++++++++++++
  2 files changed, 25 insertions(+)
  create mode 100644 gcc/testsuite/gcc.dg/ipa/pr100600.c

diff --git a/gcc/ipa-icf-gimple.c b/gcc/ipa-icf-gimple.c
index edf5f025627..cf0262621be 100644
--- a/gcc/ipa-icf-gimple.c
+++ b/gcc/ipa-icf-gimple.c
@@ -96,6 +96,9 @@ func_checker::compare_ssa_name (const_tree t1, const_tree t2)
    unsigned i1 = SSA_NAME_VERSION (t1);
    unsigned i2 = SSA_NAME_VERSION (t2);
  
+  if (SSA_NAME_IS_DEFAULT_DEF (t1) != SSA_NAME_IS_DEFAULT_DEF (t2))
+    return false;
+
    if (m_source_ssa_names[i1] == -1)
      m_source_ssa_names[i1] = i2;
    else if (m_source_ssa_names[i1] != (int) i2)
diff --git a/gcc/testsuite/gcc.dg/ipa/pr100600.c b/gcc/testsuite/gcc.dg/ipa/pr100600.c
new file mode 100644
index 00000000000..8a3d0e16e7e
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/ipa/pr100600.c
@@ -0,0 +1,22 @@
+/* PR ipa/100600 */
+/* { dg-do compile } */
+/* { dg-options "-O2" } */
+
+int a, b, c;
+long d(long x, long e, long f, long g) {
+  long h, i;
+  for (; h < e; h++) {
+    i = f;
+    for (; i < g; i++)
+      c = b + a;
+  }
+  return h + i;
+}
+
+long j(long x, long e, long y, long g) {
+  long h, i;
+  for (; h < e; h++)
+    for (; i < g; i++)
+      c = b + a;
+  return h + i;
+}
-- 
2.32.0


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

* Re: [PATCH] ipa: ICF should check SSA_NAME_IS_DEFAULT_DEF
  2021-08-13 13:47 [PATCH] ipa: ICF should check SSA_NAME_IS_DEFAULT_DEF Martin Liška
@ 2021-08-13 16:56 ` Jeff Law
  0 siblings, 0 replies; 2+ messages in thread
From: Jeff Law @ 2021-08-13 16:56 UTC (permalink / raw)
  To: Martin Liška, gcc-patches



On 8/13/2021 7:47 AM, Martin Liška wrote:
> Hello.
>
> Currently, the IPA ICF pass optimistically assumes that SSA NAMES do 
> match.
> It's fine, but we should match SSA_NAME_IS_DEFAULT_DEF, otherwise we get
> the verification error where a pair of SSA_NAMEs is equal, but hash 
> values
> do differ.
>
> Patch can bootstrap on x86_64-linux-gnu and survives regression tests.
>
> Ready to be installed?
> Thanks,
> Martin
>
>     PR ipa/100600
>
> gcc/ChangeLog:
>
>     * ipa-icf-gimple.c (func_checker::compare_ssa_name): Do not
>       consider equal SSA_NAMEs when one is a param.
>
> gcc/testsuite/ChangeLog:
>
>     * gcc.dg/ipa/pr100600.c: New test.
OK
jeff


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

end of thread, other threads:[~2021-08-13 16:56 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-08-13 13:47 [PATCH] ipa: ICF should check SSA_NAME_IS_DEFAULT_DEF Martin Liška
2021-08-13 16:56 ` Jeff Law

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).