From patchwork Tue Mar 4 07:27:09 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Sandiford X-Patchwork-Id: 326163 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 6416D2C0097 for ; Tue, 4 Mar 2014 18:27:22 +1100 (EST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :to:cc:subject:references:date:in-reply-to:message-id :mime-version:content-type; q=dns; s=default; b=hIJ4SFwjFs7o09Gh b9RtoU+bA+jteS5v29hTC7BaPk1OHR1LDgXFJ0MQcXO/pviY+WZjpSVqSMAh0hIs zlENh2Hdz3+aWcs+RT/VhMwQLP6pspm/gYTBC5AREFOQ/Kjay0ciP4sOg92c9FE9 uSg9NQTlwSBnMQwxzfbB0V4/NsQ= 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:from :to:cc:subject:references:date:in-reply-to:message-id :mime-version:content-type; s=default; bh=ThlUKHX0bC1l05cyZjulrR 8+OgU=; b=PE4AG4djMho/pWOsQSXPw7+SY/1kxZOAQy7KDfGlSW1NqRdANZCuLE r1vEXfFcUOK4pZ3wUXu/QffKkdk7ZjixMr9djp/Z6KvJuagYOtlZH72uAdi16SO4 IIRmKRqhWy11aK+gzuDoslmB71yua5FbsbpOde+Wn0M8l4Deemj0s= Received: (qmail 16538 invoked by alias); 4 Mar 2014 07:27:15 -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 16526 invoked by uid 89); 4 Mar 2014 07:27:15 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.8 required=5.0 tests=AWL, BAYES_00, FREEMAIL_FROM, RCVD_IN_DNSWL_LOW, SPF_PASS autolearn=ham version=3.3.2 X-HELO: mail-we0-f181.google.com Received: from mail-we0-f181.google.com (HELO mail-we0-f181.google.com) (74.125.82.181) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-SHA encrypted) ESMTPS; Tue, 04 Mar 2014 07:27:13 +0000 Received: by mail-we0-f181.google.com with SMTP id q58so4441738wes.12 for ; Mon, 03 Mar 2014 23:27:10 -0800 (PST) X-Received: by 10.194.8.196 with SMTP id t4mr16450780wja.49.1393918030419; Mon, 03 Mar 2014 23:27:10 -0800 (PST) Received: from localhost ([2.28.235.12]) by mx.google.com with ESMTPSA id dd3sm47581279wjb.9.2014.03.03.23.27.09 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 03 Mar 2014 23:27:10 -0800 (PST) From: Richard Sandiford To: Eric Botcazou Mail-Followup-To: Eric Botcazou , gcc-patches@gcc.gnu.org, Yury Gribov , rdsandiford@googlemail.com Cc: gcc-patches@gcc.gnu.org, Yury Gribov Subject: Re: [RFC] Do not consider volatile asms as optimization barriers #1 References: <2417129.VoWsWu5CJz@polaris> <87bnxnc56j.fsf@talisman.default> Date: Tue, 04 Mar 2014 07:27:09 +0000 In-Reply-To: <87bnxnc56j.fsf@talisman.default> (Richard Sandiford's message of "Mon, 03 Mar 2014 22:01:40 +0000") Message-ID: <877g8actki.fsf@talisman.default> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux) MIME-Version: 1.0 Richard Sandiford writes: > I'll run a full test overnight, but does this look like it might be > a way out, at least for 4.9? FWIW, it passed testing on x86_64-linux-gnu ({,-m32}, all,ada). Here it is again with an updated cselib.c comment. OK to install? Thanks, Richard gcc/ * builtins.c (expand_builtin_setjmp_receiver): Use and clobber hard_frame_pointer_rtx. * cse.c (cse_insn): Remove volatile check. * cselib.c (cselib_process_insn): Likewise. * dse.c (scan_insn): Likewise. Index: gcc/builtins.c =================================================================== --- gcc/builtins.c 2014-03-03 21:47:59.749026019 +0000 +++ gcc/builtins.c 2014-03-03 21:48:00.550030853 +0000 @@ -910,18 +910,27 @@ expand_builtin_setjmp_receiver (rtx rece #ifdef HAVE_nonlocal_goto if (! HAVE_nonlocal_goto) #endif - /* First adjust our frame pointer to its actual value. It was - previously set to the start of the virtual area corresponding to - the stacked variables when we branched here and now needs to be - adjusted to the actual hardware fp value. - - Assignments to virtual registers are converted by - instantiate_virtual_regs into the corresponding assignment - to the underlying register (fp in this case) that makes - the original assignment true. - So the following insn will actually be decrementing fp by - STARTING_FRAME_OFFSET. */ - emit_move_insn (virtual_stack_vars_rtx, hard_frame_pointer_rtx); + { + /* First adjust our frame pointer to its actual value. It was + previously set to the start of the virtual area corresponding to + the stacked variables when we branched here and now needs to be + adjusted to the actual hardware fp value. + + Assignments to virtual registers are converted by + instantiate_virtual_regs into the corresponding assignment + to the underlying register (fp in this case) that makes + the original assignment true. + So the following insn will actually be decrementing fp by + STARTING_FRAME_OFFSET. */ + emit_move_insn (virtual_stack_vars_rtx, hard_frame_pointer_rtx); + + /* Restoring the frame pointer also modifies the hard frame pointer. + Mark it used (so that the previous assignment remains live once + the frame pointer is eliminated) and clobbered (to represent the + implicit update from the assignment). */ + emit_use (hard_frame_pointer_rtx); + emit_clobber (hard_frame_pointer_rtx); + } #if !HARD_FRAME_POINTER_IS_ARG_POINTER if (fixed_regs[ARG_POINTER_REGNUM]) @@ -965,8 +974,7 @@ expand_builtin_setjmp_receiver (rtx rece /* We must not allow the code we just generated to be reordered by scheduling. Specifically, the update of the frame pointer must - happen immediately, not later. Similarly, we must block - (frame-related) register values to be used across this code. */ + happen immediately, not later. */ emit_insn (gen_blockage ()); } Index: gcc/cse.c =================================================================== --- gcc/cse.c 2014-03-03 21:47:59.869026741 +0000 +++ gcc/cse.c 2014-03-03 21:48:00.625031305 +0000 @@ -5664,11 +5664,6 @@ cse_insn (rtx insn) invalidate (XEXP (dest, 0), GET_MODE (dest)); } - /* A volatile ASM or an UNSPEC_VOLATILE invalidates everything. */ - if (NONJUMP_INSN_P (insn) - && volatile_insn_p (PATTERN (insn))) - flush_hash_table (); - /* Don't cse over a call to setjmp; on some machines (eg VAX) the regs restored by the longjmp come from a later time than the setjmp. */ Index: gcc/cselib.c =================================================================== --- gcc/cselib.c 2014-03-03 21:47:59.870026748 +0000 +++ gcc/cselib.c 2014-03-03 22:09:24.211994918 +0000 @@ -2626,12 +2626,10 @@ cselib_process_insn (rtx insn) cselib_current_insn = insn; - /* Forget everything at a CODE_LABEL, a volatile insn, or a setjmp. */ + /* Forget everything at a CODE_LABEL or a setjmp. */ if ((LABEL_P (insn) || (CALL_P (insn) - && find_reg_note (insn, REG_SETJMP, NULL)) - || (NONJUMP_INSN_P (insn) - && volatile_insn_p (PATTERN (insn)))) + && find_reg_note (insn, REG_SETJMP, NULL))) && !cselib_preserve_constants) { cselib_reset_table (next_uid); Index: gcc/dse.c =================================================================== --- gcc/dse.c 2014-03-03 21:47:59.871026754 +0000 +++ gcc/dse.c 2014-03-03 21:48:00.627031317 +0000 @@ -2470,16 +2470,6 @@ scan_insn (bb_info_t bb_info, rtx insn) return; } - /* Cselib clears the table for this case, so we have to essentially - do the same. */ - if (NONJUMP_INSN_P (insn) - && volatile_insn_p (PATTERN (insn))) - { - add_wild_read (bb_info); - insn_info->cannot_delete = true; - return; - } - /* Look at all of the uses in the insn. */ note_uses (&PATTERN (insn), check_mem_read_use, bb_info);