IPA ICF: handle IMAGPART_EXPR and REALPART_EXPR.
authorMartin Liska <mliska@suse.cz>
Wed, 14 Jan 2015 10:35:13 +0000 (11:35 +0100)
committerMartin Liska <marxin@gcc.gnu.org>
Wed, 14 Jan 2015 10:35:13 +0000 (10:35 +0000)
* gcc.dg/ipa/pr64307.c: New test.
* ipa-icf-gimple.c (func_checker::compare_operand): Add support for
IMAGPART_EXPR and REALPART_EXPR and fix BIT_FIELD_REF comparison.

From-SVN: r219586

gcc/ChangeLog
gcc/ipa-icf-gimple.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/ipa/pr64307.c [new file with mode: 0644]

index 611f0a7bd495bdf16dfd2220b43955252e269006..3d4c8ab640edb64223c80c3d5c05803cace07b5b 100644 (file)
@@ -1,3 +1,8 @@
+2015-01-14  Martin Liska  <mliska@suse.cz>
+
+       * ipa-icf-gimple.c (func_checker::compare_operand): Add support for
+       IMAGPART_EXPR and REALPART_EXPR and fix BIT_FIELD_REF comparison.
+
 2015-01-14  Kyrylo Tkachov  <kyrylo.tkachov@arm.com>
 
        PR target/64460
index ed3cdf56ccb5e4ec46f1f96e25114bab810bcfc0..05c2a23bd6f1f489dc8ef62d8c285d2a0e0ab8c2 100644 (file)
@@ -448,6 +448,8 @@ func_checker::compare_operand (tree t1, tree t2)
 
        return return_with_debug (ret);
       }
+    case IMAGPART_EXPR:
+    case REALPART_EXPR:
     case ADDR_EXPR:
       {
        x1 = TREE_OPERAND (t1, 0);
@@ -458,7 +460,17 @@ func_checker::compare_operand (tree t1, tree t2)
       }
     case BIT_FIELD_REF:
       {
-       ret = compare_decl (t1, t2);
+       x1 = TREE_OPERAND (t1, 0);
+       x2 = TREE_OPERAND (t2, 0);
+       y1 = TREE_OPERAND (t1, 1);
+       y2 = TREE_OPERAND (t2, 1);
+       z1 = TREE_OPERAND (t1, 2);
+       z2 = TREE_OPERAND (t2, 2);
+
+       ret = compare_operand (x1, x2)
+             && compare_cst_or_decl (y1, y2)
+             && compare_cst_or_decl (z1, z2);
+
        return return_with_debug (ret);
       }
     case SSA_NAME:
index 4f3ed20941a528f62353f4e17e4250b7639db214..efb7c378b9507f0e3ebc1d8a52aa02ac6116c8ed 100644 (file)
@@ -1,3 +1,7 @@
+2015-01-14  Martin Liska  <mliska@suse.cz>
+
+       * gcc.dg/ipa/pr64307.c: New test.
+
 2015-01-14  Tejas Belagod  <tejas.belagod@arm.com>
 
        * gcc.target/aarch64/vect-movi.c: Check for vectorization for
diff --git a/gcc/testsuite/gcc.dg/ipa/pr64307.c b/gcc/testsuite/gcc.dg/ipa/pr64307.c
new file mode 100644 (file)
index 0000000..66a5df4
--- /dev/null
@@ -0,0 +1,32 @@
+/* { dg-do compile } */
+/* { dg-options "-O0 -fipa-icf -fdump-ipa-icf"  } */
+
+#include <complex.h>
+
+typedef _Complex float COMPLEX_FLOAT;
+
+__attribute__ ((noinline))
+static float real_part(COMPLEX_FLOAT a)
+{
+  return *(float*)(&a);
+}
+
+__attribute__ ((noinline))
+static float real_part_2(COMPLEX_FLOAT a)
+{
+  return ((float*)(&a))[0];
+}
+
+int main()
+{
+  COMPLEX_FLOAT f = 1.0f + _Complex_I;
+
+  float r1 = real_part(f);
+  float r2 = real_part_2(f);
+
+  return r1 - r2;
+}
+
+/* { dg-final { scan-ipa-dump "Semantic equality hit:real_part_2->real_part" "icf"  } } */
+/* { dg-final { scan-ipa-dump "Equal symbols: 1" "icf"  } } */
+/* { dg-final { cleanup-ipa-dump "icf" } } */