diff mbox

[5/5] New tests introduction

Message ID 53B15497.2070806@suse.cz
State New
Headers show

Commit Message

Martin Liška June 30, 2014, 12:14 p.m. UTC
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

Comments

Andreas Schwab Oct. 19, 2014, 7:50 a.m. UTC | #1
Martin Liška <mliska@suse.cz> writes:

> 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" } } */

FAIL: gcc.dg/ipa/ipa-icf-21.c (test for excess errors)
Excess errors:
/usr/local/gcc/gcc-20141019/gcc/testsuite/gcc.dg/ipa/ipa-icf-21.c:4:23: fatal e\
rror: xmmintrin.h: No such file or directory
compilation terminated.

Andreas.
Martin Liška Oct. 23, 2014, 11:37 a.m. UTC | #2
On 10/19/2014 09:50 AM, Andreas Schwab wrote:
> Martin Liška <mliska@suse.cz> writes:
>
>> 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" } } */
>
> FAIL: gcc.dg/ipa/ipa-icf-21.c (test for excess errors)
> Excess errors:
> /usr/local/gcc/gcc-20141019/gcc/testsuite/gcc.dg/ipa/ipa-icf-21.c:4:23: fatal e\
> rror: xmmintrin.h: No such file or directory
> compilation terminated.
>
> Andreas.
>

Hello Andreas.

Starting from r216589 this problem should be fixed.

Thanks,
Martin
diff mbox

Patch

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