From patchwork Wed Apr 6 08:50:40 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Jelinek X-Patchwork-Id: 1613852 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.a=rsa-sha256 header.s=default header.b=lnQq+wAX; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=8.43.85.97; helo=sourceware.org; envelope-from=gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Received: from sourceware.org (server2.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4KYJC23ynCz9sFq for ; Wed, 6 Apr 2022 18:51:09 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id A2FBC3857C4A for ; Wed, 6 Apr 2022 08:51:06 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org A2FBC3857C4A DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1649235066; bh=B6m6xPVPFU4IaW7FwaBXEIQlGagYJWrLyLosWGgMiHI=; h=Date:To:Subject:References:In-Reply-To:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=lnQq+wAXlAzEk2kTCZuw/HF+V4Z+YoJt7SBjEq7HQHJ2TZbxXryXeNO+V0AWLo7eV PS9FGaOkqOSbNXofOMWHlBzqwuuaxusCpZZ5n22cw82NDWb5fKYeToXzPDrkOIIslM QpeiyS3EQ3w6WMY+wCmaHQ2Z2q/tSUUZNeQMCRXc= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by sourceware.org (Postfix) with ESMTPS id CD3033858D1E for ; Wed, 6 Apr 2022 08:50:46 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org CD3033858D1E Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-613-40BxW1vXNbOnB4NcsWkHew-1; Wed, 06 Apr 2022 04:50:45 -0400 X-MC-Unique: 40BxW1vXNbOnB4NcsWkHew-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id EC6931C1C520; Wed, 6 Apr 2022 08:50:44 +0000 (UTC) Received: from tucnak.zalov.cz (unknown [10.39.195.172]) by smtp.corp.redhat.com (Postfix) with ESMTPS id AE88F7AE3; Wed, 6 Apr 2022 08:50:44 +0000 (UTC) Received: from tucnak.zalov.cz (localhost [127.0.0.1]) by tucnak.zalov.cz (8.16.1/8.16.1) with ESMTPS id 2368ofbb1580072 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Wed, 6 Apr 2022 10:50:42 +0200 Received: (from jakub@localhost) by tucnak.zalov.cz (8.16.1/8.16.1/Submit) id 2368ofS81580071; Wed, 6 Apr 2022 10:50:41 +0200 Date: Wed, 6 Apr 2022 10:50:40 +0200 To: Segher Boessenkool Subject: [PATCH] combine, v2: Don't record for UNDO_MODE pointers into regno_reg_rtx array [PR104985] Message-ID: References: <20220405215655.GG614@gate.crashing.org> MIME-Version: 1.0 In-Reply-To: <20220405215655.GG614@gate.crashing.org> X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline X-Spam-Status: No, score=-4.3 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_NONE, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Jakub Jelinek via Gcc-patches From: Jakub Jelinek Reply-To: Jakub Jelinek Cc: gcc-patches@gcc.gnu.org Errors-To: gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org Sender: "Gcc-patches" On Tue, Apr 05, 2022 at 04:56:55PM -0500, Segher Boessenkool wrote: > > Or there are variant patches in the PR, either a minimal version of > > this patch, or one that records regno and adjusts all SUBST_MODE uses. > > I like this one best I think :-) > > > Also, not sure I like very much a function name in all caps, but I wanted > > to preserve the users and all other SUBST and SUBST_* are also all caps. > > Yet another possibility would be keep do_SUBST_MODE with the new > > arguments and > > #define SUBST_MODE(INTO, NEWVAL) do_SUBST_MODE ((INTO), (NEWVAL)) > > Like the other things in combine.c do, so please change to that? Which > means changing less than you do now :-) > > Changing this all to not have macros is better of course, and can be > tastefully done even with C++ (it would use C++ features even :-) ), but > let's do that all at once, and in stage 1. > > > - union { rtx *r; int *i; struct insn_link **l; } where; > > + union { rtx *r; int *i; rtx m; struct insn_link **l; } where; > > NAK. It is not clear at all what "rtx m" means, esp. since there is an > "rtx *r" already. In the PR you said "machine_mode m", that is clear of > course, can you do that instead? So in that case something like this (i.e. the regno variant, renamed to subst_mode from SUBST_MODE, and naming the union member regno rather than m)? And for GCC 13 change do_SUBST_INT to subst_int with int &into arg, do_SUBST_LINK to subst_link with struct insn_link *&into arg, and do_SUBST into subst with rtx &into arg? 2022-04-06 Jakub Jelinek PR rtl-optimization/104985 * combine.cc (struct undo): Add where.regno member. (do_SUBST_MODE): Rename to ... (subst_mode): ... this. Change first argument from rtx * into int, operate on regno_reg_rtx[regno] and save regno into where.regno. (SUBST_MODE): Remove. (try_combine): Use subst_mode instead of SUBST_MODE, change first argument from regno_reg_rtx[whatever] to whatever. For UNDO_MODE, use regno_reg_rtx[undo->where.regno] instead of *undo->where.r. (undo_to_marker): For UNDO_MODE, use regno_reg_rtx[undo->where.regno] instead of *undo->where.r. (simplify_set): Use subst_mode instead of SUBST_MODE, change first argument from regno_reg_rtx[whatever] to whatever. Jakub --- gcc/combine.cc.jj 2022-03-30 09:11:42.331261823 +0200 +++ gcc/combine.cc 2022-04-06 10:29:55.333106447 +0200 @@ -382,7 +382,7 @@ struct undo struct undo *next; enum undo_kind kind; union { rtx r; int i; machine_mode m; struct insn_link *l; } old_contents; - union { rtx *r; int *i; struct insn_link **l; } where; + union { rtx *r; int *i; int regno; struct insn_link **l; } where; }; /* Record a bunch of changes to be undone, up to MAX_UNDO of them. @@ -761,10 +761,11 @@ do_SUBST_INT (int *into, int newval) well. */ static void -do_SUBST_MODE (rtx *into, machine_mode newval) +subst_mode (int regno, machine_mode newval) { struct undo *buf; - machine_mode oldval = GET_MODE (*into); + rtx reg = regno_reg_rtx[regno]; + machine_mode oldval = GET_MODE (reg); if (oldval == newval) return; @@ -775,15 +776,13 @@ do_SUBST_MODE (rtx *into, machine_mode n buf = XNEW (struct undo); buf->kind = UNDO_MODE; - buf->where.r = into; + buf->where.regno = regno; buf->old_contents.m = oldval; - adjust_reg_mode (*into, newval); + adjust_reg_mode (reg, newval); buf->next = undobuf.undos, undobuf.undos = buf; } -#define SUBST_MODE(INTO, NEWVAL) do_SUBST_MODE (&(INTO), (NEWVAL)) - /* Similar to SUBST, but NEWVAL is a LOG_LINKS expression. */ static void @@ -3186,7 +3185,7 @@ try_combine (rtx_insn *i3, rtx_insn *i2, newpat_dest = gen_rtx_REG (compare_mode, regno); else { - SUBST_MODE (regno_reg_rtx[regno], compare_mode); + subst_mode (regno, compare_mode); newpat_dest = regno_reg_rtx[regno]; } } @@ -3576,7 +3575,7 @@ try_combine (rtx_insn *i3, rtx_insn *i2, ni2dest = gen_rtx_REG (new_mode, REGNO (i2dest)); else { - SUBST_MODE (regno_reg_rtx[REGNO (i2dest)], new_mode); + subst_mode (REGNO (i2dest), new_mode); ni2dest = regno_reg_rtx[REGNO (i2dest)]; } @@ -3712,7 +3711,7 @@ try_combine (rtx_insn *i3, rtx_insn *i2, newdest = gen_rtx_REG (split_mode, REGNO (i2dest)); else { - SUBST_MODE (regno_reg_rtx[REGNO (i2dest)], split_mode); + subst_mode (REGNO (i2dest), split_mode); newdest = regno_reg_rtx[REGNO (i2dest)]; } } @@ -4082,7 +4081,7 @@ try_combine (rtx_insn *i3, rtx_insn *i2, for (undo = undobuf.undos; undo; undo = undo->next) if (undo->kind == UNDO_MODE) { - rtx reg = *undo->where.r; + rtx reg = regno_reg_rtx[undo->where.regno]; machine_mode new_mode = GET_MODE (reg); machine_mode old_mode = undo->old_contents.m; @@ -4755,7 +4754,8 @@ undo_to_marker (void *marker) *undo->where.i = undo->old_contents.i; break; case UNDO_MODE: - adjust_reg_mode (*undo->where.r, undo->old_contents.m); + adjust_reg_mode (regno_reg_rtx[undo->where.regno], + undo->old_contents.m); break; case UNDO_LINKS: *undo->where.l = undo->old_contents.l; @@ -6819,7 +6819,7 @@ simplify_set (rtx x) new_dest = gen_rtx_REG (compare_mode, regno); else { - SUBST_MODE (regno_reg_rtx[regno], compare_mode); + subst_mode (regno, compare_mode); new_dest = regno_reg_rtx[regno]; }