]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
ipa: ICF should check SSA_NAME_IS_DEFAULT_DEF
authorMartin Liska <mliska@suse.cz>
Fri, 13 Aug 2021 10:35:47 +0000 (12:35 +0200)
committerMartin Liska <mliska@suse.cz>
Mon, 16 Aug 2021 07:53:11 +0000 (09:53 +0200)
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
gcc/testsuite/gcc.dg/ipa/pr100600.c [new file with mode: 0644]

index edf5f0256273bb90096733c479777afa24dd5c4a..cf0262621be774a61975d92938bd0cfd5d0112ea 100644 (file)
@@ -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 (file)
index 0000000..8a3d0e1
--- /dev/null
@@ -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;
+}