From: "Martin Liška" <mliska@suse.cz>
To: gcc-patches@gcc.gnu.org
Subject: Re: [PATCH 5/5] New tests introduction
Date: Mon, 30 Jun 2014 12:14:00 -0000 [thread overview]
Message-ID: <53B15497.2070806@suse.cz> (raw)
In-Reply-To: <53A09CC0.6060209@redhat.com>
[-- Attachment #1: Type: text/plain, Size: 4301 bytes --]
On 06/17/2014 09:53 PM, Jeff Law wrote:
> On 06/13/14 05:16, mliska wrote:
>> Hi,
>> this is a new collection of tests for IPA ICF pass.
>>
>> Martin
>>
>> Changelog:
>>
>> 2014-06-13 Martin Liska <mliska@suse.cz>
>> Honza Hubicka <hubicka@ucw.cz>
>>
>> * gcc/testsuite/g++.dg/ipa/ipa-se-1.C: New test.
>> * gcc/testsuite/g++.dg/ipa/ipa-se-2.C: Likewise.
>> * gcc/testsuite/g++.dg/ipa/ipa-se-3.C: Likewise.
>> * gcc/testsuite/g++.dg/ipa/ipa-se-4.C: Likewise.
>> * gcc/testsuite/g++.dg/ipa/ipa-se-5.C: Likewise.
>> * gcc/testsuite/gcc.dg/ipa/ipa-se-1.c: Likewise.
>> * gcc/testsuite/gcc.dg/ipa/ipa-se-10.c: Likewise.
>> * gcc/testsuite/gcc.dg/ipa/ipa-se-11.c: Likewise.
>> * gcc/testsuite/gcc.dg/ipa/ipa-se-12.c: Likewise.
>> * gcc/testsuite/gcc.dg/ipa/ipa-se-13.c: Likewise.
>> * gcc/testsuite/gcc.dg/ipa/ipa-se-14.c: Likewise.
>> * gcc/testsuite/gcc.dg/ipa/ipa-se-15.c: Likewise.
>> * gcc/testsuite/gcc.dg/ipa/ipa-se-16.c: Likewise.
>> * gcc/testsuite/gcc.dg/ipa/ipa-se-17.c: Likewise.
>> * gcc/testsuite/gcc.dg/ipa/ipa-se-18.c: Likewise.
>> * gcc/testsuite/gcc.dg/ipa/ipa-se-19.c: Likewise.
>> * gcc/testsuite/gcc.dg/ipa/ipa-se-2.c: Likewise.
>> * gcc/testsuite/gcc.dg/ipa/ipa-se-20.c: Likewise.
>> * gcc/testsuite/gcc.dg/ipa/ipa-se-21.c: Likewise.
>> * gcc/testsuite/gcc.dg/ipa/ipa-se-22.c: Likewise.
>> * gcc/testsuite/gcc.dg/ipa/ipa-se-23.c: Likewise.
>> * gcc/testsuite/gcc.dg/ipa/ipa-se-24.c: Likewise.
>> * gcc/testsuite/gcc.dg/ipa/ipa-se-25.c: Likewise.
>> * gcc/testsuite/gcc.dg/ipa/ipa-se-26.c: Likewise.
>> * gcc/testsuite/gcc.dg/ipa/ipa-se-27.c: Likewise.
>> * gcc/testsuite/gcc.dg/ipa/ipa-se-28.c: Likewise.
>> * gcc/testsuite/gcc.dg/ipa/ipa-se-3.c: Likewise.
>> * gcc/testsuite/gcc.dg/ipa/ipa-se-4.c: Likewise.
>> * gcc/testsuite/gcc.dg/ipa/ipa-se-5.c: Likewise.
>> * gcc/testsuite/gcc.dg/ipa/ipa-se-6.c: Likewise.
>> * gcc/testsuite/gcc.dg/ipa/ipa-se-7.c: Likewise.
>> * gcc/testsuite/gcc.dg/ipa/ipa-se-8.c: Likewise.
>> * gcc/testsuite/gcc.dg/ipa/ipa-se-9.c: Likewise.
> Also approved, but please don't install entire the entire kit is approved.
>
> I'd like to applaud you and Jan for including a nice baseline of tests.
>
> jeff
>
Hi,
there's updatd baseline of tests.
Martin
gcc/testsuite/ChangeLog:
2014-06-30 Martin Liska <mliska@suse.cz>
Honza Hubicka <hubicka@ucw.cz>
* gcc/testsuite/g++.dg/ipa/ipa-icf-1.C: New test.
* gcc/testsuite/g++.dg/ipa/ipa-icf-2.C: Likewise.
* gcc/testsuite/g++.dg/ipa/ipa-icf-3.C: Likewise.
* gcc/testsuite/g++.dg/ipa/ipa-icf-4.C: Likewise.
* gcc/testsuite/g++.dg/ipa/ipa-icf-5.C: Likewise.
* gcc/testsuite/gcc.dg/ipa/ipa-icf-1.c: Likewise.
* gcc/testsuite/gcc.dg/ipa/ipa-icf-10.c: Likewise.
* gcc/testsuite/gcc.dg/ipa/ipa-icf-11.c: Likewise.
* gcc/testsuite/gcc.dg/ipa/ipa-icf-12.c: Likewise.
* gcc/testsuite/gcc.dg/ipa/ipa-icf-13.c: Likewise.
* gcc/testsuite/gcc.dg/ipa/ipa-icf-14.c: Likewise.
* gcc/testsuite/gcc.dg/ipa/ipa-icf-15.c: Likewise.
* gcc/testsuite/gcc.dg/ipa/ipa-icf-16.c: Likewise.
* gcc/testsuite/gcc.dg/ipa/ipa-icf-17.c: Likewise.
* gcc/testsuite/gcc.dg/ipa/ipa-icf-18.c: Likewise.
* gcc/testsuite/gcc.dg/ipa/ipa-icf-19.c: Likewise.
* gcc/testsuite/gcc.dg/ipa/ipa-icf-2.c: Likewise.
* gcc/testsuite/gcc.dg/ipa/ipa-icf-20.c: Likewise.
* gcc/testsuite/gcc.dg/ipa/ipa-icf-21.c: Likewise.
* gcc/testsuite/gcc.dg/ipa/ipa-icf-22.c: Likewise.
* gcc/testsuite/gcc.dg/ipa/ipa-icf-23.c: Likewise.
* gcc/testsuite/gcc.dg/ipa/ipa-icf-24.c: Likewise.
* gcc/testsuite/gcc.dg/ipa/ipa-icf-25.c: Likewise.
* gcc/testsuite/gcc.dg/ipa/ipa-icf-26.c: Likewise.
* gcc/testsuite/gcc.dg/ipa/ipa-icf-27.c: Likewise.
* gcc/testsuite/gcc.dg/ipa/ipa-icf-28.c: Likewise.
* gcc/testsuite/gcc.dg/ipa/ipa-icf-3.c: Likewise.
* gcc/testsuite/gcc.dg/ipa/ipa-icf-4.c: Likewise.
* gcc/testsuite/gcc.dg/ipa/ipa-icf-5.c: Likewise.
* gcc/testsuite/gcc.dg/ipa/ipa-icf-6.c: Likewise.
* gcc/testsuite/gcc.dg/ipa/ipa-icf-7.c: Likewise.
* gcc/testsuite/gcc.dg/ipa/ipa-icf-8.c: Likewise.
* gcc/testsuite/gcc.dg/ipa/ipa-icf-9.c: Likewise.
Martin
[-- Attachment #2: 0004-New-tests-introduction.patch --]
[-- Type: text/x-patch, Size: 31428 bytes --]
diff --git a/gcc/testsuite/g++.dg/ipa/ipa-icf-1.C b/gcc/testsuite/g++.dg/ipa/ipa-icf-1.C
new file mode 100644
index 0000000..d27abf4
--- /dev/null
+++ b/gcc/testsuite/g++.dg/ipa/ipa-icf-1.C
@@ -0,0 +1,43 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -fdump-ipa-icf" } */
+
+class A
+{
+public:
+ __attribute__ ((noinline))
+ virtual int Foo2()
+ {
+ return v;
+ }
+
+ float f;
+ int v;
+};
+
+class B
+{
+public:
+ __attribute__ ((noinline))
+ int Bar2()
+ {
+ return v;
+ }
+
+ float f, aaa;
+ int v;
+};
+
+int main()
+{
+ A a;
+ B b;
+
+ a.Foo2();
+ b.Bar2();
+
+ return 12345;
+}
+
+/* { dg-final { scan-ipa-dump-not "Semantic equality hit:" "icf" } } */
+/* { dg-final { scan-ipa-dump "Equal symbols: 0" "icf" } } */
+/* { dg-final { cleanup-ipa-dump "icf" } } */
diff --git a/gcc/testsuite/g++.dg/ipa/ipa-icf-2.C b/gcc/testsuite/g++.dg/ipa/ipa-icf-2.C
new file mode 100644
index 0000000..48badd7
--- /dev/null
+++ b/gcc/testsuite/g++.dg/ipa/ipa-icf-2.C
@@ -0,0 +1,40 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -fdump-ipa-icf" } */
+
+class A
+{
+public:
+ __attribute__ ((noinline))
+ int Foo2()
+ {
+ return 1;
+ }
+
+ int v;
+ float f;
+};
+
+class B
+{
+public:
+ __attribute__ ((noinline))
+ int Bar2()
+ {
+ return 1;
+ }
+
+ int v;
+ float f, aaa;
+};
+
+int main()
+{
+ A a;
+ B b;
+
+ return a.Foo2() + b.Bar2();
+}
+
+/* { dg-final { scan-ipa-dump "Semantic equality hit:" "icf" } } */
+/* { dg-final { scan-ipa-dump "Equal symbols: 1" "icf" } } */
+/* { dg-final { cleanup-ipa-dump "icf" } } */
diff --git a/gcc/testsuite/g++.dg/ipa/ipa-icf-3.C b/gcc/testsuite/g++.dg/ipa/ipa-icf-3.C
new file mode 100644
index 0000000..042f789
--- /dev/null
+++ b/gcc/testsuite/g++.dg/ipa/ipa-icf-3.C
@@ -0,0 +1,36 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -fdump-ipa-icf" } */
+
+__attribute__ ((noinline))
+int zero()
+{
+ return 0;
+}
+
+__attribute__ ((noinline))
+int nula()
+{
+ return 0;
+}
+
+__attribute__ ((noinline))
+int foo()
+{
+ return zero();
+}
+
+__attribute__ ((noinline))
+int bar()
+{
+ return nula();
+}
+
+int main()
+{
+ return foo() + bar();
+}
+
+/* { dg-final { scan-ipa-dump "Semantic equality hit:.*bar.*->.*foo.*" "icf" } } */
+/* { dg-final { scan-ipa-dump "Semantic equality hit:.*nula.*->.*zero.*" "icf" } } */
+/* { dg-final { scan-ipa-dump "Equal symbols: 2" "icf" } } */
+/* { dg-final { cleanup-ipa-dump "icf" } } */
diff --git a/gcc/testsuite/g++.dg/ipa/ipa-icf-4.C b/gcc/testsuite/g++.dg/ipa/ipa-icf-4.C
new file mode 100644
index 0000000..4ac2cf9
--- /dev/null
+++ b/gcc/testsuite/g++.dg/ipa/ipa-icf-4.C
@@ -0,0 +1,49 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -fdump-ipa-icf -fno-inline" } */
+
+namespace {
+struct A
+{
+ virtual void foo(void) {}
+};
+struct B: virtual A
+{
+ virtual void foo(void) {}
+};
+struct C: virtual A
+{
+ virtual void bar(void) {}
+};
+struct D: virtual A
+{
+ virtual void sparta(void) {}
+};
+struct E: B,C,D
+{
+ virtual void foo(void) {}
+ virtual void barbar(void) {}
+};
+} // anonymous namespace
+
+int main()
+{
+ struct A a;
+ struct B b;
+ struct C c;
+ struct D d;
+ struct E e;
+
+ a.foo();
+ b.foo();
+ c.bar();
+ d.foo();
+ d.sparta();
+ e.barbar();
+
+ return 123;
+}
+
+/* { dg-final { scan-ipa-dump "Varpool alias has been created" "icf" } } */
+/* { dg-final { scan-ipa-dump-times "Callgraph alias has been created" 5 "icf" } } */
+/* { dg-final { scan-ipa-dump "Equal symbols: 6" "icf" } } */
+/* { dg-final { cleanup-ipa-dump "icf" } } */
diff --git a/gcc/testsuite/g++.dg/ipa/ipa-icf-5.C b/gcc/testsuite/g++.dg/ipa/ipa-icf-5.C
new file mode 100644
index 0000000..728df20
--- /dev/null
+++ b/gcc/testsuite/g++.dg/ipa/ipa-icf-5.C
@@ -0,0 +1,24 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -fdump-ipa-icf" } */
+
+struct test
+{
+ int a;
+ float b;
+};
+
+extern const struct test myarray __attribute__ ((visibility("hidden")));
+extern const struct test myarray_alias __attribute__ ((visibility("hidden")));
+
+const struct test myarray = {1, 1.5f};
+
+extern const struct test myarray_alias __attribute__ ((alias ("myarray")));
+
+int main()
+{
+ return myarray.a - myarray_alias.a;
+}
+
+/* { dg-final { scan-ipa-dump "Varpool alias cannot be created \\(alias cycle\\)." "icf" } } */
+/* { dg-final { scan-ipa-dump "Equal symbols: 1" "icf" } } */
+/* { dg-final { cleanup-ipa-dump "icf" } } */
diff --git a/gcc/testsuite/gcc.dg/ipa/ipa-icf-1.c b/gcc/testsuite/gcc.dg/ipa/ipa-icf-1.c
new file mode 100644
index 0000000..aeee356
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/ipa/ipa-icf-1.c
@@ -0,0 +1,61 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -fdump-ipa-icf" } */
+
+#include <stdio.h>
+
+struct container
+{
+ int x;
+ int y;
+};
+
+static struct container max;
+static int array[3][3];
+static int array2[123];
+
+__attribute__ ((noinline))
+void foo(void)
+{
+ printf("Foo()");
+}
+
+__attribute__ ((noinline))
+int order(int x, int y)
+{
+ return x < y ? 2 : 4;
+}
+
+__attribute__ ((noinline))
+int order2(int y, int x)
+{
+ return x < y ? 2 : 4;
+}
+
+__attribute__ ((noinline))
+void x1(int x)
+{
+ int i;
+ for(i = 0; i < 20; ++i)
+ array2[i] = i;
+
+ array2[2] = 13;
+}
+
+__attribute__ ((noinline))
+void x2(int a)
+{
+ int i;
+ for(i = 0; i < 20; ++i)
+ array2[i] = i;
+
+ array2[2] = 13;
+}
+
+int main(int argc, char **argv)
+{
+ return 0;
+}
+
+/* { dg-final { scan-ipa-dump "Semantic equality hit:x2->x1" "icf" } } */
+/* { dg-final { scan-ipa-dump "Equal symbols: 1" "icf" } } */
+/* { dg-final { cleanup-ipa-dump "icf" } } */
diff --git a/gcc/testsuite/gcc.dg/ipa/ipa-icf-10.c b/gcc/testsuite/gcc.dg/ipa/ipa-icf-10.c
new file mode 100644
index 0000000..b9bca60
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/ipa/ipa-icf-10.c
@@ -0,0 +1,34 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -fdump-ipa-icf" } */
+
+int ferda(int x, int y) __attribute__ ((pure));
+int funkce(int a, int b) __attribute__ ((pure));
+
+__attribute__ ((noinline))
+int ferda(int x, int y)
+{
+ if (x < y)
+ {
+ return x;
+ }
+ else
+ return y;
+}
+
+__attribute__ ((noinline))
+int funkce(int a, int b)
+{
+ if(a < b)
+ return a;
+ else
+ return b;
+}
+
+int main(int argc, char **argv)
+{
+ return 0;
+}
+
+/* { dg-final { scan-ipa-dump "Semantic equality hit:funkce->ferda" "icf" } } */
+/* { dg-final { scan-ipa-dump "Equal symbols: 1" "icf" } } */
+/* { dg-final { cleanup-ipa-dump "icf" } } */
diff --git a/gcc/testsuite/gcc.dg/ipa/ipa-icf-11.c b/gcc/testsuite/gcc.dg/ipa/ipa-icf-11.c
new file mode 100644
index 0000000..2eb90da
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/ipa/ipa-icf-11.c
@@ -0,0 +1,29 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -fdump-ipa-icf" } */
+
+__attribute__ ((noinline))
+int fce(int a, int b)
+{
+ return a + b;
+}
+
+__attribute__ ((noinline))
+int f0(int a)
+{
+ return fce(a, 5) + fce(a, 7);
+}
+
+__attribute__ ((noinline))
+int f1(int a)
+{
+ return fce(a, 5) + fce(a, 7);
+}
+
+int main(int argc, char **argv)
+{
+ return f0(argc) * f1(argc);
+}
+
+/* { dg-final { scan-ipa-dump "Semantic equality hit:f1->f0" "icf" } } */
+/* { dg-final { scan-ipa-dump "Equal symbols: 1" "icf" } } */
+/* { dg-final { cleanup-ipa-dump "icf" } } */
diff --git a/gcc/testsuite/gcc.dg/ipa/ipa-icf-12.c b/gcc/testsuite/gcc.dg/ipa/ipa-icf-12.c
new file mode 100644
index 0000000..d4b7c38
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/ipa/ipa-icf-12.c
@@ -0,0 +1,78 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -fdump-ipa-icf" } */
+
+#include <stdlib.h>
+#include <stdio.h>
+
+int gcd(int x, int y) __attribute__ ((pure));
+
+__attribute__ ((noinline))
+int gcd(int x, int y)
+{
+ int swap;
+
+ if(x <= 0 || y <= 0)
+ return 0;
+
+ if(x < y)
+ {
+ swap = x;
+ x = y;
+ y = swap;
+ }
+
+ while(x != y)
+ {
+ x = x - y;
+
+ if(y > x)
+ {
+ swap = x;
+ x = y;
+ y = swap;
+ }
+ }
+
+ return x;
+}
+
+int nsd(int x, int y) __attribute__ ((pure));
+
+__attribute__ ((noinline))
+int nsd(int x, int y)
+{
+ int swap;
+
+ if(x <= 0 || y <= 0)
+ return 0;
+
+ if(x < y)
+ {
+ swap = x;
+ x = y;
+ y = swap;
+ }
+
+ while(x != y)
+ {
+ x = x - y;
+
+ if(y > x)
+ {
+ swap = x;
+ x = y;
+ y = swap;
+ }
+ }
+
+ return x;
+}
+
+int main(int argc, char **argv)
+{
+ return 0;
+}
+
+/* { dg-final { scan-ipa-dump "Semantic equality hit:nsd->gcd" "icf" } } */
+/* { dg-final { scan-ipa-dump "Equal symbols: 1" "icf" } } */
+/* { dg-final { cleanup-ipa-dump "icf" } } */
diff --git a/gcc/testsuite/gcc.dg/ipa/ipa-icf-13.c b/gcc/testsuite/gcc.dg/ipa/ipa-icf-13.c
new file mode 100644
index 0000000..e409ee4
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/ipa/ipa-icf-13.c
@@ -0,0 +1,194 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -fdump-ipa-icf" } */
+
+#include <stdlib.h>
+#include <stdio.h>
+
+int gcd(int x, int y) __attribute__ ((pure));
+
+__attribute__ ((noinline))
+int gcd(int x, int y)
+{
+ int swap;
+
+ if(x <= 0 || y <= 0)
+ return 0;
+
+ if(x < y)
+ {
+ swap = x;
+ x = y;
+ y = swap;
+ }
+
+ while(x != y)
+ {
+ x = x - y;
+
+ if(y > x)
+ {
+ swap = x;
+ x = y;
+ y = swap;
+ }
+ }
+
+ return x;
+}
+
+int nsd(int x, int y) __attribute__ ((pure));
+
+__attribute__ ((noinline))
+int nsd(int x, int y)
+{
+ int swap;
+
+ if(x <= 0 || y <= 0)
+ return 0;
+
+ if(x < y)
+ {
+ swap = x;
+ x = y;
+ y = swap;
+ }
+
+ while(x != y)
+ {
+ x = x - y;
+
+ if(y > x)
+ {
+ swap = x;
+ x = y;
+ y = swap;
+ }
+ }
+
+ return x;
+}
+
+int nsd_different_result(int x, int y) __attribute__ ((pure));
+
+__attribute__ ((noinline))
+int nsd_different_result(int x, int y)
+{
+ int pes;
+
+ if(x <= 0 || y <= 0)
+ return 1;
+
+ if(x < 10)
+ y = 12;
+ else if(x == 44)
+ y = 124;
+ else
+ y = 1111;
+
+ if(x < y)
+ {
+ pes = x;
+ x = y;
+ y = pes;
+ }
+
+ while(x != y)
+ {
+ x = x - y;
+
+ if(y > x)
+ {
+ pes = x;
+ x = y;
+ y = pes;
+ }
+ }
+
+ return x;
+}
+
+int nsd_different_result2(int x, int y) __attribute__ ((pure));
+
+__attribute__ ((noinline))
+int nsd_different_result2(int x, int y)
+{
+ int pes;
+
+ if(x <= 0 || y <= 0)
+ return 1;
+
+ if(x < 10)
+ y = 12;
+ else if(x == 44)
+ y = 124;
+ else
+ y = 1111;
+
+ if(x < y)
+ {
+ pes = x;
+ x = y;
+ y = pes;
+ }
+
+ while(x != y)
+ {
+ x = x - y;
+
+ if(y > x)
+ {
+ pes = x;
+ x = y;
+ y = pes;
+ }
+ }
+
+ return x;
+}
+
+__attribute__ ((noinline))
+int s1(int x)
+{
+ switch (x)
+ {
+ case 10:
+ case 11:
+ return 2;
+ case 12:
+ return 123;
+ default:
+ return x + 2;
+ }
+}
+
+__attribute__ ((noinline))
+int s2(int x)
+{
+ switch (x)
+ {
+ case 10:
+ case 11:
+ return 2;
+ case 12:
+ return 123;
+ default:
+ return x + 2;
+ }
+}
+int main(int argc, char **argv)
+{
+ if(argc < 3)
+ return 1;
+
+ int a = atoi(argv[1]);
+ int b = atoi(argv[2]);
+
+ printf("Test1: %d, %d, gdc: %d\n", a, b, gcd(a, b));
+ printf("Test2: %d, %d, gdc: %d\n", a, b, nsd(a, b));
+}
+
+/* { dg-final { scan-ipa-dump "Semantic equality hit:s2->s1" "icf" } } */
+/* { dg-final { scan-ipa-dump "Semantic equality hit:nsd_different_result2->nsd_different_result" "icf" } } */
+/* { dg-final { scan-ipa-dump "Semantic equality hit:nsd->gcd" "icf" } } */
+/* { dg-final { scan-ipa-dump "Equal symbols: 3" "icf" } } */
+/* { dg-final { cleanup-ipa-dump "icf" } } */
diff --git a/gcc/testsuite/gcc.dg/ipa/ipa-icf-14.c b/gcc/testsuite/gcc.dg/ipa/ipa-icf-14.c
new file mode 100644
index 0000000..cae02fb
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/ipa/ipa-icf-14.c
@@ -0,0 +1,47 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -fdump-ipa-icf" } */
+
+#include <stdio.h>
+
+__attribute__ ((noinline))
+int foo(int a)
+{
+ void *l = &&error;
+
+ if(a == 4)
+ goto *l;
+
+ return 150;
+
+error:
+ return a;
+failure:
+ return a + 2;
+}
+
+__attribute__ ((noinline))
+int foo_wrong(int a)
+{
+ void *l = &&failure;
+
+ if(a == 4)
+ goto *l;
+
+ return 150;
+
+error:
+ return a;
+failure:
+ return a + 2;
+}
+
+int main(int argc, char **argv)
+{
+ printf("value: %d\n", foo(argc));
+
+ return 0;
+}
+
+/* { dg-final { scan-ipa-dump-not "Semantic equality hit:" "icf" } } */
+/* { dg-final { scan-ipa-dump "Equal symbols: 0" "icf" } } */
+/* { dg-final { cleanup-ipa-dump "icf" } } */
diff --git a/gcc/testsuite/gcc.dg/ipa/ipa-icf-15.c b/gcc/testsuite/gcc.dg/ipa/ipa-icf-15.c
new file mode 100644
index 0000000..f6e7fb3
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/ipa/ipa-icf-15.c
@@ -0,0 +1,47 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -fdump-ipa-icf" } */
+
+#include <stdio.h>
+
+__attribute__ ((noinline))
+int bar(int a)
+{
+ void *l = &&error;
+
+ if(a == 4)
+ goto *l;
+
+ return 150;
+
+error:
+ return a;
+failure:
+ return a + 2;
+}
+
+__attribute__ ((noinline))
+int foo(int a)
+{
+ void *l = &&error;
+
+ if(a == 4)
+ goto *l;
+
+ return 150;
+
+error:
+ return a;
+failure:
+ return a + 2;
+}
+
+int main(int argc, char **argv)
+{
+ printf("value: %d\n", foo(argc));
+
+ return 0;
+}
+
+/* { dg-final { scan-ipa-dump "Semantic equality hit:foo->bar" "icf" } } */
+/* { dg-final { scan-ipa-dump "Equal symbols: 1" "icf" } } */
+/* { dg-final { cleanup-ipa-dump "icf" } } */
diff --git a/gcc/testsuite/gcc.dg/ipa/ipa-icf-16.c b/gcc/testsuite/gcc.dg/ipa/ipa-icf-16.c
new file mode 100644
index 0000000..fb0b116
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/ipa/ipa-icf-16.c
@@ -0,0 +1,27 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -fdump-ipa-icf" } */
+
+#include <stdio.h>
+
+__attribute__ ((noinline))
+int foo()
+{
+ printf ("Hello world.\n");
+ return 0;
+}
+
+__attribute__ ((noinline))
+int bar()
+{
+ printf ("Hello world.\n");
+ return 0;
+}
+
+int main()
+{
+ return foo() + bar();
+}
+
+/* { dg-final { scan-ipa-dump "Semantic equality hit:bar->foo" "icf" } } */
+/* { dg-final { scan-ipa-dump "Equal symbols: 1" "icf" } } */
+/* { dg-final { cleanup-ipa-dump "icf" } } */
diff --git a/gcc/testsuite/gcc.dg/ipa/ipa-icf-17.c b/gcc/testsuite/gcc.dg/ipa/ipa-icf-17.c
new file mode 100644
index 0000000..7c9172d
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/ipa/ipa-icf-17.c
@@ -0,0 +1,37 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -fdump-ipa-icf" } */
+
+__attribute__ ((noinline))
+int foo(int x)
+{
+ int c = x;
+
+ if (x > 10)
+ c += 2;
+ else
+ c -= 3;
+
+ return x;
+}
+
+__attribute__ ((noinline))
+int bar(int y)
+{
+ int d = y;
+
+ if (y > 10)
+ d += 2;
+ else
+ d -= 3;
+
+ return d;
+}
+
+int main()
+{
+ return 0;
+}
+
+/* { dg-final { scan-ipa-dump-not "Semantic equality hit:" "icf" } } */
+/* { dg-final { scan-ipa-dump "Equal symbols: 0" "icf" } } */
+/* { dg-final { cleanup-ipa-dump "icf" } } */
diff --git a/gcc/testsuite/gcc.dg/ipa/ipa-icf-18.c b/gcc/testsuite/gcc.dg/ipa/ipa-icf-18.c
new file mode 100644
index 0000000..9dc3979
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/ipa/ipa-icf-18.c
@@ -0,0 +1,37 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -fdump-ipa-icf" } */
+
+__attribute__ ((noinline))
+int foo(int x)
+{
+ int c = x;
+
+ if (x > 10)
+ c += 2;
+ else
+ c -= 3;
+
+ return c;
+}
+
+__attribute__ ((noinline))
+int bar(int y)
+{
+ int d = y;
+
+ if (y > 10)
+ d += 2;
+ else
+ d -= 3;
+
+ return d;
+}
+
+int main()
+{
+ return 0;
+}
+
+/* { dg-final { scan-ipa-dump "Semantic equality hit:bar->foo" "icf" } } */
+/* { dg-final { scan-ipa-dump "Equal symbols: 1" "icf" } } */
+/* { dg-final { cleanup-ipa-dump "icf" } } */
diff --git a/gcc/testsuite/gcc.dg/ipa/ipa-icf-19.c b/gcc/testsuite/gcc.dg/ipa/ipa-icf-19.c
new file mode 100644
index 0000000..7a29cf3
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/ipa/ipa-icf-19.c
@@ -0,0 +1,37 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -fdump-ipa-icf" } */
+
+__attribute__ ((noinline))
+int foo(int x)
+{
+ int c = x;
+
+ if (x > 10)
+ c += 2;
+ else
+ c -= 3;
+
+ return c;
+}
+
+__attribute__ ((noinline))
+int bar(int y)
+{
+ int d = y;
+
+ if (y > 11)
+ d += 2;
+ else
+ d -= 3;
+
+ return d;
+}
+
+int main()
+{
+ return 0;
+}
+
+/* { dg-final { scan-ipa-dump-not "Semantic equality hit:" "icf" } } */
+/* { dg-final { scan-ipa-dump "Equal symbols: 0" "icf" } } */
+/* { dg-final { cleanup-ipa-dump "icf" } } */
diff --git a/gcc/testsuite/gcc.dg/ipa/ipa-icf-2.c b/gcc/testsuite/gcc.dg/ipa/ipa-icf-2.c
new file mode 100644
index 0000000..385db0c
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/ipa/ipa-icf-2.c
@@ -0,0 +1,69 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -fdump-ipa-icf" } */
+
+#include <stdio.h>
+
+struct container
+{
+ int x;
+ int y;
+};
+
+static struct container max;
+static int pole[3][3];
+static int pole2[123];
+
+static struct container superpole[10][10];
+
+void f1(struct container *c)
+{
+ struct container pes;
+ pes.x = 123;
+ pes.y = 123;
+
+ struct container *pesp = c;
+ pesp->x = 5;
+
+ pole[1][2] = 3;
+
+ superpole[4][3].x = 4;
+ max.x = 3;
+ void *x = &pole;
+
+ int **a = (int**)pole;
+ a[1][2] = 543;
+
+ if(x != 0)
+ pole[1][2] = 123;
+}
+
+void f2(struct container *c)
+{
+ struct container pes;
+ pes.x = 123;
+ pes.y = 123;
+
+ struct container *pesp = c;
+ pesp->x = 5;
+
+ pole[1][2] = 3;
+
+ superpole[4][3].x = 4;
+ max.x = 3;
+ void *x = &pole;
+
+ int **a = (int**)pole;
+ a[1][2] = 543;
+
+ if(x != 0)
+ pole[1][2] = 123;
+}
+
+int main(int argc, char **argv)
+{
+ return 0;
+}
+
+/* { dg-final { scan-ipa-dump "Semantic equality hit:f2->f1" "icf" } } */
+/* { dg-final { scan-ipa-dump "Equal symbols: 1" "icf" } } */
+/* { dg-final { cleanup-ipa-dump "icf" } } */
diff --git a/gcc/testsuite/gcc.dg/ipa/ipa-icf-20.c b/gcc/testsuite/gcc.dg/ipa/ipa-icf-20.c
new file mode 100644
index 0000000..9912a9a
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/ipa/ipa-icf-20.c
@@ -0,0 +1,28 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -fdump-ipa-icf" } */
+
+#include <math.h>
+
+__attribute__ ((noinline))
+float foo()
+{
+ return sin(12.4f);
+}
+
+__attribute__ ((noinline))
+float bar()
+{
+ return sin(12.4f);
+}
+
+int main()
+{
+ foo();
+ bar();
+
+ return 0;
+}
+
+/* { dg-final { scan-ipa-dump "Semantic equality hit:bar->foo" "icf" } } */
+/* { dg-final { scan-ipa-dump "Equal symbols: 1" "icf" } } */
+/* { dg-final { cleanup-ipa-dump "icf" } } */
diff --git a/gcc/testsuite/gcc.dg/ipa/ipa-icf-21.c b/gcc/testsuite/gcc.dg/ipa/ipa-icf-21.c
new file mode 100644
index 0000000..7358e43
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/ipa/ipa-icf-21.c
@@ -0,0 +1,27 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -fdump-ipa-icf" } */
+
+#include <xmmintrin.h>
+
+__attribute__ ((noinline))
+void foo()
+{
+ float x = 1.2345f;
+ __m128 v =_mm_load1_ps(&x);
+}
+
+__attribute__ ((noinline))
+void bar()
+{
+ float x = 1.2345f;
+ __m128 v =_mm_load1_ps(&x);
+}
+
+int main()
+{
+ return 2;
+}
+
+/* { dg-final { scan-ipa-dump "Semantic equality hit:bar->foo" "icf" } } */
+/* { dg-final { scan-ipa-dump "Equal symbols: 1" "icf" } } */
+/* { dg-final { cleanup-ipa-dump "icf" } } */
diff --git a/gcc/testsuite/gcc.dg/ipa/ipa-icf-22.c b/gcc/testsuite/gcc.dg/ipa/ipa-icf-22.c
new file mode 100644
index 0000000..9561026
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/ipa/ipa-icf-22.c
@@ -0,0 +1,37 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -fdump-ipa-icf" } */
+
+struct A
+{
+ int a, b, c;
+};
+
+struct B
+{
+ int x, y;
+};
+
+__attribute__ ((noinline))
+int foo(struct A *a)
+{
+ a->c = 1;
+
+ return 123;
+}
+
+__attribute__ ((noinline))
+int bar(struct B *b)
+{
+ b->y = 1;
+
+ return 123;
+}
+
+int main()
+{
+ return foo(0) + bar(0);
+}
+
+/* { dg-final { scan-ipa-dump-not "Semantic equality hit:" "icf" } } */
+/* { dg-final { scan-ipa-dump "Equal symbols: 0" "icf" } } */
+/* { dg-final { cleanup-ipa-dump "icf" } } */
diff --git a/gcc/testsuite/gcc.dg/ipa/ipa-icf-23.c b/gcc/testsuite/gcc.dg/ipa/ipa-icf-23.c
new file mode 100644
index 0000000..7e81ae2
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/ipa/ipa-icf-23.c
@@ -0,0 +1,29 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -fdump-ipa-icf" } */
+
+struct A
+{
+ int a;
+ int b;
+};
+
+__attribute__ ((noinline))
+int foo(struct A *a)
+{
+ return 123;
+}
+
+__attribute__ ((noinline))
+int bar(struct A *b)
+{
+ return 123;
+}
+
+int main()
+{
+ return foo(0) + bar(0);
+}
+
+/* { dg-final { scan-ipa-dump "Semantic equality hit:bar->foo" "icf" } } */
+/* { dg-final { scan-ipa-dump "Equal symbols: 1" "icf" } } */
+/* { dg-final { cleanup-ipa-dump "icf" } } */
diff --git a/gcc/testsuite/gcc.dg/ipa/ipa-icf-24.c b/gcc/testsuite/gcc.dg/ipa/ipa-icf-24.c
new file mode 100644
index 0000000..3cd476f
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/ipa/ipa-icf-24.c
@@ -0,0 +1,36 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -fdump-ipa-icf" } */
+
+struct A
+{
+ int a, b, c, d;
+};
+
+struct B
+{
+ int x, y, z;
+};
+
+__attribute__ ((noinline))
+int foo(struct A *a)
+{
+ a->c = 1;
+
+ return 123;
+}
+
+__attribute__ ((noinline))
+int bar(struct B *b)
+{
+ b->z = 1;
+
+ return 123;
+}
+
+int main()
+{
+ return foo(0) + bar(0);
+}
+
+/* { dg-final { scan-ipa-dump "Equal symbols: 0" "icf" } } */
+/* { dg-final { cleanup-ipa-dump "icf" } } */
diff --git a/gcc/testsuite/gcc.dg/ipa/ipa-icf-25.c b/gcc/testsuite/gcc.dg/ipa/ipa-icf-25.c
new file mode 100644
index 0000000..e6cf8ac
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/ipa/ipa-icf-25.c
@@ -0,0 +1,48 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -fdump-ipa-icf" } */
+
+__attribute__ ((noinline))
+int foo()
+{
+ return zip();
+}
+
+__attribute__ ((noinline))
+int bar()
+{
+ return zap();
+}
+
+__attribute__ ((noinline))
+int baz()
+{
+ return two();
+}
+
+__attribute__ ((noinline))
+int zip()
+{
+ return 0;
+}
+
+__attribute__ ((noinline))
+int zap()
+{
+ return 0;
+}
+
+__attribute__ ((noinline))
+int two()
+{
+ return 2;
+}
+
+int main()
+{
+ return foo() + bar();
+}
+
+/* { dg-final { scan-ipa-dump "Semantic equality hit:bar->foo" "icf" } } */
+/* { dg-final { scan-ipa-dump "Semantic equality hit:zap->zip" "icf" } } */
+/* { dg-final { scan-ipa-dump "Equal symbols: 2" "icf" } } */
+/* { dg-final { cleanup-ipa-dump "icf" } } */
diff --git a/gcc/testsuite/gcc.dg/ipa/ipa-icf-26.c b/gcc/testsuite/gcc.dg/ipa/ipa-icf-26.c
new file mode 100644
index 0000000..0c5a5a6
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/ipa/ipa-icf-26.c
@@ -0,0 +1,44 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -fdump-ipa-icf" } */
+
+void destroy (void)
+{
+}
+
+void remove (void)
+{
+}
+
+
+struct callbacks
+{
+ void (*success) (void);
+ void (*error) (void);
+};
+
+struct callbacks my_callbacks;
+
+__attribute__ ((noinline))
+void foo()
+{
+ my_callbacks.success = destroy;
+}
+
+__attribute__ ((noinline))
+void bar()
+{
+ my_callbacks.success = remove;
+}
+
+int main()
+{
+ foo();
+ bar();
+
+ return 0;
+}
+
+/* { dg-final { scan-ipa-dump "Semantic equality hit:bar->foo" "icf" } } */
+/* { dg-final { scan-ipa-dump "Semantic equality hit:remove->destroy" "icf" } } */
+/* { dg-final { scan-ipa-dump "Equal symbols: 2" "icf" } } */
+/* { dg-final { cleanup-ipa-dump "icf" } } */
diff --git a/gcc/testsuite/gcc.dg/ipa/ipa-icf-27.c b/gcc/testsuite/gcc.dg/ipa/ipa-icf-27.c
new file mode 100644
index 0000000..fab2e41
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/ipa/ipa-icf-27.c
@@ -0,0 +1,30 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -fdump-ipa-icf -fno-inline" } */
+
+void destroy (void)
+{
+ __asm__ __volatile__ ("" : : : "memory");
+}
+
+void remove (void)
+{
+ __asm__ __volatile__ ("" : : : "memory");
+}
+
+void remove2 (void)
+{
+ __asm__ __volatile__ ("" : : : );
+}
+
+int main()
+{
+ destroy ();
+ remove ();
+ remove2 ();
+
+ return 0;
+}
+
+/* { dg-final { scan-ipa-dump "Semantic equality hit:remove->destroy" "icf" } } */
+/* { dg-final { scan-ipa-dump "Equal symbols: 1" "icf" } } */
+/* { dg-final { cleanup-ipa-dump "icf" } } */
diff --git a/gcc/testsuite/gcc.dg/ipa/ipa-icf-28.c b/gcc/testsuite/gcc.dg/ipa/ipa-icf-28.c
new file mode 100644
index 0000000..538e0ab
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/ipa/ipa-icf-28.c
@@ -0,0 +1,24 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -fdump-ipa-icf-details -fno-inline" } */
+
+__attribute__ ((noinline, constructor(200)))
+int foo()
+{
+ return 123;
+}
+
+__attribute__ ((noinline, constructor(400)))
+int bar()
+{
+ return 123;
+}
+
+int main()
+{
+ foo() + bar();
+
+ return 0;
+}
+/* { dg-final { scan-ipa-dump "Equal symbols: 0" "icf" } } */
+/* { dg-final { scan-ipa-dump "attribute values are different" "icf" } } */
+/* { dg-final { cleanup-ipa-dump "icf" } } */
diff --git a/gcc/testsuite/gcc.dg/ipa/ipa-icf-3.c b/gcc/testsuite/gcc.dg/ipa/ipa-icf-3.c
new file mode 100644
index 0000000..e4e2eb6
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/ipa/ipa-icf-3.c
@@ -0,0 +1,36 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -fdump-ipa-icf" } */
+
+typedef int v4si __attribute__ ((vector_size (16)));
+
+__attribute__ ((noinline))
+int foo(void)
+{
+ v4si a = {1,2,3,4};
+ v4si b = {3,2,1,4};
+ v4si c;
+
+ return 54;
+}
+
+__attribute__ ((noinline))
+int bar(void)
+{
+ v4si a = {1,2,3,4};
+ v4si b = {3,2,1,4};
+ v4si c;
+
+ return 54;
+}
+
+int main()
+{
+ foo();
+ bar();
+
+ return 0;
+}
+
+/* { dg-final { scan-ipa-dump "Semantic equality hit:bar->foo" "icf" } } */
+/* { dg-final { scan-ipa-dump "Equal symbols: 1" "icf" } } */
+/* { dg-final { cleanup-ipa-dump "icf" } } */
diff --git a/gcc/testsuite/gcc.dg/ipa/ipa-icf-4.c b/gcc/testsuite/gcc.dg/ipa/ipa-icf-4.c
new file mode 100644
index 0000000..9434fb0
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/ipa/ipa-icf-4.c
@@ -0,0 +1,32 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -fdump-ipa-icf" } */
+
+__attribute__ ((noinline))
+int foo(int a)
+{
+ return a * a;
+}
+
+__attribute__ ((noinline))
+int bar(int b)
+{
+ return b;
+}
+
+__attribute__ ((noinline))
+void caller(int x)
+{
+ return;
+}
+
+int main(int argc, char **argv)
+{
+ caller(foo(argc));
+ caller(bar(argc));
+
+ return 123;
+}
+
+/* { dg-final { scan-ipa-dump-not "Semantic equality hit:" "icf" } } */
+/* { dg-final { scan-ipa-dump "Equal symbols: 0" "icf" } } */
+/* { dg-final { cleanup-ipa-dump "icf" } } */
diff --git a/gcc/testsuite/gcc.dg/ipa/ipa-icf-5.c b/gcc/testsuite/gcc.dg/ipa/ipa-icf-5.c
new file mode 100644
index 0000000..45fddf5
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/ipa/ipa-icf-5.c
@@ -0,0 +1,55 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -fdump-ipa-icf" } */
+
+#include <complex.h>
+
+static double test;
+
+__attribute__ ((noinline))
+double f1(void)
+{
+ double complex z1 = 1.0 + 3.0 * I;
+ double complex z2 = 1.0 - 4.0 * I;
+
+ unsigned a = 123;
+ unsigned b = 321;
+
+ if (a & b)
+ return 1.2f;
+
+ if(cimag(z1) > 1)
+ return 1.0f;
+
+ test = cimag(z1) + 2;
+
+ return cimag(z1 + z2);
+}
+
+__attribute__ ((noinline))
+double f2(void)
+{
+ double complex z1 = 1.0 + 3.0 * I;
+ double complex z2 = 1.0 - 4.0 * I;
+
+ unsigned a = 123;
+ unsigned b = 321;
+
+ if (a & b)
+ return 1.2f;
+
+ if(cimag(z1) > 1)
+ return 1.0f;
+
+ test = cimag(z1) + 2;
+
+ return cimag(z1 + z2);
+}
+
+int main()
+{
+ return 1;
+}
+
+/* { dg-final { scan-ipa-dump "Semantic equality hit:f2->f1" "icf" } } */
+/* { dg-final { scan-ipa-dump "Equal symbols: 1" "icf" } } */
+/* { dg-final { cleanup-ipa-dump "icf" } } */
diff --git a/gcc/testsuite/gcc.dg/ipa/ipa-icf-6.c b/gcc/testsuite/gcc.dg/ipa/ipa-icf-6.c
new file mode 100644
index 0000000..6e6758e
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/ipa/ipa-icf-6.c
@@ -0,0 +1,36 @@
+/* { dg-do compile } */
+/* { dg-options "-O0 -fipa-icf -fdump-ipa-icf" } */
+
+typedef int v4si __attribute__ ((vector_size (16)));
+
+__attribute__ ((noinline))
+int foo(void)
+{
+ v4si a = {1,2,3,4};
+ v4si b = {3,2,1,4};
+ v4si c;
+
+ return 54;
+}
+
+__attribute__ ((noinline))
+int bar(void)
+{
+ v4si a = {1,2,3,4};
+ v4si b = {3,2,5,4};
+ v4si c;
+
+ return 54;
+}
+
+int main()
+{
+ foo();
+ bar();
+
+ return 0;
+}
+
+/* { dg-final { scan-ipa-dump-not "Semantic equality hit:" "icf" } } */
+/* { dg-final { scan-ipa-dump "Equal symbols: 0" "icf" } } */
+/* { dg-final { cleanup-ipa-dump "icf" } } */
diff --git a/gcc/testsuite/gcc.dg/ipa/ipa-icf-7.c b/gcc/testsuite/gcc.dg/ipa/ipa-icf-7.c
new file mode 100644
index 0000000..ec7961d
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/ipa/ipa-icf-7.c
@@ -0,0 +1,72 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -fdump-ipa-icf" } */
+
+#include <complex.h>
+
+#if (__SIZEOF_INT__ == __SIZEOF_FLOAT__)
+typedef int intflt;
+#elif (__SIZEOF_LONG__ == __SIZEOF_FLOAT__)
+typedef long intflt;
+#else
+#error Add target support here for type that will union float size
+#endif
+
+
+static double test;
+
+struct struktura
+{
+ union
+ {
+ long i;
+ float f;
+ } u;
+};
+
+struct struktura sss;
+
+struct X
+{
+ int i;
+ union
+ {
+ intflt j;
+ intflt k;
+ float f;
+ } u;
+};
+
+__attribute__ ((noinline))
+intflt foo(intflt j)
+{
+ struct X a;
+
+ a.u.j = j;
+ a.u.f = a.u.f;
+ a.u.f = a.u.f;
+ a.u.j = a.u.j;
+ a.u.f = a.u.f;
+ return a.u.k;
+}
+
+__attribute__ ((noinline))
+intflt foo2(intflt j)
+{
+ struct X a;
+
+ a.u.j = j;
+ a.u.f = a.u.f;
+ a.u.f = a.u.f;
+ a.u.j = a.u.j;
+ a.u.f = a.u.f;
+ return a.u.k;
+}
+
+int main()
+{
+ return 1;
+}
+
+/* { dg-final { scan-ipa-dump "Semantic equality hit:foo2->foo" "icf" } } */
+/* { dg-final { scan-ipa-dump "Equal symbols: 1" "icf" } } */
+/* { dg-final { cleanup-ipa-dump "icf" } } */
diff --git a/gcc/testsuite/gcc.dg/ipa/ipa-icf-8.c b/gcc/testsuite/gcc.dg/ipa/ipa-icf-8.c
new file mode 100644
index 0000000..d35df90
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/ipa/ipa-icf-8.c
@@ -0,0 +1,45 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -fdump-ipa-icf" } */
+
+#include <stdio.h>
+
+__attribute__ ((noinline))
+int fce1(int a, int b)
+{
+ int swap;
+
+ if(a < b)
+ {
+ swap = a;
+ a = b;
+ b = swap;
+ }
+
+ return a / b;
+}
+
+__attribute__ ((noinline))
+int fce2(int x, int y)
+{
+ int tmp;
+
+ if(x < y)
+ {
+ tmp = x;
+ x = y;
+ y = tmp;
+ }
+
+ return x / y;
+}
+
+
+int main(int argc, char **argv)
+{
+ printf("fce1: %d\n", fce1(argc, argc + 2));
+ printf("fce2: %d\n", fce2(argc, 2 * argc));
+}
+
+/* { dg-final { scan-ipa-dump "Semantic equality hit:fce2->fce1" "icf" } } */
+/* { dg-final { scan-ipa-dump "Equal symbols: 1" "icf" } } */
+/* { dg-final { cleanup-ipa-dump "icf" } } */
diff --git a/gcc/testsuite/gcc.dg/ipa/ipa-icf-9.c b/gcc/testsuite/gcc.dg/ipa/ipa-icf-9.c
new file mode 100644
index 0000000..9d04dd1
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/ipa/ipa-icf-9.c
@@ -0,0 +1,33 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -fdump-ipa-icf" } */
+
+int funkce(int a, int b) __attribute__ ((pure));
+
+__attribute__ ((noinline))
+int ferda(int x, int y)
+{
+ if (x < y)
+ {
+ return x;
+ }
+ else
+ return y;
+}
+
+__attribute__ ((noinline))
+int funkce(int a, int b)
+{
+ if(a < b)
+ return a;
+ else
+ return b;
+}
+
+int main(int argc, char **argv)
+{
+ return 0;
+}
+
+/* { dg-final { scan-ipa-dump-not "Semantic equality hit:" "icf" } } */
+/* { dg-final { scan-ipa-dump "Equal symbols: 0" "icf" } } */
+/* { dg-final { cleanup-ipa-dump "icf" } } */
--
1.8.4.5
next prev parent reply other threads:[~2014-06-30 12:14 UTC|newest]
Thread overview: 70+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-06-16 10:07 [PATCH 1/5] New Identical Code Folding IPA pass mliska
2014-06-16 10:07 ` [PATCH 5/5] New tests introduction mliska
2014-06-17 19:53 ` Jeff Law
2014-06-30 12:14 ` Martin Liška [this message]
2014-10-19 8:19 ` Andreas Schwab
2014-10-23 12:34 ` Martin Liška
2014-06-16 10:07 ` [PATCH 2/5] Existing call graph infrastructure enhancement mliska
2014-06-17 20:00 ` Jeff Law
2014-06-30 11:49 ` Martin Liška
2014-06-30 18:54 ` Jeff Law
2014-07-17 14:54 ` Martin Liška
2014-08-25 9:56 ` Martin Liška
2014-08-25 16:12 ` Jan Hubicka
2014-08-27 21:12 ` Jeff Law
2014-09-24 14:23 ` Martin Liška
2014-09-24 15:01 ` Jan Hubicka
2014-09-26 10:19 ` Martin Liška
2014-06-16 10:07 ` [PATCH 3/5] IPA ICF pass mliska
2014-06-20 7:32 ` Trevor Saunders
2014-06-26 11:18 ` Martin Liška
2014-07-05 21:44 ` Gerald Pfeifer
2014-07-05 22:53 ` Jan Hubicka
2014-07-17 15:23 ` Martin Liška
2014-09-26 12:20 ` Martin Liška
2014-09-26 14:44 ` Markus Trippelsdorf
2014-09-26 23:27 ` Jan Hubicka
2014-09-27 5:59 ` Markus Trippelsdorf
2014-09-27 7:47 ` Markus Trippelsdorf
2014-09-27 10:46 ` Martin Liška
2014-09-27 10:37 ` Martin Liška
2014-09-28 2:21 ` Jan Hubicka
2014-10-10 23:54 ` Fakturace
2014-10-11 0:02 ` Martin Liška
2014-10-11 8:23 ` Jan Hubicka
2014-10-13 13:20 ` Martin Liška
2014-10-13 13:29 ` Jan Hubicka
2014-09-27 10:32 ` Martin Liška
2014-09-26 20:47 ` Jan Hubicka
2014-10-11 0:08 ` Martin Liška
2014-10-11 8:26 ` Jan Hubicka
2014-10-13 15:17 ` Martin Liška
2014-10-14 16:12 ` Jan Hubicka
2014-10-15 17:06 ` Martin Liška
2014-10-22 21:20 ` Jiong Wang
2014-11-06 3:01 ` Joey Ye
2014-11-06 9:03 ` Jan Hubicka
2014-11-13 22:26 ` H.J. Lu
2015-01-20 21:29 ` H.J. Lu
2014-09-26 22:27 ` Jan Hubicka
2014-10-11 0:23 ` Martin Liška
2014-10-11 9:05 ` Jan Hubicka
2014-06-24 20:31 ` Jeff Law
2014-06-26 16:02 ` Martin Liška
2014-06-26 18:46 ` Jan Hubicka
2014-06-30 12:05 ` Martin Liška
2014-07-01 23:45 ` Trevor Saunders
2014-06-30 19:06 ` Jeff Law
2014-06-16 10:07 ` [PATCH 4/5] Existing tests fix mliska
2014-06-17 19:52 ` Jeff Law
2014-06-17 20:50 ` Rainer Orth
2014-06-18 9:02 ` Martin Liška
2014-06-30 12:12 ` Martin Liška
2014-09-26 12:21 ` Martin Liška
2014-06-17 19:49 ` [PATCH 1/5] New Identical Code Folding IPA pass Jeff Law
2014-06-18 19:05 ` Jan Hubicka
2014-06-17 20:09 ` Paolo Carlini
2014-06-18 8:46 ` Martin Liška
2014-06-18 8:49 ` Paolo Carlini
2014-06-17 20:17 ` David Malcolm
2014-06-18 8:10 ` Martin Liška
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=53B15497.2070806@suse.cz \
--to=mliska@suse.cz \
--cc=gcc-patches@gcc.gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).