From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from server.nextmovesoftware.com (server.nextmovesoftware.com [162.254.253.69]) by sourceware.org (Postfix) with ESMTPS id 3DDDC385740D for ; Mon, 30 May 2022 13:46:25 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 3DDDC385740D Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=nextmovesoftware.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=nextmovesoftware.com DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=nextmovesoftware.com; s=default; h=Content-Type:MIME-Version:Message-ID: Date:Subject:To:From:Sender:Reply-To:Cc:Content-Transfer-Encoding:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:In-Reply-To:References:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=+h+PikF5jBKHLIRNtg8Jn+6wnku2HiBQB3k6SXmrsuI=; b=nhpMLEE7wC1k0c8tH2XkAxZt7f zRbYXT1uH8KYVyKpGE5UtHnXiuAW4+teYyIq2Vdc8gIKsbfGjKrLfNM5oUWE5h61KMJSJrZNtR6Nq CdLoirw307x4jEjAwKvbIZZheMzihLiD7vna0DuLK3l6dLyjjwPGoPXODk9ayRuzq4ahsTDXzTERl rlbwIdxOwdJv8F3gqxg3yl3BmHT0G60XvjR2etbQLsk2n6TvDkpFJOo8Jqj7G/mV+Sl8YS1+Rlisw D+jNP7cnNO+TFz4ak8BInMbEbNVxZKqQvtfo7vuvo7C8usBG5wlU9WfD8JO9Qh5GwBe+CCnHEtdnR mjx0T10A==; Received: from [185.62.158.67] (port=54655 helo=Dell) by server.nextmovesoftware.com with esmtpsa (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1nvfiy-0006Xg-N7 for gcc-patches@gcc.gnu.org; Mon, 30 May 2022 09:46:24 -0400 From: "Roger Sayle" To: "'GCC Patches'" Subject: [PATCH] Make the default rtx_costs of MULT/DIV variants consistent. Date: Mon, 30 May 2022 14:46:23 +0100 Message-ID: <003901d8742b$a7715db0$f6541910$@nextmovesoftware.com> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="----=_NextPart_000_003A_01D87434.09380FA0" X-Mailer: Microsoft Outlook 16.0 Thread-Index: Adh0KvkfUJEqY0F7R0KXZslhWg/E0Q== Content-Language: en-gb X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - server.nextmovesoftware.com X-AntiAbuse: Original Domain - gcc.gnu.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - nextmovesoftware.com X-Get-Message-Sender-Via: server.nextmovesoftware.com: authenticated_id: roger@nextmovesoftware.com X-Authenticated-Sender: server.nextmovesoftware.com: roger@nextmovesoftware.com X-Source: X-Source-Args: X-Source-Dir: X-Spam-Status: No, score=-12.4 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) 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-List-Received-Date: Mon, 30 May 2022 13:46:27 -0000 This is a multipart message in MIME format. ------=_NextPart_000_003A_01D87434.09380FA0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit GCC's middle-end provides a default cost model for RTL expressions, for backends that don't specify their own instruction timings, that can be summarized as multiplications are COSTS_N_INSNS(4), divisions are COSTS_N_INSNS(7) and all other operations are COSTS_N_INSNS(1). This patch tweaks the above definition so that fused-multiply-add (FMA) and high-part multiplications cost the same as regular multiplications, or more importantly aren't (by default) considered less expensive. Likewise the saturating forms of multiplication and division cost the same as the regular variants. These values can always be changed by the target, but the goal is to avoid RTL expansion substituting a suitable operation with its saturating equivalent because it (accidentally) looks much cheaper. For example, PR 89845 is about implementing division/modulus via highpart multiply, which may accidentally look extremely cheap. I believe there should be no code generation changes for this patch, but of course I'm happy to address any adverse changes on rare targets. This patch has been tested on x86_64-pc-linux-gnu with make bootstrap and make -k check, both with and without --target_board=unix{-m32}, with no new failures. Ok for mainline? 2022-05-30 Roger Sayle gcc/ChangeLog * rtlanal.cc (rtx_cost) : Treat FMA, SS_MULT, US_MULT, SMUL_HIGHPART and UMUL_HIGHPART as having the same cost as MULT.
: Likewise, SS_DIV and US_DIV have the same default as DIV. Thanks in advance, Roger -- ------=_NextPart_000_003A_01D87434.09380FA0 Content-Type: text/plain; name="patchrc.txt" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="patchrc.txt" diff --git a/gcc/rtlanal.cc b/gcc/rtlanal.cc=0A= index 7c29682..d78cc60 100644=0A= --- a/gcc/rtlanal.cc=0A= +++ b/gcc/rtlanal.cc=0A= @@ -4578,6 +4578,11 @@ rtx_cost (rtx x, machine_mode mode, enum rtx_code = outer_code,=0A= switch (code)=0A= {=0A= case MULT:=0A= + case FMA:=0A= + case SS_MULT:=0A= + case US_MULT:=0A= + case SMUL_HIGHPART:=0A= + case UMUL_HIGHPART:=0A= /* Multiplication has time-complexity O(N*N), where N is the=0A= number of units (translated from digits) when using=0A= schoolbook long multiplication. */=0A= @@ -4587,6 +4592,8 @@ rtx_cost (rtx x, machine_mode mode, enum rtx_code = outer_code,=0A= case UDIV:=0A= case MOD:=0A= case UMOD:=0A= + case SS_DIV:=0A= + case US_DIV:=0A= /* Similarly, complexity for schoolbook long division. */=0A= total =3D factor * factor * COSTS_N_INSNS (7);=0A= break;=0A= ------=_NextPart_000_003A_01D87434.09380FA0--