From patchwork Thu Jun 2 16:53:53 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Greenhalgh X-Patchwork-Id: 69194 Delivered-To: patch@linaro.org Received: by 10.140.106.246 with SMTP id e109csp216844qgf; Thu, 2 Jun 2016 09:54:54 -0700 (PDT) X-Received: by 10.98.94.194 with SMTP id s185mr6339102pfb.32.1464886493994; Thu, 02 Jun 2016 09:54:53 -0700 (PDT) Return-Path: Received: from sourceware.org (server1.sourceware.org. [209.132.180.131]) by mx.google.com with ESMTPS id o4si20431921pas.14.2016.06.02.09.54.53 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 02 Jun 2016 09:54:53 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-return-428924-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) client-ip=209.132.180.131; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org; spf=pass (google.com: domain of gcc-patches-return-428924-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-428924-patch=linaro.org@gcc.gnu.org DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-type; q=dns; s=default; b=HJ0lypWnS4Q2lLEp wJaIv/LsmCryQFZy8hpeyiyZiL2eqtcrUbMJUM+E0iBhU0skup98DwPlwX+elEq0 ASPnOhrqTpd5pqo4mJbYmtCmXC7Qto6xtClNKEt0KyTQ4yBMFbz8HUQ7QPH2gWzL aPYap1ejkbxA2hetoWq1eNYBf7o= 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:from :to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-type; s=default; bh=FColWyjdWjLqbs1t8c8Ib+ FeBzc=; b=rfsxAtxFNHLgkEcHHBsRE99/BxU/croYRRxMWwQKFCiamdGy6UILU9 hANdnAvnOE3kJmvHmPuTgSrl+uFlMD1AEx8Zoy1ubokUEKZ3xVyOsP33G6VQDzZi zDiPRZ4Dn7i2ksUOK5+khKQNtebBpKrLGWlNmH7jUIv7CKlCk+Cc4= Received: (qmail 19680 invoked by alias); 2 Jun 2016 16:54:29 -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 19635 invoked by uid 89); 2 Jun 2016 16:54:27 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.5 required=5.0 tests=AWL, BAYES_00, SPF_PASS autolearn=ham version=3.3.2 spammy=HX-Exchange-Antispam-Report-CFA-Test:102415321, jamesgreenhalgharmcom, james.greenhalgh@arm.com, metric X-HELO: eu-smtp-delivery-143.mimecast.com Received: from eu-smtp-delivery-143.mimecast.com (HELO eu-smtp-delivery-143.mimecast.com) (146.101.78.143) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 02 Jun 2016 16:54:17 +0000 Received: from emea01-db3-obe.outbound.protection.outlook.com (mail-db3lrp0080.outbound.protection.outlook.com [213.199.154.80]) (Using TLS) by eu-smtp-1.mimecast.com with ESMTP id uk-mta-3-7o6FGrz5Or6aCTXE4WNsTw-1; Thu, 02 Jun 2016 17:54:11 +0100 Received: from AM2PR08CA0032.eurprd08.prod.outlook.com (10.162.32.42) by AM2PR08MB0387.eurprd08.prod.outlook.com (10.161.235.25) with Microsoft SMTP Server (TLS) id 15.1.506.9; Thu, 2 Jun 2016 16:54:10 +0000 Received: from DB3FFO11FD052.protection.gbl (2a01:111:f400:7e04::123) by AM2PR08CA0032.outlook.office365.com (2a01:111:e400:843e::42) with Microsoft SMTP Server (TLS) id 15.1.506.9 via Frontend Transport; Thu, 2 Jun 2016 16:54:10 +0000 Received: from nebula.arm.com (217.140.96.140) by DB3FFO11FD052.mail.protection.outlook.com (10.47.217.83) with Microsoft SMTP Server (TLS) id 15.1.497.8 via Frontend Transport; Thu, 2 Jun 2016 16:54:09 +0000 Received: from e107456-lin.cambridge.arm.com (10.1.2.79) by mail.arm.com (10.1.106.66) with Microsoft SMTP Server id 14.3.294.0; Thu, 2 Jun 2016 17:54:08 +0100 From: James Greenhalgh To: CC: , , , , , Subject: [RFC: Patch 1/6] New target hook: rtx_branch_cost Date: Thu, 2 Jun 2016 17:53:53 +0100 Message-ID: <1464886438-17892-2-git-send-email-james.greenhalgh@arm.com> In-Reply-To: <1464886438-17892-1-git-send-email-james.greenhalgh@arm.com> References: <5617A4DE.6020004@redhat.com> <1464886438-17892-1-git-send-email-james.greenhalgh@arm.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-Forefront-Antispam-Report: CIP:217.140.96.140; IPV:CAL; SCL:-1; CTRY:GB; EFV:NLI; SFV:NSPM; SFS:(10009020)(6009001)(2980300002)(438002)(199003)(189002)(377424004)(4326007)(2906002)(33646002)(92566002)(4610100001)(6806005)(104016004)(2476003)(11100500001)(2351001)(229853001)(586003)(2950100001)(106466001)(8676002)(77096005)(568964002)(50226002)(76176999)(512874002)(87936001)(5003600100002)(36756003)(19580405001)(19580395003)(189998001)(110136002)(84326002)(50986999)(5008740100001)(8936002)(5890100001)(86362001); DIR:OUT; SFP:1101; SCL:1; SRVR:AM2PR08MB0387; H:nebula.arm.com; FPR:; SPF:Pass; MLV:sfv; A:1; MX:1; LANG:en; X-Microsoft-Exchange-Diagnostics: 1; DB3FFO11FD052; 1:clCXlv/JgKvB7vwgRqxguRh/kGjJ2mN+Xmm5uTM3WTFxBpQ1E02QhlzKJ23zo39j+zONNcyLMpdv0hJNmgYD5I9ySha5dN+j0gjuss9T+sby7UQY8yq5h+itoMSEFL5LFUDEpNUB1upDGl+Z+LmJ+RJcATtT0JbU9cr1z8cnkAuJ8/3Ei7ygtlMC++qPf/P4OgAmEPdya+17IW/H3qkFTa4PDS3jW59MGaqrv3L2HIFUQG6mudAcD9EPIK1s+mkzZrxICl7oKObJeXdMeVdC+mGCQ8Xdl7hHjuAnlIuus7/SKFESMb+j9DMT9qDAK5Ed66hc3wrQqSrOMMErjhzA0nKqmFnnA0VFfDScKL0t/2jYvdA33uESE0yZe1Q7H29RFtQc5TVMbWzy3ACUv0To3KeE8psCMS6s4ix+uHBNMk7tc5bHFIKNL4MG32SzK4q24xWrFSi2Gz0jA4Q0VndP7hxwIq73GTy7TMNUPoCZk6yOfGY+oFUI3igX7csUEDSgCGNk1XjCOj1Yr8l7BfPkg3mgOuaP5eCzzmeenzG5Mym+dkWe6c5HqG/Zta6wcvoA X-MS-Office365-Filtering-Correlation-Id: abdbfd01-631b-4973-2b65-08d38b0684b2 X-Microsoft-Exchange-Diagnostics: 1; AM2PR08MB0387; 2:vZ9Ef51aQDD+CnxYBczR6G0Vx5LLqc8QraeJCQk3pGMQXvS8oZ48gD0AAtgMl3SANjiVAy28DUaxIwyiWbe1yO1cmfjg45zFr6XpH+Cnz95xcEzmUYc3xibHHjsZ/lJVErTDIRa4vXV7jv6R7YNzNi2ZoI4ZWY0J3UURC0khUQQrOwFNQ/AA9n8kFjt6JA/S; 3:PwpEojG+y6SKbTV+tZtf6U4ztjEYyTYcNHcz8RaWC1wXa4CxpJTxqubai1moEEFozab8nvqGnLPgAPFsuiN+nWHk87HO5vjV4YPRD3IGYpf+jKXxLukR/YjXzVuguUUK6v1nht94GuvYSOMXuyEu6DLWBfbYeeJAh03rY9ugZ/hBC20NePamWs+HK2j3FtvxsiL8p3IdfhCNz0D95AgIWHOhJDvhd7tcqS+AX6c1GeZgg6dygtNtWGGeFpVOYnGQscdbK5b+Y3mbhvzJ0FLCNw== X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(8251501002); SRVR:AM2PR08MB0387; X-Microsoft-Exchange-Diagnostics: 1; AM2PR08MB0387; 25:hnWMFRHA/YEK3kKPsOcig9cqZ/aPngdk+/qUesde87ArNVPaFBk9tIX+7sXCkW/Q0Q3Lxjl0aIkO3nD9tDMbCt4cXfF84sPrNMi6fomYukNl61AnzgooRpEihyLqdgYmuk8QlKWsZnuzC/xxdjwltrk87D4KPzQqNmvL4WFK5j+mLiZ7+Q+gPRCRVWr81PsO/HR2yb8S3iunpn1351eVBPfSyDjL4XFhDNbnV9revjbAHPg8rRPGMv+I2iRwnoboyrHSZRtmIf2H8YVsV1RD/lE70Ri42P0na3pKOErfptxihwJp9+vucNJYr2BCWqBFBwxhnOarDoZ4QgkTcHKj7Q1ZnWYBjX1wO0NY19ehrniJxF0hk+7R3j4WV2FKtdirDe4dXLtk9vNEOlQuf0CCjsRw6w1VzMCPMxUJ0HP++pCjj/WpWTqPjSWNrmKIayPrF0SCEikGFXwIkyHGTX2oY0oybsFMvj+c3imBW4luS506kJnNIFAXwKWlxmygPisd; 20:0+ZT+4So04Ttj0fa/PmpbkfrRFGe1WoVvSUt+zp134Ar+yyMhz+Iu1MS9N8cBjzHG1IMZaMtuE4E+PW5kJpY39eEAh/gRLjGd8jYHtFbJGcS7Wm4mN0EMLrmuO8ZFPoyaVJvS7sHHx2heTo0Je2sFMUDgQsDxmN24oJ7bF5+SAuan84GXSBOmv5ocM4smfbL2/TUTvHPqmEbjd6diLd+Ta2IWmz32+oTUBdl32Lp4QjR3GThVbBXCmSRtUo96YMP NoDisclaimer: True X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(180628864354917); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(102415321)(601004)(2401047)(13013025)(5005006)(8121501046)(13020025)(13023025)(13024025)(10201501046)(3002001)(6055026); SRVR:AM2PR08MB0387; BCL:0; PCL:0; RULEID:; SRVR:AM2PR08MB0387; X-Microsoft-Exchange-Diagnostics: 1; AM2PR08MB0387; 4:LAxYrF1dsWgxgiH7D81kYAsQKLVkvpwGpFQ3Ksn+S4qCy6JzyKrxoDUIhESAwS6U6jiKYmKktUsD8zSu5CoVssKoVdHMAsdTD+elIhmMwVIcJJUdZFtfIuGVmVTOr7u86tZQ5luL0fUFat2pjXUvT+3OOiY8FEh+RXvyVX/so51WN07BDFzJFBzN//e0QF7P+oqfJIfcYA30GupuIS4r4/vrGw3g0+WW2s4TLUNymzj3hsnVQWEQStCSlWg5l3fxYt8s+VQFvHxz+qqjdJ88ydbfXiSTujjEi5/qflm3O7Hfg4MskrCaG7fwx1Iezdn3gH6ssAFtD06rG919djbsndMO4KIOJkMnqIwGYYO54OvzEcV2+yScO364ug8rCUTzcLXo1d3CafT6A6wdguhqzBUGAHgUXsb64E+SRM3CjEvUtVsAFMd15lFa1MLhcqmU4ZaIWCCjxz7CwJP7M+1pc3wIQMg4A7tKiSZGZ1Meay0OcZW9tPgwSIaEr7YN2mls9oQQyAqeKCJaUitduuIVsg== X-Forefront-PRVS: 0961DF5286 X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; AM2PR08MB0387; 23:xJzwYYqnkQuqnMTKfpqEw4y741UXHQWX1gwt3UoRY?= =?us-ascii?Q?7OIikjahP9tmqryvEy4Vnl04ixo79Ax7VDU4OsTp9/ThoJGjAkrFR2DNDyjp?= =?us-ascii?Q?bxQMDWJvYMYvzrFndX8M684h1TStBu562cmFBuAaHr2zUjygaZu+fRv/a3Pd?= =?us-ascii?Q?XnfSAxmqBwcjtVxQLi16BVGK9Jsn4dmcwit9I6h4gRInjv0Q/9kQH42xUoXx?= =?us-ascii?Q?OH/rRtYy+xgmiDexsNwjzRfW+KV0VnxHKqHcoiEzGvA6LjhaWJetT0sVZqXp?= =?us-ascii?Q?YcG3U2efdOIjl8uBOUFdp4QH0wFG/JUYQswNXJusUlJn++H7dqcYVOhiQmic?= =?us-ascii?Q?Rku/AzpNpaK65ldl/6JVhuiELrrZyNshHPhrzEIGpXA3N5mvsZDR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KEFQxq0Md3/xmFkLXFwwGf1oZSjntwpFgCKpMiXjyDc=; 7:2JIgEXn7IOtcdkQB7Saqvd9CDJgzruZcKTQG834NmbE7qe/N7I0U45O07bF5iRrfeuvvSI9vPfZQRlQI8XSMX/WUQnXHqci1ngWuoZy1pnN1AW16jP1L9/9zd9asrZtn1SY+jiWSufmPgvp93zYRyyp0/5uIOUj8yNzJ53Wnjcsjpiek2JbM7AoB0lFcAC2U; 20:r1d2HPrw6mMMaW9y2q+KVLKeT5sPTH/2sRDIuAe+h+FYF4w4B5w3VQ1HnGXSTZvq2cOy6/kdsofDGxsLSYkk/Ox+rbXQ9WPnwdXtBNH9Lh7OBGYn5cPwiObKbwcgSPZGrQ+mZiL0jgh2Jrdoiu+9JWf0SWgw6v+Xl01k5bdb7yE= SpamDiagnosticOutput: 1:23 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Jun 2016 16:54:09.9209 (UTC) X-MS-Exchange-CrossTenant-Id: f34e5979-57d9-4aaa-ad4d-b122a662184d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=f34e5979-57d9-4aaa-ad4d-b122a662184d; Ip=[217.140.96.140]; Helo=[nebula.arm.com] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM2PR08MB0387 X-MC-Unique: 7o6FGrz5Or6aCTXE4WNsTw-1 X-IsSubscribed: yes Hi, This patch introduces a new target hook, to be used like BRANCH_COST but with a guaranteed unit of measurement. We want this to break away from the current ambiguous uses of BRANCH_COST. BRANCH_COST is used in ifcvt.c in two types of comparisons. One against instruction counts - where it is used as the limit on the number of new instructions we are permitted to generate. The other (after multiplying by COSTS_N_INSNS (1)) directly against RTX costs. Of these, a comparison against RTX costs is the more easily understood metric across the compiler, and the one I've pulled out to the new hook. To keep things consistent for targets which don't migrate, this new hook has a default value of BRANCH_COST * COSTS_N_INSNS (1). OK? Thanks, James --- 2016-06-02 James Greenhalgh * target.def (rtx_branch_cost): New. * doc/tm.texi.in (TARGET_RTX_BRANCH_COST): Document it. * doc/tm.texi: Regenerate. * targhooks.h (default_rtx_branch_cost): New. * targhooks.c (default_rtx_branch_cost): New. diff --git a/gcc/doc/tm.texi b/gcc/doc/tm.texi index 8c7f2a1..32efa1f 100644 --- a/gcc/doc/tm.texi +++ b/gcc/doc/tm.texi @@ -6499,6 +6499,16 @@ should probably only be given to addresses with different numbers of registers on machines with lots of registers. @end deftypefn +@deftypefn {Target Hook} {unsigned int} TARGET_RTX_BRANCH_COST (bool @var{speed_p}, bool @var{predictable_p}) +This hook should return a cost in the same units as + @code{TARGET_RTX_COSTS}, giving the estimated cost of a branch. + @code{speed_p} is true if we are compiling for speed. + @code{predictable_p} is true if analysis suggests that the branch + will be predictable. The default implementation of this hook + multiplies @code{BRANCH_COST} by the cost of a cheap instruction to + approximate the cost of a branch in the appropriate units. +@end deftypefn + @deftypefn {Target Hook} bool TARGET_NO_SPECULATION_IN_DELAY_SLOTS_P (void) This predicate controls the use of the eager delay slot filler to disallow speculatively executed instructions being placed in delay slots. Targets diff --git a/gcc/doc/tm.texi.in b/gcc/doc/tm.texi.in index f963a58..92461b0 100644 --- a/gcc/doc/tm.texi.in +++ b/gcc/doc/tm.texi.in @@ -4748,6 +4748,8 @@ Define this macro if a non-short-circuit operation produced by @hook TARGET_ADDRESS_COST +@hook TARGET_RTX_BRANCH_COST + @hook TARGET_NO_SPECULATION_IN_DELAY_SLOTS_P @node Scheduling diff --git a/gcc/target.def b/gcc/target.def index 6392e73..f049a8b 100644 --- a/gcc/target.def +++ b/gcc/target.def @@ -3559,6 +3559,20 @@ registers on machines with lots of registers.", int, (rtx address, machine_mode mode, addr_space_t as, bool speed), default_address_cost) +/* Give a cost, in RTX Costs units, for an edge. Like BRANCH_COST, but with + well defined units. */ +DEFHOOK +(rtx_branch_cost, + "This hook should return a cost in the same units as\n\ + @code{TARGET_RTX_COSTS}, giving the estimated cost of a branch.\n\ + @code{speed_p} is true if we are compiling for speed.\n\ + @code{predictable_p} is true if analysis suggests that the branch\n\ + will be predictable. The default implementation of this hook\n\ + multiplies @code{BRANCH_COST} by the cost of a cheap instruction to\n\ + approximate the cost of a branch in the appropriate units.", + unsigned int, (bool speed_p, bool predictable_p), + default_rtx_branch_cost) + /* Permit speculative instructions in delay slots during delayed-branch scheduling. */ DEFHOOK diff --git a/gcc/targhooks.c b/gcc/targhooks.c index 6b4601b..dcffeb8 100644 --- a/gcc/targhooks.c +++ b/gcc/targhooks.c @@ -74,6 +74,7 @@ along with GCC; see the file COPYING3. If not see #include "intl.h" #include "opts.h" #include "gimplify.h" +#include "predict.h" bool @@ -1965,4 +1966,13 @@ default_optab_supported_p (int, machine_mode, machine_mode, optimization_type) return true; } +/* Default implementation of TARGET_RTX_BRANCH_COST. */ + +unsigned int +default_rtx_branch_cost (bool speed_p, + bool predictable_p) +{ + return BRANCH_COST (speed_p, predictable_p) * COSTS_N_INSNS (1); +} + #include "gt-targhooks.h" diff --git a/gcc/targhooks.h b/gcc/targhooks.h index 7687c39..b7ff94c 100644 --- a/gcc/targhooks.h +++ b/gcc/targhooks.h @@ -254,4 +254,6 @@ extern void default_setup_incoming_vararg_bounds (cumulative_args_t ca ATTRIBUTE extern bool default_optab_supported_p (int, machine_mode, machine_mode, optimization_type); +extern unsigned int default_rtx_branch_cost (bool, bool); + #endif /* GCC_TARGHOOKS_H */