From patchwork Wed Sep 3 20:19:12 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Makarov X-Patchwork-Id: 385633 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 E3A2714018E for ; Thu, 4 Sep 2014 06:19:35 +1000 (EST) 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:cc:subject:references :in-reply-to:content-type; q=dns; s=default; b=EhVQORXQLM/hK/QuR OJbrsclTraadBFuM0W/W/XOASifP50J87IJjf8bbkZJoSpBivCaJ44PUcZ3sa1zz ko3XwxJogw5RoDQYZg0B+N56UjiJmukMm2qu8MNxHcvPdA17m6vI6yKxoRGpZPH8 aKXMjeKSP2Zipt6D1HcL1bapFA= 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:cc:subject:references :in-reply-to:content-type; s=default; bh=KY0YVGz8wGI/CFTvOGLP82/ qIHg=; b=CiAh7Wejufs56ok1Bww5gCO10MsNy1OH2vR5CUMfvit8RWQRGQmE/kR 9NV2yrUu3uvDN0wLWSYEKE3Xb5Rnr4fWL8pYBULIr9o5U53wfENuCxRBpqaaeMr7 jGfu1MKgy2RHcFTiv2SYxMqYpbt/hwFVYyAirgOv/ugJzQPMxBNk= Received: (qmail 17463 invoked by alias); 3 Sep 2014 20:19:26 -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 17450 invoked by uid 89); 3 Sep 2014 20:19:26 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-4.7 required=5.0 tests=AWL, BAYES_00, RP_MATCHES_RCVD, SPF_HELO_PASS, SPF_PASS autolearn=ham version=3.3.2 X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-GCM-SHA384 encrypted) ESMTPS; Wed, 03 Sep 2014 20:19:25 +0000 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id s83KJN4J015129 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Wed, 3 Sep 2014 16:19:23 -0400 Received: from VMBP.local (vpn-48-17.rdu2.redhat.com [10.10.48.17]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id s83KJM6i007526; Wed, 3 Sep 2014 16:19:22 -0400 Message-ID: <540777C0.9050106@redhat.com> Date: Wed, 03 Sep 2014 16:19:12 -0400 From: Vladimir Makarov User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.9; rv:31.0) Gecko/20100101 Thunderbird/31.0 MIME-Version: 1.0 To: Ilya Enkovich CC: gcc@gnu.org, gcc-patches , Evgeny Stupachenko , Richard Biener , Uros Bizjak , Jeff Law Subject: Re: Enable EBX for x86 in 32bits PIC code References: <20140707114750.GB31640@tucnak.redhat.com> <20140822121151.GA60032@msticlxl57.ims.intel.com> <53FB5184.3030500@redhat.com> <53FCA6F5.7020405@redhat.com> <20140826213712.GA39451@msticlxl57.ims.intel.com> <53FE3D46.8050904@redhat.com> In-Reply-To: X-IsSubscribed: yes On 2014-08-29 2:47 AM, Ilya Enkovich wrote: > Seems your patch doesn't cover all cases. Attached is a modified > patch (with your changes included) and a test where double constant is > wrongly rematerialized. I also see in ira dump that there is still a > copy of PIC reg created: > > Initialization of original PIC reg: > (insn 23 22 24 2 (set (reg:SI 127) > (reg:SI 3 bx)) test.cc:42 90 {*movsi_internal} > (expr_list:REG_DEAD (reg:SI 3 bx) > (nil))) > ... > Copy is created: > (insn 135 37 25 3 (set (reg:SI 138 [127]) > (reg:SI 127)) 90 {*movsi_internal} > (expr_list:REG_DEAD (reg:SI 127) > (nil))) > ... > Copy is used: > (insn 119 25 122 3 (set (reg:DF 134) > (mem/u/c:DF (plus:SI (reg:SI 138 [127]) > (const:SI (unspec:SI [ > (symbol_ref/u:SI ("*.LC0") [flags 0x2]) > ] UNSPEC_GOTOFF))) [5 S8 A64])) 128 {*movdf_internal} > (expr_list:REG_EQUIV (const_double:DF > 2.9999999999999997371893933895137251965934410691261292e-4 > [0x0.9d495182a99308p-11]) > (nil))) > The copy is created by a newer IRA optimization for function prologues. The patch in the attachment should solve the problem. I also added the code to prevent spilling the pic pseudo in LRA which could happen before theoretically. > After reload we have new usage of r127 which is allocated to ecx which > actually does not have any definition in this function at all. > > (insn 151 42 44 4 (set (reg:SI 0 ax [147]) > (plus:SI (reg:SI 2 cx [127]) > (const:SI (unspec:SI [ > (symbol_ref/u:SI ("*.LC0") [flags 0x2]) > ] UNSPEC_GOTOFF)))) test.cc:44 213 {*leasi} > (expr_list:REG_EQUAL (symbol_ref/u:SI ("*.LC0") [flags 0x2]) > (nil))) > (insn 44 151 45 4 (set (reg:DF 21 xmm0 [orig:129 D.2450 ] [129]) > (mult:DF (reg:DF 21 xmm0 [orig:128 D.2450 ] [128]) > (mem/u/c:DF (reg:SI 0 ax [147]) [5 S8 A64]))) test.cc:44 > 790 {*fop_df_comm_sse} > (expr_list:REG_EQUAL (mult:DF (reg:DF 21 xmm0 [orig:128 D.2450 ] [128]) > (const_double:DF > 2.9999999999999997371893933895137251965934410691261292e-4 > [0x0.9d495182a99308p-11])) > (nil))) > > Compilation string: g++ -m32 -O2 -mfpmath=sse -fPIE -S test.cc Index: ira.c =================================================================== --- ira.c (revision 214576) +++ ira.c (working copy) @@ -4887,7 +4887,7 @@ split_live_ranges_for_shrink_wrap (void) FOR_BB_INSNS (first, insn) { rtx dest = interesting_dest_for_shprep (insn, call_dom); - if (!dest) + if (!dest || dest == pic_offset_table_rtx) continue; rtx newreg = NULL_RTX; Index: lra-assigns.c =================================================================== --- lra-assigns.c (revision 214576) +++ lra-assigns.c (working copy) @@ -879,11 +879,13 @@ spill_for (int regno, bitmap spilled_pse } /* Spill pseudos. */ EXECUTE_IF_SET_IN_BITMAP (&spill_pseudos_bitmap, 0, spill_regno, bi) - if ((int) spill_regno >= lra_constraint_new_regno_start - && ! bitmap_bit_p (&lra_inheritance_pseudos, spill_regno) - && ! bitmap_bit_p (&lra_split_regs, spill_regno) - && ! bitmap_bit_p (&lra_subreg_reload_pseudos, spill_regno) - && ! bitmap_bit_p (&lra_optional_reload_pseudos, spill_regno)) + if ((pic_offset_table_rtx != NULL + && spill_regno == REGNO (pic_offset_table_rtx)) + || ((int) spill_regno >= lra_constraint_new_regno_start + && ! bitmap_bit_p (&lra_inheritance_pseudos, spill_regno) + && ! bitmap_bit_p (&lra_split_regs, spill_regno) + && ! bitmap_bit_p (&lra_subreg_reload_pseudos, spill_regno) + && ! bitmap_bit_p (&lra_optional_reload_pseudos, spill_regno))) goto fail; insn_pseudos_num = 0; if (lra_dump_file != NULL) @@ -1053,7 +1055,9 @@ setup_live_pseudos_and_spill_after_risky return; } for (n = 0, i = FIRST_PSEUDO_REGISTER; i < max_regno; i++) - if (reg_renumber[i] >= 0 && lra_reg_info[i].nrefs > 0) + if ((pic_offset_table_rtx == NULL_RTX + || i != (int) REGNO (pic_offset_table_rtx)) + && reg_renumber[i] >= 0 && lra_reg_info[i].nrefs > 0) sorted_pseudos[n++] = i; qsort (sorted_pseudos, n, sizeof (int), pseudo_compare_func); for (i = n - 1; i >= 0; i--) @@ -1360,6 +1364,8 @@ assign_by_spills (void) } EXECUTE_IF_SET_IN_SPARSESET (live_range_hard_reg_pseudos, conflict_regno) { + gcc_assert (pic_offset_table_rtx == NULL + || conflict_regno != REGNO (pic_offset_table_rtx)); if ((int) conflict_regno >= lra_constraint_new_regno_start) sorted_pseudos[nfails++] = conflict_regno; if (lra_dump_file != NULL)