From patchwork Tue Jan 13 20:47:09 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Martin_Li=C5=A1ka?= X-Patchwork-Id: 428688 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 927AC14016A for ; Wed, 14 Jan 2015 07:47:23 +1100 (AEDT) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :message-id:date:from:mime-version:to:subject:content-type; q= dns; s=default; b=MT/SgBsGmMkMXvGwDZzsakbTKrmNIYOyK/O7g1R0Ho5g1p 2hcX0+Y9s66iiILyPNDT0EhzQzu6+qaANNve0uyZauk/Q5OuL+A8CMslkRGTvCBe TmdQ0FeHf4VoXeerXcEQaPG7fxMDhml1UO+yRoxV6th6m8stFqKp/4Odu1h4c= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :message-id:date:from:mime-version:to:subject:content-type; s= default; bh=CRy6rLPVF7T4q1t034rLXfNlPJ0=; b=xLTk4wiFrjYuXW4KchlD IIC5xtsbdkv+hcRS46XRAFu34Tg94BYXhsd6GKxFYXGdH4e68jSBiI7A8Bw3PWGF w2tuUKLI+4yKmu1dlqR4QR8YJoRGL5rJztIdAatNDkeeufJfR1SSW+uedaKtz8zL ElLD8cdZRHZ/qTQpIv+Nk38= Received: (qmail 9325 invoked by alias); 13 Jan 2015 20:47:16 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 9308 invoked by uid 89); 13 Jan 2015 20:47:15 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.2 required=5.0 tests=AWL, BAYES_00 autolearn=ham version=3.3.2 X-HELO: mx2.suse.de Received: from cantor2.suse.de (HELO mx2.suse.de) (195.135.220.15) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (CAMELLIA256-SHA encrypted) ESMTPS; Tue, 13 Jan 2015 20:47:14 +0000 Received: from relay1.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id B790CABFC for ; Tue, 13 Jan 2015 20:47:10 +0000 (UTC) Message-ID: <54B5844D.8060602@suse.cz> Date: Tue, 13 Jan 2015 21:47:09 +0100 From: =?UTF-8?B?TWFydGluIExpxaFrYQ==?= User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.3.0 MIME-Version: 1.0 To: "gcc-pa >> GCC Patches" Subject: [PATCH] IPA ICF: handle IMAGPART_EXPR and REALPART_EXPR X-IsSubscribed: yes 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 From 036a27ec12ad556160cb92a86fd99ed02b66ed1a Mon Sep 17 00:00:00 2001 From: mliska 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 * gcc.dg/ipa/pr64307.c: New test. gcc/ChangeLog: 2015-01-13 Martin Liska * 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 + +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