From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 49292 invoked by alias); 23 Feb 2017 07:46:22 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Received: (qmail 49273 invoked by uid 89); 23 Feb 2017 07:46:21 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.9 required=5.0 tests=BAYES_00,RP_MATCHES_RCVD,SPF_HELO_PASS autolearn=ham version=3.3.2 spammy=boom, H*f:sk:a60879d, IRA, H*MI:sk:4D665FF 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 ESMTP; Thu, 23 Feb 2017 07:46:20 +0000 Received: from smtp.corp.redhat.com (int-mx16.intmail.prod.int.phx2.redhat.com [10.5.11.28]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 4645C7FB74; Thu, 23 Feb 2017 07:46:20 +0000 (UTC) Received: from localhost.localdomain (unknown [10.10.122.189]) by smtp.corp.redhat.com (Postfix) with ESMTP id A5311B5062; Thu, 23 Feb 2017 07:46:19 +0000 (UTC) Subject: Re: PR79286, ira combine_and_move_insns in loops To: =?UTF-8?Q?Dominique_d'Humi=c3=a8res?= References: <23ABDF83-F0BD-4382-BEDA-78306BBA29EA@lps.ens.fr> <20170221224808.GA14945@bubble.grove.modra.org> <57095C63-7993-4BD8-9719-7AB967191932@lps.ens.fr> <4D665FFA-F1F2-45F3-A14A-14638350518A@lps.ens.fr> Cc: Alan Modra , GCC-Patches-ML From: Jeff Law Message-ID: <766c6bfa-90a0-ea89-2131-11fd4a40c32c@redhat.com> Date: Thu, 23 Feb 2017 08:55:00 -0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.7.0 MIME-Version: 1.0 In-Reply-To: <4D665FFA-F1F2-45F3-A14A-14638350518A@lps.ens.fr> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit X-IsSubscribed: yes X-SW-Source: 2017-02/txt/msg01431.txt.bz2 On 02/22/2017 09:32 AM, Dominique d'Humières wrote: >> Let me stand up an i686 linux instance and see if I can twiddle things without compromising the test. > > Also darwin is a -fpic platform. Which is the key here :-) The test works fine without PIC, but once PIC is introduced, it blows up. It's pretty easy to see in the assembly code and the dumps. Prior to IRA we have: bb3 (loop header): [ ... ] (insn 8 7 9 3 (set (mem:SI (pre_dec:SI (reg/f:SI 7 sp)) [1 S4 A32]) (reg/v:SI 89 [ e ])) "j.c":9 56 {*pushsi2} (expr_list:REG_ARGS_SIZE (const_int 8 [0x8]) (nil))) [ ... ] bb5 (conditional within the loop): (insn 28 26 30 5 (set (reg/v:SI 89 [ e ]) (mem/u:SI (plus:SI (reg:SI 87) (const:SI (plus:SI (unspec:SI [ (symbol_ref:SI ("d") [flags 0x2] ) ] UNSPEC_GOTOFF) (const_int 331350016 [0x13c00000])))) [1 d+331350016 S4 A32])) "j.c":11 75 {*movsi_internal} (expr_list:REG_DEAD (reg:SI 87) (nil))) After IRA we have: bb3 (loop header) (insn 8 7 9 3 (set (mem:SI (pre_dec:SI (reg/f:SI 7 sp)) [1 S4 A32]) (mem/u:SI (plus:SI (reg:SI 87) (const:SI (plus:SI (unspec:SI [ (symbol_ref:SI ("d") [flags 0x2] ) ] UNSPEC_GOTOFF) (const_int 331350016 [0x13c00000])))) [1 d+331350016 S4 A32])) "j.c":9 56 {*pushsi2} (expr_list:REG_ARGS_SIZE (const_int 8 [0x8]) (nil))) And of course that goes boom. Note that we don't have a REG_EQUAL prior to IRA. That allows us to zero in on this code within IRA which adds the note to insn 28: 3485 /* cse sometimes generates function invariants, but doesn't put a 3486 REG_EQUAL note on the insn. Since this note would be redundant, 3487 there's no point creating it earlier than here. */ 3488 if (! note && ! rtx_varies_p (src, 0)) 3489 note = set_unique_reg_note (insn, REG_EQUAL, copy_rtx (src)); may_trap_p returns false for the note: expr_list:REG_EQUAL (mem/u:SI (plus:SI (reg:SI 87) (const:SI (plus:SI (unspec:SI [ (symbol_ref:SI ("d") [flags 0x2] ) ] UNSPEC_GOTOFF) (const_int 331350016 [0x13c00000])))) [1 d+331350016 S4 A32]) And thus we keep the equivalence. Ultimately may_trap_p considers a PIC memory reference as non-trapping. I really wonder if we should just drop the may_trap_p test and always do the domination check. jeff