From patchwork Wed Oct 7 22:57:59 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alan Modra X-Patchwork-Id: 1378329 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=8.43.85.97; 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=Jli65S68; dkim-atps=neutral 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 ozlabs.org (Postfix) with ESMTPS id 4C68sQ3t6Wz9sS8 for ; Thu, 8 Oct 2020 09:59:06 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id AA4D9387088F; Wed, 7 Oct 2020 22:58:54 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org AA4D9387088F DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1602111534; bh=XGF/Wo3emnYynpFhGrKcFEjvrKFdrr6q9ioLFujt/1Q=; 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=Jli65S68uin7t/deqey+WvAiHNC0r2fyJ6VX4IOAZwctM+86txAkdgYLCgIYqlZSL +wch7Sce+wvLxoygVk/o5vBxMrQtC0DKQY5nPAwMTUBiU+1d9ZQ6d59L0dIQsurahV Jec03Y76na5QLXjzm/7RUFeSErxElZeOcCkczeuA= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-pg1-x532.google.com (mail-pg1-x532.google.com [IPv6:2607:f8b0:4864:20::532]) by sourceware.org (Postfix) with ESMTPS id 061F53870883 for ; Wed, 7 Oct 2020 22:58:52 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 061F53870883 Received: by mail-pg1-x532.google.com with SMTP id o25so2602515pgm.0 for ; Wed, 07 Oct 2020 15:58:51 -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=XGF/Wo3emnYynpFhGrKcFEjvrKFdrr6q9ioLFujt/1Q=; b=pNRvnbunFkVQgUwP69JINIzw6h4RVZxyRhe84pPKNgCMC0EI+Rj3Ff51HWemRi0HvN lRwVNyLRbO9tI3OT6jAVR9O6wkK+ylshN0HhYrvN4+SAYmWHpfovM1m3n+k9M46QS8XA V/pkPXZ5TuL1PyNj4AQDYG1+ccdjbx5QVC2YUg43Et3FI6CBsDapJ9MfFYJmMW/VV0t6 rI+q8d/gPL67AG7lepkPRS/EZf6Da3JE81Zyhg8pJm6p5ArqqcdHoE8/rDjmYFIwG2nh 8Y0z6YKy6+DWkkkfumiNUSyD7VUTRepLiaUtDZX+CDRwD8zdvHLrd+qv/CzMrG2eK5mD G53w== X-Gm-Message-State: AOAM531eL1aum0b6FiAOkdnC6NfIcAjpPM0vKyDnK0vMEeqiON1HwrXa U7O+lR2mEs0p+h0YlhO8rvfHwmBoDadang== X-Google-Smtp-Source: ABdhPJwICrJtrpUEGpG/lH67dWHSKVpfdlXbWW2RYW0HpWN0uphVFPhNzUbniNqDaacr015uf/3Dag== X-Received: by 2002:a17:90a:17c9:: with SMTP id q67mr4930320pja.128.1602111530820; Wed, 07 Oct 2020 15:58:50 -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.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 07 Oct 2020 15:58:50 -0700 (PDT) To: gcc-patches@gcc.gnu.org Subject: [PATCH 7/8] [RS6000] rs6000_rtx_costs reduce cost for SETs Date: Thu, 8 Oct 2020 09:27:59 +1030 Message-Id: <20201007225800.9536-8-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=-10.3 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" The aim of this patch is to make rtx_costs for SETs closer to insn_cost for SETs. One visible effect on powerpc code is increased if-conversion. * config/rs6000/rs6000.c (rs6000_rtx_costs): Reduce cost of SET operands. diff --git a/gcc/config/rs6000/rs6000.c b/gcc/config/rs6000/rs6000.c index 76aedbfae6f..d455aa52427 100644 --- a/gcc/config/rs6000/rs6000.c +++ b/gcc/config/rs6000/rs6000.c @@ -21684,6 +21684,35 @@ rs6000_rtx_costs (rtx x, machine_mode mode, int outer_code, } return false; + case SET: + /* On entry the value in *TOTAL is the number of general purpose + regs being set, multiplied by COSTS_N_INSNS (1). Handle + costing of set operands specially since in most cases we have + an instruction rather than just a piece of RTL and should + return a cost comparable to insn_cost. That's a little + complicated because in some cases the cost of SET operands is + non-zero, see point 5 above and cost of PLUS for example, and + in others it is zero, for example for (set (reg) (reg)). + But (set (reg) (reg)) has the same insn_cost as + (set (reg) (plus (reg) (reg))). Hack around this by + subtracting COSTS_N_INSNS (1) from the operand cost in cases + were we add at least COSTS_N_INSNS (1) for some operation. + However, don't do so for constants. Constants might cost + more than zero when they require more than one instruction, + and we do want the cost of extra instructions. */ + { + rtx_code src_code = GET_CODE (SET_SRC (x)); + if (src_code == CONST_INT + || src_code == CONST_DOUBLE + || src_code == CONST_WIDE_INT) + return false; + int set_cost = (rtx_cost (SET_SRC (x), mode, SET, 1, speed) + + rtx_cost (SET_DEST (x), mode, SET, 0, speed)); + if (set_cost >= COSTS_N_INSNS (1)) + *total += set_cost - COSTS_N_INSNS (1); + return true; + } + default: return false; }