summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormarxin <marxin@138bc75d-0d04-0410-961f-82ee72b054a4>2014-10-16 11:01:28 +0000
committermarxin <marxin@138bc75d-0d04-0410-961f-82ee72b054a4>2014-10-16 11:01:28 +0000
commit343d6f412f4b1b91cdde5d666bd3c6b82cc72fa6 (patch)
tree4fc9f6523c11cc2d3016b900acbd91480fcac7a7
parentb0fa59a967d603a02495f2c0a3db9a894e1dddba (diff)
downloadgcc-343d6f412f4b1b91cdde5d666bd3c6b82cc72fa6.tar.gz
IPA ICF pass, part 5/5
* g++.dg/ipa/ipa-icf-1.C: New test. * g++.dg/ipa/ipa-icf-2.C: New test. * g++.dg/ipa/ipa-icf-3.C: New test. * g++.dg/ipa/ipa-icf-4.C: New test. * g++.dg/ipa/ipa-icf-5.C: New test. * gcc.dg/ipa/ipa-icf-1.c: New test. * gcc.dg/ipa/ipa-icf-10.c: New test. * gcc.dg/ipa/ipa-icf-11.c: New test. * gcc.dg/ipa/ipa-icf-12.c: New test. * gcc.dg/ipa/ipa-icf-13.c: New test. * gcc.dg/ipa/ipa-icf-14.c: New test. * gcc.dg/ipa/ipa-icf-15.c: New test. * gcc.dg/ipa/ipa-icf-16.c: New test. * gcc.dg/ipa/ipa-icf-17.c: New test. * gcc.dg/ipa/ipa-icf-18.c: New test. * gcc.dg/ipa/ipa-icf-19.c: New test. * gcc.dg/ipa/ipa-icf-2.c: New test. * gcc.dg/ipa/ipa-icf-20.c: New test. * gcc.dg/ipa/ipa-icf-21.c: New test. * gcc.dg/ipa/ipa-icf-22.c: New test. * gcc.dg/ipa/ipa-icf-23.c: New test. * gcc.dg/ipa/ipa-icf-24.c: New test. * gcc.dg/ipa/ipa-icf-25.c: New test. * gcc.dg/ipa/ipa-icf-26.c: New test. * gcc.dg/ipa/ipa-icf-27.c: New test. * gcc.dg/ipa/ipa-icf-28.c: New test. * gcc.dg/ipa/ipa-icf-29.c: New test. * gcc.dg/ipa/ipa-icf-3.c: New test. * gcc.dg/ipa/ipa-icf-30.c: New test. * gcc.dg/ipa/ipa-icf-4.c: New test. * gcc.dg/ipa/ipa-icf-5.c: New test. * gcc.dg/ipa/ipa-icf-6.c: New test. * gcc.dg/ipa/ipa-icf-7.c: New test. * gcc.dg/ipa/ipa-icf-8.c: New test. * gcc.dg/ipa/ipa-icf-9.c: New test. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@216308 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r--gcc/testsuite/ChangeLog39
-rw-r--r--gcc/testsuite/g++.dg/ipa/ipa-icf-1.C43
-rw-r--r--gcc/testsuite/g++.dg/ipa/ipa-icf-2.C40
-rw-r--r--gcc/testsuite/g++.dg/ipa/ipa-icf-3.C36
-rw-r--r--gcc/testsuite/g++.dg/ipa/ipa-icf-4.C48
-rw-r--r--gcc/testsuite/g++.dg/ipa/ipa-icf-5.C24
-rw-r--r--gcc/testsuite/gcc.dg/ipa/ipa-icf-1.c61
-rw-r--r--gcc/testsuite/gcc.dg/ipa/ipa-icf-10.c34
-rw-r--r--gcc/testsuite/gcc.dg/ipa/ipa-icf-11.c29
-rw-r--r--gcc/testsuite/gcc.dg/ipa/ipa-icf-12.c78
-rw-r--r--gcc/testsuite/gcc.dg/ipa/ipa-icf-13.c194
-rw-r--r--gcc/testsuite/gcc.dg/ipa/ipa-icf-14.c47
-rw-r--r--gcc/testsuite/gcc.dg/ipa/ipa-icf-15.c46
-rw-r--r--gcc/testsuite/gcc.dg/ipa/ipa-icf-16.c27
-rw-r--r--gcc/testsuite/gcc.dg/ipa/ipa-icf-17.c37
-rw-r--r--gcc/testsuite/gcc.dg/ipa/ipa-icf-18.c37
-rw-r--r--gcc/testsuite/gcc.dg/ipa/ipa-icf-19.c37
-rw-r--r--gcc/testsuite/gcc.dg/ipa/ipa-icf-2.c69
-rw-r--r--gcc/testsuite/gcc.dg/ipa/ipa-icf-20.c28
-rw-r--r--gcc/testsuite/gcc.dg/ipa/ipa-icf-21.c27
-rw-r--r--gcc/testsuite/gcc.dg/ipa/ipa-icf-22.c37
-rw-r--r--gcc/testsuite/gcc.dg/ipa/ipa-icf-23.c29
-rw-r--r--gcc/testsuite/gcc.dg/ipa/ipa-icf-24.c36
-rw-r--r--gcc/testsuite/gcc.dg/ipa/ipa-icf-25.c52
-rw-r--r--gcc/testsuite/gcc.dg/ipa/ipa-icf-26.c44
-rw-r--r--gcc/testsuite/gcc.dg/ipa/ipa-icf-27.c30
-rw-r--r--gcc/testsuite/gcc.dg/ipa/ipa-icf-28.c24
-rw-r--r--gcc/testsuite/gcc.dg/ipa/ipa-icf-29.c30
-rw-r--r--gcc/testsuite/gcc.dg/ipa/ipa-icf-3.c36
-rw-r--r--gcc/testsuite/gcc.dg/ipa/ipa-icf-30.c30
-rw-r--r--gcc/testsuite/gcc.dg/ipa/ipa-icf-4.c32
-rw-r--r--gcc/testsuite/gcc.dg/ipa/ipa-icf-5.c55
-rw-r--r--gcc/testsuite/gcc.dg/ipa/ipa-icf-6.c36
-rw-r--r--gcc/testsuite/gcc.dg/ipa/ipa-icf-7.c72
-rw-r--r--gcc/testsuite/gcc.dg/ipa/ipa-icf-8.c45
-rw-r--r--gcc/testsuite/gcc.dg/ipa/ipa-icf-9.c33
36 files changed, 1602 insertions, 0 deletions
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 21e3e06f031..9571e6b03eb 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,42 @@
+2014-10-16 Martin Liska <mliska@suse.cz>
+ Jan Hubicka <hubicka@ucw.cz>
+
+ * g++.dg/ipa/ipa-icf-1.C: New test.
+ * g++.dg/ipa/ipa-icf-2.C: New test.
+ * g++.dg/ipa/ipa-icf-3.C: New test.
+ * g++.dg/ipa/ipa-icf-4.C: New test.
+ * g++.dg/ipa/ipa-icf-5.C: New test.
+ * gcc.dg/ipa/ipa-icf-1.c: New test.
+ * gcc.dg/ipa/ipa-icf-10.c: New test.
+ * gcc.dg/ipa/ipa-icf-11.c: New test.
+ * gcc.dg/ipa/ipa-icf-12.c: New test.
+ * gcc.dg/ipa/ipa-icf-13.c: New test.
+ * gcc.dg/ipa/ipa-icf-14.c: New test.
+ * gcc.dg/ipa/ipa-icf-15.c: New test.
+ * gcc.dg/ipa/ipa-icf-16.c: New test.
+ * gcc.dg/ipa/ipa-icf-17.c: New test.
+ * gcc.dg/ipa/ipa-icf-18.c: New test.
+ * gcc.dg/ipa/ipa-icf-19.c: New test.
+ * gcc.dg/ipa/ipa-icf-2.c: New test.
+ * gcc.dg/ipa/ipa-icf-20.c: New test.
+ * gcc.dg/ipa/ipa-icf-21.c: New test.
+ * gcc.dg/ipa/ipa-icf-22.c: New test.
+ * gcc.dg/ipa/ipa-icf-23.c: New test.
+ * gcc.dg/ipa/ipa-icf-24.c: New test.
+ * gcc.dg/ipa/ipa-icf-25.c: New test.
+ * gcc.dg/ipa/ipa-icf-26.c: New test.
+ * gcc.dg/ipa/ipa-icf-27.c: New test.
+ * gcc.dg/ipa/ipa-icf-28.c: New test.
+ * gcc.dg/ipa/ipa-icf-29.c: New test.
+ * gcc.dg/ipa/ipa-icf-3.c: New test.
+ * gcc.dg/ipa/ipa-icf-30.c: New test.
+ * gcc.dg/ipa/ipa-icf-4.c: New test.
+ * gcc.dg/ipa/ipa-icf-5.c: New test.
+ * gcc.dg/ipa/ipa-icf-6.c: New test.
+ * gcc.dg/ipa/ipa-icf-7.c: New test.
+ * gcc.dg/ipa/ipa-icf-8.c: New test.
+ * gcc.dg/ipa/ipa-icf-9.c: New test.
+
2014-10-16 Oleg Endo <olegendo@gcc.gnu.org>
PR target/53513
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 00000000000..d27abf47a29
--- /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 00000000000..48badd740f3
--- /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 00000000000..042f789f669
--- /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 00000000000..9d178893341
--- /dev/null
+++ b/gcc/testsuite/g++.dg/ipa/ipa-icf-4.C
@@ -0,0 +1,48 @@
+/* { 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 "Equal symbols: 2" "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 00000000000..728df20a390
--- /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 00000000000..aeee356d6c9
--- /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 00000000000..b9bca608c8a
--- /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 00000000000..2eb90dac22b
--- /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 00000000000..d4b7c38d77f
--- /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 00000000000..e409ee496b1
--- /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 00000000000..cae02fbd4a6
--- /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 00000000000..04c2320759c
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/ipa/ipa-icf-15.c
@@ -0,0 +1,46 @@
+/* { 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 "Equal symbols: 0" "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 00000000000..fb0b116f736
--- /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 00000000000..7c9172da3fa
--- /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 00000000000..9dc39791e57
--- /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 00000000000..7a29cf3b877
--- /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 00000000000..385db0c1b21
--- /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 00000000000..9912a9a5c69
--- /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 00000000000..7358e43e384
--- /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 00000000000..95610260849
--- /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 00000000000..7e81ae21ae6
--- /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 00000000000..3cd476ffc5d
--- /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 00000000000..89f5a80f98f
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/ipa/ipa-icf-25.c
@@ -0,0 +1,52 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -fdump-ipa-icf" } */
+
+static int zip();
+static int zap();
+static int two();
+
+__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 00000000000..0c5a5a65e2f
--- /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 00000000000..fab2e41e910
--- /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 00000000000..538e0abb975
--- /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-29.c b/gcc/testsuite/gcc.dg/ipa/ipa-icf-29.c
new file mode 100644
index 00000000000..75839953534
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/ipa/ipa-icf-29.c
@@ -0,0 +1,30 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -fdump-ipa-icf -fno-inline" } */
+
+struct str
+{
+ unsigned a:1, b:1;
+};
+
+static struct str test;
+
+unsigned foo(struct str *s)
+{
+ return s->a;
+}
+
+unsigned bar(struct str *s)
+{
+ return s->b;
+}
+
+int main()
+{
+ test.a = 0;
+ test.b = 1;
+
+ return foo (&test) != bar (&test);
+}
+
+/* { 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-3.c b/gcc/testsuite/gcc.dg/ipa/ipa-icf-3.c
new file mode 100644
index 00000000000..e4e2eb628b9
--- /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-30.c b/gcc/testsuite/gcc.dg/ipa/ipa-icf-30.c
new file mode 100644
index 00000000000..75c284f27e0
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/ipa/ipa-icf-30.c
@@ -0,0 +1,30 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -fdump-ipa-icf -fno-inline" } */
+
+struct str
+{
+ unsigned a:1, b:1;
+};
+
+static struct str test;
+
+unsigned foo(struct str *s)
+{
+ return s->a;
+}
+
+unsigned bar(struct str *s)
+{
+ return s->a;
+}
+
+int main()
+{
+ test.a = 0;
+ test.b = 1;
+
+ return foo (&test) == bar (&test);
+}
+
+/* { 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 00000000000..9434fb05adf
--- /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 00000000000..45fddf589ac
--- /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 00000000000..6e6758e9bd3
--- /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 00000000000..ec7961dc177
--- /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 00000000000..d35df907005
--- /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 00000000000..9d04dd1633c
--- /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" } } */