public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] IPA ICF: handle IMAGPART_EXPR and REALPART_EXPR
@ 2015-01-13 21:02 Martin Liška
  2015-01-13 21:18 ` Jeff Law
  0 siblings, 1 reply; 2+ messages in thread
From: Martin Liška @ 2015-01-13 21:02 UTC (permalink / raw)
  To: gcc-pa >> GCC Patches

[-- Attachment #1: Type: text/plain, Size: 273 bytes --]

Hello.

As pointed out in the following PR64307, IPA ICF is missing support for 
aforementioned TREE types. Apart from that, the patch also fixes 
BIT_FIELD_REF, which was broken.

Tested on x86_64-linux-pc and no regression has been seen.

Ready for trunk?
Thanks,
Martin

[-- Attachment #2: 0001-IPA-ICF-handle-IMAGPART_EXPR-and-REALPART_EXPR.patch --]
[-- Type: text/x-patch, Size: 2521 bytes --]

From 036a27ec12ad556160cb92a86fd99ed02b66ed1a Mon Sep 17 00:00:00 2001
From: mliska <mliska@suse.cz>
Date: Tue, 13 Jan 2015 18:52:22 +0100
Subject: [PATCH] IPA ICF: handle IMAGPART_EXPR and REALPART_EXPR.

gcc/testsuite/ChangeLog:

2015-01-13  Martin Liska  <mliska@suse.cz>

	* gcc.dg/ipa/pr64307.c: New test.

gcc/ChangeLog:

2015-01-13  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.
---
 gcc/ipa-icf-gimple.c               | 14 +++++++++++++-
 gcc/testsuite/gcc.dg/ipa/pr64307.c | 32 ++++++++++++++++++++++++++++++++
 2 files changed, 45 insertions(+), 1 deletion(-)
 create mode 100644 gcc/testsuite/gcc.dg/ipa/pr64307.c

diff --git a/gcc/ipa-icf-gimple.c b/gcc/ipa-icf-gimple.c
index ed3cdf5..05c2a23 100644
--- a/gcc/ipa-icf-gimple.c
+++ b/gcc/ipa-icf-gimple.c
@@ -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:
diff --git a/gcc/testsuite/gcc.dg/ipa/pr64307.c b/gcc/testsuite/gcc.dg/ipa/pr64307.c
new file mode 100644
index 0000000..e8c1b02
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/ipa/pr64307.c
@@ -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(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" } } */
-- 
2.1.2


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] IPA ICF: handle IMAGPART_EXPR and REALPART_EXPR
  2015-01-13 21:02 [PATCH] IPA ICF: handle IMAGPART_EXPR and REALPART_EXPR Martin Liška
@ 2015-01-13 21:18 ` Jeff Law
  0 siblings, 0 replies; 2+ messages in thread
From: Jeff Law @ 2015-01-13 21:18 UTC (permalink / raw)
  To: Martin Liška, gcc-pa >> GCC Patches

On 01/13/15 13:47, Martin Liška wrote:
> Hello.
>
> As pointed out in the following PR64307, IPA ICF is missing support for
> aforementioned TREE types. Apart from that, the patch also fixes
> BIT_FIELD_REF, which was broken.
>
> Tested on x86_64-linux-pc and no regression has been seen.
>
> Ready for trunk?
> Thanks,
> Martin
>
> 0001-IPA-ICF-handle-IMAGPART_EXPR-and-REALPART_EXPR.patch
>
>
>  From 036a27ec12ad556160cb92a86fd99ed02b66ed1a Mon Sep 17 00:00:00 2001
> From: mliska<mliska@suse.cz>
> Date: Tue, 13 Jan 2015 18:52:22 +0100
> Subject: [PATCH] IPA ICF: handle IMAGPART_EXPR and REALPART_EXPR.
>
> gcc/testsuite/ChangeLog:
>
> 2015-01-13  Martin Liska<mliska@suse.cz>
>
> 	* gcc.dg/ipa/pr64307.c: New test.
>
> gcc/ChangeLog:
>
> 2015-01-13  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.
OK.

Jeff

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2015-01-13 21:11 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-01-13 21:02 [PATCH] IPA ICF: handle IMAGPART_EXPR and REALPART_EXPR Martin Liška
2015-01-13 21:18 ` Jeff Law

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).