From patchwork Wed Oct 7 22:57:53 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alan Modra X-Patchwork-Id: 1378323 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=sourceware.org; envelope-from=gcc-patches-bounces@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=none dis=none) header.from=gcc.gnu.org Authentication-Results: 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=tPmbpPRB; dkim-atps=neutral Received: from sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (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 ozlabs.org (Postfix) with ESMTPS id 4C68rz6dMGz9sS8 for ; Thu, 8 Oct 2020 09:58:43 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 7A3863846035; Wed, 7 Oct 2020 22:58:38 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 7A3863846035 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1602111518; bh=V9XOcuMXLFK9ZnwG2EUBtJqSxWpOgK55R67pqKSNWLI=; h=To:Subject:Date:In-Reply-To:References:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=tPmbpPRB4fJk9vH2zOSgqwCfifqGVLFDVu+P3salh2jWDi45NeyXRllov2a/0iVLA Qkm/GahmqEdEvnRrTH/LsxeK7J5mJH0N15m2WqCwcjaGFO6jFRbc1F/K4phq+3Cckw ZZ2qmBQvWs11edIELM9K53U/i6y7+NdAiTLHvFPI= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-pf1-x430.google.com (mail-pf1-x430.google.com [IPv6:2607:f8b0:4864:20::430]) by sourceware.org (Postfix) with ESMTPS id C36BF3851C2A for ; Wed, 7 Oct 2020 22:58:35 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org C36BF3851C2A Received: by mail-pf1-x430.google.com with SMTP id x22so2341963pfo.12 for ; Wed, 07 Oct 2020 15:58:35 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=V9XOcuMXLFK9ZnwG2EUBtJqSxWpOgK55R67pqKSNWLI=; b=jH6+88uKS4aHykf4DwxBRBcQ0E5rlXcfIH+eYQE/pHw9P6MSjsRP5cGy10dkMCVS0t 69d2wcmoBKXeOpVfWYAhu1uzHRC0Uo9d0Zz8vjQ23yb9XG75wFPk+d/rdmhw2vAuvDGK C0JyD3eq1Kc2AAB5fFS6pEgA6BrDZHWN5Po7FiNylxs8tHuujhH4BgkwLGoJl1npvB6Y uA96yGE/DIqGxQ1mczigkv+I/B9Ch4GEaFQTtzkRrJh7mOHhMDVvIp0or6nbzUB9Om8f koYjVKRePwTBcsRFNqKIUB+V6X50yWbvL78xaYxqXw14ZItfwmcD89POF/ADBE11/qGL 2hqg== X-Gm-Message-State: AOAM531WSTKJrEFG27gNRI7hChHETyC1h1m1lXlbPcM4rbPD4u8an8Ck cE5kctL4MYNDszln9A8Qnaq1PNiPtr6K/g== X-Google-Smtp-Source: ABdhPJx5Qspg6BQDqnUAMUNyF3a5jZrNtKBgH1+GtLl75VUcCLGT83WoUTLCNF0Dm7lHIGagt1pAmg== X-Received: by 2002:a63:de0a:: with SMTP id f10mr4944793pgg.49.1602111512719; Wed, 07 Oct 2020 15:58:32 -0700 (PDT) Received: from bubble.grove.modra.org ([2406:3400:51d:8cc0:e872:ea73:2f18:2dba]) by smtp.gmail.com with ESMTPSA id u15sm4451348pfm.61.2020.10.07.15.58.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 07 Oct 2020 15:58:27 -0700 (PDT) To: gcc-patches@gcc.gnu.org Subject: [PATCH 1/8] [RS6000] rs6000_rtx_costs comment Date: Thu, 8 Oct 2020 09:27:53 +1030 Message-Id: <20201007225800.9536-2-amodra@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20201007225800.9536-1-amodra@gmail.com> References: <20201007225800.9536-1-amodra@gmail.com> X-Spam-Status: No, score=-9.8 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) 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: Alan Modra via Gcc-patches From: Alan Modra Reply-To: Alan Modra Cc: segher@kernel.crashing.org Errors-To: gcc-patches-bounces@gcc.gnu.org Sender: "Gcc-patches" This lays out the ground rules for following patches. * config/rs6000/rs6000.c (rs6000_rtx_costs): Expand comment. diff --git a/gcc/config/rs6000/rs6000.c b/gcc/config/rs6000/rs6000.c index b58eeae2b98..97180bb3819 100644 --- a/gcc/config/rs6000/rs6000.c +++ b/gcc/config/rs6000/rs6000.c @@ -21208,7 +21208,46 @@ rs6000_cannot_copy_insn_p (rtx_insn *insn) /* Compute a (partial) cost for rtx X. Return true if the complete cost has been computed, and false if subexpressions should be - scanned. In either case, *TOTAL contains the cost result. */ + scanned. In either case, *TOTAL contains the cost result. + + 1) Calls from places like optabs.c:avoid_expensive_constant will + come here with OUTER_CODE set to an operation such as AND with X + being a CONST_INT or other CONSTANT_P type. This will be compared + against set_src_cost, where we'll come here with OUTER_CODE as SET + and X the same constant. + + 2) Calls from places like combine.c:distribute_and_simplify_rtx are + asking whether a possibly quite complex SET_SRC can be implemented + more cheaply than some other logically equivalent SET_SRC. + + 3) Calls from places like ifcvt.c:default_noce_conversion_profitable_p + will come here via seq_cost which calls set_rtx_cost on single set + insns. set_rtx_cost passes the pattern of a SET insn in X with + OUTER_CODE as INSN. The overall cost should be comparable to + rs6000_insn_cost since the code is comparing one insn sequence + (some of which may be costed by insn_cost) against another sequence. + Note the difference between set_rtx_cost, which costs the entire + SET, and set_src_cost, which costs just the SET_SRC. + + 4) Calls from places like cprop.c:try_replace_reg will also come + here via set_rtx_cost, with X either a valid pattern of a SET or + one where some registers have been replaced with constants. The + replacements may make the SET invalid, for example if + (set (reg1) (and (reg2) (const_int 0xfff))) + has reg2 replaced as + (set (reg1) (and (symbol_ref) (const_int 0xfff))) + then the replacement can't be implemented in one instruction and + really the cost should be higher by one instruction. However, + the cost for invalid insns doesn't matter much except that a + higher cost may lead to their rejection earlier. + + 5) fwprop.c:should_replace_address puts yet another wrinkle on this + function, where we prefer an address calculation that is more + complex yet has the same address_cost. In this case "more + complex" is determined by having a higher set_src_cost. So for + example, if we want a plain (reg) address to be replaced with + (plus (reg) (const)) when possible then PLUS needs to cost more + than zero here. */ static bool rs6000_rtx_costs (rtx x, machine_mode mode, int outer_code,