From patchwork Tue Mar 15 02:27:28 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alan Modra X-Patchwork-Id: 597331 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 3qPJSm3GRsz9sD5 for ; Tue, 15 Mar 2016 13:28:23 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b=xKJusSbi; dkim-atps=neutral DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:date :from:to:cc:subject:message-id:references:mime-version :content-type:in-reply-to; q=dns; s=default; b=VANE9l4kEzvc0Qgqm D4tMabXPCpVIw7ClWYMEsQ6VcbaKPeV9i9LtlMsT9kqK7OnPbOUTjqvInMDp7c9t JzRWMcy5OfK+0KEKfdnYwmmxcg0dYVfkMvyDPDiqSoHsod9iQgRvkbDJNQTlk6gd Otb6anhglDdDZoYeJ680+pS07Y= 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:date :from:to:cc:subject:message-id:references:mime-version :content-type:in-reply-to; s=default; bh=wOTALAQO6W7lN4Fp2vhdtoy UGm8=; b=xKJusSbi71JG+Np6gDQjofWOhJmtUrjKs/MGmbxhmebZLrDsdao3yXQ B3DrmGWKUfflRXEArjM2kKbt5zSXB9m9bf8PEHYfW3/nA6nP8j8w2PsdIRkIVcAa KVSYdL8i4ro7i8oYKXjarSYaREDfJIQ+QxP3b6qvlSt5UDLJuFPs= Received: (qmail 100640 invoked by alias); 15 Mar 2016 02:27:47 -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 100548 invoked by uid 89); 15 Mar 2016 02:27:46 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.4 required=5.0 tests=AWL, BAYES_00, FREEMAIL_FROM, RCVD_IN_DNSWL_LOW, SPF_PASS autolearn=ham version=3.3.2 spammy=sk:gen_rtx, Pmode, pmode, sk:validat X-HELO: mail-pf0-f173.google.com Received: from mail-pf0-f173.google.com (HELO mail-pf0-f173.google.com) (209.85.192.173) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-GCM-SHA256 encrypted) ESMTPS; Tue, 15 Mar 2016 02:27:36 +0000 Received: by mail-pf0-f173.google.com with SMTP id u190so6572682pfb.3 for ; Mon, 14 Mar 2016 19:27:36 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=TlswXkV/ONshuIHT0jg7SdY3IkHErPuLZYxlgPOeCjQ=; b=BxGWKt9FQXq3evJd9gcRXtrxMTc57nupergQ8QnuAQjnj7rCSUUWG8QVa6joIBbv0a HH29yQaOYOilJF658UVf5j0jHjemiBiWLgVaFrC+8OkWIf4FTgwajBj1xPmY7MpcvYiq Nq0nY3+1w0krBcT9NqlXjW+83s2IwzDEJKY2vkmi84ga0GhBE8NFBMHD31F3uBPu5kQT vGNynPJIcUG8H7tL/gnfRUIdr5H8QnazdFIUw6f4Kd31gnESS80odKiySwdrbY/4zssg BWaRGF14WsoRqk6UvjiKmrLzlw+GhtuZGNpjiMIhRJX9kMgRNnm2Gf3hb5R8yYqDw/Z/ KHzg== X-Gm-Message-State: AD7BkJJ2cndxSpJWsUbDdfR1+I1DTn1g3qcgD9MDIq1XH3jAZy2fzHiCQtpJJOsPq1Bxhg== X-Received: by 10.66.55.70 with SMTP id q6mr38302355pap.126.1458008854376; Mon, 14 Mar 2016 19:27:34 -0700 (PDT) Received: from bubble.grove.modra.org (CPE-58-160-146-233.sa.bigpond.net.au. [58.160.146.233]) by smtp.gmail.com with ESMTPSA id q4sm942109pfi.94.2016.03.14.19.27.32 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 14 Mar 2016 19:27:33 -0700 (PDT) Received: by bubble.grove.modra.org (Postfix, from userid 1000) id D6E23EA0157; Tue, 15 Mar 2016 12:57:28 +1030 (ACDT) Date: Tue, 15 Mar 2016 12:57:28 +1030 From: Alan Modra To: Jeff Law Cc: Richard Biener , Jakub Jelinek , Andreas Schwab , Bernd Schmidt , GCC Patches Subject: Re: [PATCH] PR69195, Reload confused by invalid reg equivs Message-ID: <20160315022728.GA12055@bubble.grove.modra.org> References: <20160311221624.GB16812@bubble.grove.modra.org> <20160311231350.GC16812@bubble.grove.modra.org> <20160312075821.GK3017@tucnak.redhat.com> <56E3D2BF.90508@redhat.com> <20160312090725.GD16812@bubble.grove.modra.org> <20160312092940.GL3017@tucnak.redhat.com> <2EBC7A3F-3136-4284-9155-D5C0A7875320@gmail.com> <56E44CBD.6010806@redhat.com> <56E70A57.6020305@redhat.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <56E70A57.6020305@redhat.com> User-Agent: Mutt/1.5.23 (2014-03-12) X-IsSubscribed: yes On Mon, Mar 14, 2016 at 01:00:39PM -0600, Jeff Law wrote: > Right. Tolerant as in not crash. So can someone please approve my ira.c:indirect_jump_optimize patch? I'm not quite audacious enough to claim it is obvious. The original is at https://gcc.gnu.org/ml/gcc-patches/2016-03/msg00720.html, reposted here with some additional comments. Bootstrapped and regression tested powerpc64le-linux and x86_64-linux. (In the thread I mentioned we could use DF_REF_INSN_INFO in place of !DF_REF_IS_ARTIFICAL. I believe that is true, and it saves an access to another field of df_ref, but !DF_REF_IS_ARTIFICIAL before access to DF_REF_INSN or DF_REF_INSN_UID is somewhat more prevalent in the gcc sources.) PR rtl-optimization/69195 PR rtl-optimization/47992 * ira.c (indirect_jump_optimize): Ignore artificial defs. Add comments. diff --git a/gcc/ira.c b/gcc/ira.c index 5e7a2ed..a543d90 100644 --- a/gcc/ira.c +++ b/gcc/ira.c @@ -3842,7 +3842,8 @@ update_equiv_regs (void) free (pdx_subregs); } -/* A pass over indirect jumps, converting simple cases to direct jumps. */ +/* A pass over indirect jumps, converting simple cases to direct jumps. + Combine does this optimization too, but only within a basic block. */ static void indirect_jump_optimize (void) { @@ -3862,14 +3863,23 @@ indirect_jump_optimize (void) int regno = REGNO (SET_SRC (x)); if (DF_REG_DEF_COUNT (regno) == 1) { - rtx_insn *def_insn = DF_REF_INSN (DF_REG_DEF_CHAIN (regno)); - rtx note = find_reg_note (def_insn, REG_LABEL_OPERAND, NULL_RTX); - - if (note) + df_ref def = DF_REG_DEF_CHAIN (regno); + if (!DF_REF_IS_ARTIFICIAL (def)) { - rtx lab = gen_rtx_LABEL_REF (Pmode, XEXP (note, 0)); - if (validate_replace_rtx (SET_SRC (x), lab, insn)) - rebuild_p = true; + rtx_insn *def_insn = DF_REF_INSN (def); + rtx note = find_reg_note (def_insn, REG_LABEL_OPERAND, NULL_RTX); + + if (note) + { + /* Substitute a LABEL_REF to the label given by the + note rather than using SET_SRC of DEF_INSN. + DEF_INSN might be loading the label constant from + a constant pool, which isn't what we want in a + direct branch. */ + rtx lab = gen_rtx_LABEL_REF (Pmode, XEXP (note, 0)); + if (validate_replace_rtx (SET_SRC (x), lab, insn)) + rebuild_p = true; + } } } }