From patchwork Fri Oct 4 12:41:02 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Meissner X-Patchwork-Id: 1171808 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gcc.gnu.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-510243-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=linux.ibm.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="H8WUXakK"; dkim-atps=neutral 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 46l8d31vBsz9sPl for ; Fri, 4 Oct 2019 22:41:25 +1000 (AEST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:date :from:to:subject:message-id:references:mime-version:content-type :in-reply-to; q=dns; s=default; b=E8MXPc70PEP4nq0JAHr0jyMRltDTgk zvysdUgdZlCqiE0ULwoxmFCDJ6ddk7spri+uQ42vv1jYMDGSES0hIR6QG3ggomR4 QyqcP6BjuslvPyKiH2Wc0s4RmIeEH5SycnDJuwtqZvvve8aan6W53pjBEqqipbem kZ5z/0vtPYWmY= 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:date :from:to:subject:message-id:references:mime-version:content-type :in-reply-to; s=default; bh=z68EtcIpnwarMrZGbJxI7sP1b7o=; b=H8WU XakKzYX5jFy6a5sNkNIpcao5kU5kbsE3sJnJO7Ph8FNhz2gdDplfIMj4k53mStoF T4e1SyDJdTmsbzSrYaLH9zqTIi4qTCXUxEyRRVGuU2gIu9HjYMmcJbGofFtO2sXk HzGaLAoFvO4F4LP6nBAA3xIqVqQC/cxHEkQ6en8= Received: (qmail 117679 invoked by alias); 4 Oct 2019 12:41:18 -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 117668 invoked by uid 89); 4 Oct 2019 12:41:18 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-12.6 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_LOW, SPF_PASS autolearn=ham version=3.3.1 spammy=Single, rtx_insn X-HELO: mx0a-001b2d01.pphosted.com Received: from mx0b-001b2d01.pphosted.com (HELO mx0a-001b2d01.pphosted.com) (148.163.158.5) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 04 Oct 2019 12:41:16 +0000 Received: from pps.filterd (m0098414.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.27/8.16.0.27) with SMTP id x94Cchjc079254; Fri, 4 Oct 2019 08:41:08 -0400 Received: from pps.reinject (localhost [127.0.0.1]) by mx0b-001b2d01.pphosted.com with ESMTP id 2ve5s5hdy2-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 04 Oct 2019 08:41:07 -0400 Received: from m0098414.ppops.net (m0098414.ppops.net [127.0.0.1]) by pps.reinject (8.16.0.27/8.16.0.27) with SMTP id x94Cf75V086970; Fri, 4 Oct 2019 08:41:07 -0400 Received: from ppma03dal.us.ibm.com (b.bd.3ea9.ip4.static.sl-reverse.com [169.62.189.11]) by mx0b-001b2d01.pphosted.com with ESMTP id 2ve5s5hdxg-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 04 Oct 2019 08:41:07 -0400 Received: from pps.filterd (ppma03dal.us.ibm.com [127.0.0.1]) by ppma03dal.us.ibm.com (8.16.0.27/8.16.0.27) with SMTP id x94CeIWK026115; Fri, 4 Oct 2019 12:41:06 GMT Received: from b03cxnp08025.gho.boulder.ibm.com (b03cxnp08025.gho.boulder.ibm.com [9.17.130.17]) by ppma03dal.us.ibm.com with ESMTP id 2v9y591pgk-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 04 Oct 2019 12:41:06 +0000 Received: from b03ledav003.gho.boulder.ibm.com (b03ledav003.gho.boulder.ibm.com [9.17.130.234]) by b03cxnp08025.gho.boulder.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id x94Cf5Z862194010 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 4 Oct 2019 12:41:05 GMT Received: from b03ledav003.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 5E3766A04F; Fri, 4 Oct 2019 12:41:05 +0000 (GMT) Received: from b03ledav003.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id D13276A04D; Fri, 4 Oct 2019 12:41:04 +0000 (GMT) Received: from ibm-tinman.the-meissners.org (unknown [9.80.205.20]) by b03ledav003.gho.boulder.ibm.com (Postfix) with ESMTPS; Fri, 4 Oct 2019 12:41:04 +0000 (GMT) Date: Fri, 4 Oct 2019 08:41:02 -0400 From: Michael Meissner To: Michael Meissner , gcc-patches@gcc.gnu.org, segher@kernel.crashing.org, dje.gcc@gmail.com Subject: [PATCH], V4, patch #11 [part of patch #4.2], Adjust insn cost for prefixed instructions Message-ID: <20191004124102.GC561@ibm-tinman.the-meissners.org> Mail-Followup-To: Michael Meissner , gcc-patches@gcc.gnu.org, segher@kernel.crashing.org, dje.gcc@gmail.com References: <20190918234214.GA27521@ibm-toto.the-meissners.org> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20190918234214.GA27521@ibm-toto.the-meissners.org> User-Agent: Mutt/1.5.21 (2010-09-15) I was asked to split V4 patch #4.2 into smaller chuncks. This patch is one of 8 patches that were broken out from 4.2. Another patch from 4.2 to use SIGNED_16BIT_OFFSET_EXTRA_P has already been committed. This patch adjusts the insn cost to treat prefixed instructions the same as non-prefixed instructions, rather than making them seem 3 times as expensive, since the prefixed instruction length is 12 bytes compared to the normal 4 bytes. Using all of the patches in this series, I have bootstrapped the compiler on a little endian power8 system and ran the regression tests. In addition, I have built the Spec 2006 and 2017 benchmark suites, for -mcpu=power8, -mcpu=power9, and -mcpu=future, and all of the benchmarks build. Can I check this into the trunk? 2019-10-03 Michael Meissner * config/rs6000/rs6000.c (rs6000_insn_cost): Do not make prefixed instructions cost more because they are larger in size. Index: gcc/config/rs6000/rs6000.c =================================================================== --- gcc/config/rs6000/rs6000.c (revision 276535) +++ gcc/config/rs6000/rs6000.c (working copy) @@ -20972,14 +20972,38 @@ rs6000_insn_cost (rtx_insn *insn, bool s if (recog_memoized (insn) < 0) return 0; - if (!speed) - return get_attr_length (insn); + if (speed) + { + int cost = get_attr_cost (insn); + if (cost > 0) + return cost; + } - int cost = get_attr_cost (insn); - if (cost > 0) - return cost; + int cost; + int length = get_attr_length (insn); + int n = length / 4; + + /* How many real instructions are generated for this insn? This is slightly + different from the length attribute, in that the length attribute counts + the number of bytes. With prefixed instructions, we don't want to count a + prefixed instruction (length 12 bytes including possible NOP) as taking 3 + instructions, but just one. */ + if (length >= 12 && get_attr_prefixed (insn) == PREFIXED_YES) + { + /* Single prefixed instruction. */ + if (length == 12) + n = 1; + + /* A normal instruction and a prefixed instruction (16) or two back + to back prefixed instructions (20). */ + else if (length == 16 || length == 20) + n = 2; + + /* Guess for larger instruction sizes. */ + else + n = 2 + (length - 20) / 4; + } - int n = get_attr_length (insn) / 4; enum attr_type type = get_attr_type (insn); switch (type)