From patchwork Fri Feb 19 09:45:37 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Segher Boessenkool X-Patchwork-Id: 585099 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 B54F614030F for ; Fri, 19 Feb 2016 20:45:56 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b=Pdimigq/; 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:from :to:cc:subject:date:message-id; q=dns; s=default; b=U0rEkqFqRHkY iBGJn2Pqi/ICaEm6EYMVj68ES9SfeU/Jshfr+fNydtOCKajyTRR6Db8FwscVOGG8 KFusl1aLL/zYHim0TTqhOhP5Cp9iGaZ0W6Mo8iAAmzQ18zMNfVGt6POkg1tEAaLJ 62rVvMYlfdNAQMP8c1sFkUs30G67hxM= 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:date:message-id; s=default; bh=QyKFuZVbd4X23b9KP5 Wgc7pzu4Y=; b=Pdimigq/X4cRtDnTQs5vfpjhR7y7TMzW+m1hcZ3xuRZaMkPEG1 335UVg0zwG05RAw5wOJcew/kKeSiXqlVVgzTzkw+4U3BPq+6MlHxbBvBaHOp/Wuw N1nePl9eNgVYsj1i4PNRStf77nnpfGRMtxbbfu7n2UNBVuA7vGSAjhQxk= Received: (qmail 67040 invoked by alias); 19 Feb 2016 09:45:50 -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 67023 invoked by uid 89); 19 Feb 2016 09:45:50 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-0.7 required=5.0 tests=AWL, BAYES_00, KAM_LAZY_DOMAIN_SECURITY, RP_MATCHES_RCVD autolearn=no version=3.3.2 spammy=refering, Hx-languages-length:2843, globally, uptodate X-HELO: gcc1-power7.osuosl.org Received: from gcc1-power7.osuosl.org (HELO gcc1-power7.osuosl.org) (140.211.15.137) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 19 Feb 2016 09:45:48 +0000 Received: by gcc1-power7.osuosl.org (Postfix, from userid 10019) id A3BA51C06D8; Fri, 19 Feb 2016 09:45:44 +0000 (UTC) From: Segher Boessenkool To: gcc-patches@gcc.gnu.org Cc: Segher Boessenkool Subject: [PATCH] combine: Delete EQ* notes when pseudo mode changes (PR60818) Date: Fri, 19 Feb 2016 09:45:37 +0000 Message-Id: <71ce2561d2dd574e38b062a094f4ce41cac21a84.1455873752.git.segher@kernel.crashing.org> X-IsSubscribed: yes For some modifications combine does it changes the mode of a pseudo because of SELECT_CC_MODE. For example, it changes "unsigned >= 0" to "unsigned != 0", and on some targets GTU and NE use different CC_MODEs. Changing the mode of a pseudo has effect globally, so this changes any REG_EQUAL and REG_EQUIV notes referring to the pseudo as well, which makes them invalid. This patch finds such notes and deletes them in these cases. Testing on powerpc64-linux; will also test on x86_64-linux before committing. Segher 2016-02-19 Segher Boessenkool PR 60818/rtl-optimization * combine.c (combine_remove_reg_equal_equiv_notes_for_regno): New function. (try_combine): Call it when SELECT_CC_MODE makes us change the mode of a pseudo. --- gcc/combine.c | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/gcc/combine.c b/gcc/combine.c index 24dcefa..d3b69ac 100644 --- a/gcc/combine.c +++ b/gcc/combine.c @@ -2553,6 +2553,32 @@ can_split_parallel_of_n_reg_sets (rtx_insn *insn, int n) return true; } +/* Remove all REG_EQUAL and REG_EQUIV notes referring to REGNO. This is + like rtlanal's remove_reg_equal_equiv_notes_for_regno but with some big + differences, because combine does not keep the DF info up-to-date. + We do however never add or move these notes during combine, so we can + still use the DF info as it was at the start of combine to find all + such notes. */ + +static void +combine_remove_reg_equal_equiv_notes_for_regno (unsigned int regno) +{ + gcc_assert (df); + + rtx reg = regno_reg_rtx[regno]; + + for (df_ref eq_use = DF_REG_EQ_USE_CHAIN (regno); + eq_use; + eq_use = DF_REF_NEXT_REG (eq_use)) + { + rtx_insn *insn = DF_REF_INSN (eq_use); + rtx note = find_reg_equal_equiv_note (insn); + + if (note && reg_overlap_mentioned_p (reg, XEXP (note, 0))) + remove_note (insn, note); + } +} + /* Try to combine the insns I0, I1 and I2 into I3. Here I0, I1 and I2 appear earlier than I3. I0 and I1 can be zero; then we combine just I2 into I3, or I1 and I2 into @@ -3184,6 +3210,8 @@ try_combine (rtx_insn *i3, rtx_insn *i2, rtx_insn *i1, rtx_insn *i0, newpat_dest = gen_rtx_REG (compare_mode, regno); else { + combine_remove_reg_equal_equiv_notes_for_regno (regno); + SUBST_MODE (regno_reg_rtx[regno], compare_mode); newpat_dest = regno_reg_rtx[regno]; } @@ -6638,6 +6666,12 @@ simplify_set (rtx x) new_dest = gen_rtx_REG (compare_mode, regno); else { + /* We change the mode of the result pseudo. The expression + in REG_EQ* notes refering to that pseudo will likely no + longer make sense, so delete those notes. + This is PR60818. */ + combine_remove_reg_equal_equiv_notes_for_regno (regno); + SUBST_MODE (regno_reg_rtx[regno], compare_mode); new_dest = regno_reg_rtx[regno]; }