From patchwork Tue Jun 21 15:50:26 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Greenhalgh X-Patchwork-Id: 70569 Delivered-To: patch@linaro.org Received: by 10.140.28.4 with SMTP id 4csp2086495qgy; Tue, 21 Jun 2016 08:51:38 -0700 (PDT) X-Received: by 10.98.12.134 with SMTP id 6mr28456691pfm.15.1466524296254; Tue, 21 Jun 2016 08:51:36 -0700 (PDT) Return-Path: Received: from sourceware.org (server1.sourceware.org. [209.132.180.131]) by mx.google.com with ESMTPS id z125si2630984pfz.64.2016.06.21.08.51.35 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 21 Jun 2016 08:51:36 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-return-430236-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-430236-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-430236-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=a128bKejVbg4NlVl ss4BjIwivIn3bhijGBOTHNkR5FN7iGC2Mj6BLZflNAK+iKSogckHU7SgZsD8YCRp b1AL/PtD8CuCnpJsHicGgTbviDkWg3bqP67YVtHOZcnbqfLe3ICWdW6QVCImdGYd 3XtcA1n5LEb228kbM9tFsf4T0w4= 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=j0vJX8vhPrZk+xOZns5HSK fR0rA=; b=xY1ZN8aCSH88sY0lBnNkgYBtotJbcUGQTW7gr0QIoYJQYnnbzD+Ss4 T82QkXnpYWKjutEbwWRK1ASaWPRd6nDkDlvpBxDfpCSXNrmJxxut6RO1yTPMaz0B QWYfbmXpQYiM0a2vevrkqpkz2sdrCqN/nGNDQN4iviZPh3BSpEGOs= Received: (qmail 129490 invoked by alias); 21 Jun 2016 15:51:16 -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 129471 invoked by uid 89); 21 Jun 2016 15:51:15 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=0.8 required=5.0 tests=AWL, BAYES_50, LIKELY_SPAM_BODY, SPF_PASS autolearn=no version=3.3.2 spammy=eager, believes, 2554, D*var 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; Tue, 21 Jun 2016 15:51:05 +0000 Received: from EUR01-VE1-obe.outbound.protection.outlook.com (mail-ve1eur01lp0239.outbound.protection.outlook.com [213.199.154.239]) (Using TLS) by eu-smtp-1.mimecast.com with ESMTP id uk-mta-3-gdDiXkZYMWm5mK1ZxfTPGA-1; Tue, 21 Jun 2016 16:50:59 +0100 Received: from AM3PR08CA0053.eurprd08.prod.outlook.com (10.163.23.149) by VI1PR08MB0687.eurprd08.prod.outlook.com (10.163.169.154) with Microsoft SMTP Server (TLS) id 15.1.523.12; Tue, 21 Jun 2016 15:50:52 +0000 Received: from AM1FFO11FD012.protection.gbl (2a01:111:f400:7e00::121) by AM3PR08CA0053.outlook.office365.com (2a01:111:e400:8854::21) with Microsoft SMTP Server (TLS) id 15.1.523.12 via Frontend Transport; Tue, 21 Jun 2016 15:50:52 +0000 Received: from nebula.arm.com (217.140.96.140) by AM1FFO11FD012.mail.protection.outlook.com (10.174.65.101) with Microsoft SMTP Server (TLS) id 15.1.517.7 via Frontend Transport; Tue, 21 Jun 2016 15:50:51 +0000 Received: from e107456-lin.cambridge.arm.com (10.1.2.79) by mail.arm.com (10.1.105.66) with Microsoft SMTP Server id 14.3.294.0; Tue, 21 Jun 2016 16:50:37 +0100 From: James Greenhalgh To: CC: , , , , , , Subject: [RFC: Patch 1/6 v2] New target hook: max_noce_ifcvt_seq_cost Date: Tue, 21 Jun 2016 16:50:26 +0100 Message-ID: <1466524231-17412-1-git-send-email-james.greenhalgh@arm.com> In-Reply-To: References: 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)(7916002)(2980300002)(438002)(377454003)(199003)(377424004)(189002)(24454002)(8676002)(5890100001)(19580395003)(19580405001)(84326002)(104016004)(6806005)(246002)(11100500001)(36756003)(26826002)(92566002)(4610100001)(4326007)(77096005)(50986999)(76176999)(110136002)(2906002)(586003)(512874002)(189998001)(2950100001)(2476003)(7696003)(568964002)(87936001)(356003)(7846002)(5003600100003)(106466001)(86362001)(33646002)(2351001)(50226002)(229853001)(8936002); DIR:OUT; SFP:1101; SCL:1; SRVR:VI1PR08MB0687; H:nebula.arm.com; FPR:; SPF:Pass; PTR:fw-tnat.cambridge.arm.com; A:1; MX:1; LANG:en; X-Microsoft-Exchange-Diagnostics: 1; AM1FFO11FD012; 1:qXnKsqG1JV1dowQ9DbD8vIIg3JHgb0CYqy3HLJEBl+1NbLhSfheoNL3KW85/Es60pPOO8cdQy7xIdTKjCzS1TWkK0MfclH33SlGo9uFTfOjQyxy9Twt3M1ZS+S+aAUrGAJd47CPg21XTnr4CS+ZC3vXtOltdt450EMWvm/DdsxPD/TTjK28fRxGGJjflRr8TbDZrUIg8jqgN9v1z72RGF5zRs8DjlGqZcfkWd3SrgZHyq2UFPrQzUZSSiieM/dGpZS9w+PeAAGa3bTYvvkNLqzVjgrduZS8DG17iEdJlUkll9zcT5TapU/QdmnNCOXU/SKWujMXuuCfibByVb78IoUfoFcl3PA+8DXsWUx+Ua8LiUQ2ILjBeBtTLZhuJBXT5sAkuX6fPG2Z4VuASJuGKs0np11Soa02TZLYKs7IovfZyTlKMtQjzJ18V/4twC6QPf9Vm8sthTCLH5L2C4l1nHydz7tS9cx9yNa+OIjCWECjv2QVFVO1e8oHHRJuYhfZwkJY0fxU6ZRjb2ZPCSz+0oca3xEKI23P06GiqaFoQPBC3KE/meEUz/ljGxoj+TpGJ X-MS-Office365-Filtering-Correlation-Id: 16655d9a-c3c8-4dbf-e200-08d399ebd2c1 X-Microsoft-Exchange-Diagnostics: 1; VI1PR08MB0687; 2:mqW5RZlEUEE5Bi1J7ttIMRLd5yQ1AUQViXnQr/E/HqkeWbBnsxhfnCu2kIkXXGcHG6sLJkEFCMR84dmdsI6LH5V0Kk+80na7oBn9KMJd5JK5A+ndpG3dpJNDG6ufqaQG+e8TIZAfm5jyI6AqiP27SM7VVCDmDkuSMK3KVel+tKD2H+XBuEVExZ7jtIltv98T; 3:Nx9rnP4ZLnav+XIKZLSJU2kht6bAx0iSShFzbHT+AQe9TJmn6oW3ioDJMguvpKSRRBphUIVp72ZJr7Kj+nwjhSf7zZdMlL6fx6NF5q8/j1zgJ+OYaZOI+TPS7CPKAKjnoYiX0HdBiuhp/qfWSxgrs2aJdXdZD9eTPKYby8poJ/rIK3BGUj4Z7UftgTpRqCMx9OylIr/RsaAu5xJEXR2RQGofrR1jP/yuLjKio9Qru+yStIOlUGTI69hguwMw0QOrkAxzvETQzlekeXXBu/dcww== X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(8251501002); SRVR:VI1PR08MB0687; X-Microsoft-Exchange-Diagnostics: 1; VI1PR08MB0687; 25:r4zx+Ekdn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imclu7AXXTBpbBhlzQQpP2naBnKSmNNAIiyXeXHqPCYJV4wVob4zrrBnVaisyZhqrjRF1UWVDpVBUmlA9kP+YOMrTkpxdDsTVfJb/T1GAAsVrHfljqhah4ctNFrVWqlGGcdZnYg5NKbOfVhKBB0e/dFqIVYl4mKVcSW4po8MhsQNdAx1; 4:ixAGdsqAPClfWi05fPa+brJU6J4oDipbvYgDpsyO429WyiXzSd6Fu2tiAcY5/r/TFHqDsdVhkKtfoYDNRPW2mPXkHrdoCrdYAusFTuLcwOfeqTldEQYGoGHgM+pQKXbSdOMRja2Ial9GxfwZhm1OYmSOLEfVzg+U8qVo/STXwct6FMLIamzVoiLtgYh67T/lp90k9k6FZgoCJQdeG8PtsS8eXwZiz4vqdfgBibAht95tf/D8yBrO4GKOzkMFKShWnjzrNhrlP3VMSIdyDlWpJihPzahPMkBdhOfVtp89P8MS8rquGSc75HcDUAmiSElEirK01k5l/qktU0hif66TjHpav5wG2EHRksG8qvEQ7j1zKwIU80B60nQXVdULDMqrJl+1yXw2IoR6Uzk2OQo09xuv0MLPa4UG8Yiu4LnGMy6jOZytcLXsOcso0EBV8Z0Up3jm/iKiBlVTM1MqZdX/vmerp+L0e6IJAQU29iP3vIAe5L82WDIFjZkzfwEfou3fQ78M/blhqUOz3Xpni2xn1g== 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)(13020025)(13013025)(13024025)(13023025)(5005006)(8121501046)(10201501046)(3002001)(6055026); SRVR:VI1PR08MB0687; BCL:0; PCL:0; RULEID:; SRVR:VI1PR08MB0687; X-Forefront-PRVS: 098076C36C X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; VI1PR08MB0687; 23:YL5njdeV1jnUIaf32XtF0XNJEco4wlFhfaBjWhaIZ?= =?us-ascii?Q?OpYfcod8Jj92/YQatBVVxVntPpDFkwVxdU9GMZG0O/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DxTSdQlgdGy3tPf5pXvlzWg/WRQMadLsllga4VZ8NVM2KVAgefoEBIjCMPXptO3lCd28PjqQnBrHUv8LoMtupcUeDjRBpcOTHVqOrylMmIST/bh SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; VI1PR08MB0687; 20:Z9a6qepWTHPiFOmlZpQOYj4W1juDC5gk3rSabzHNpvPwQ8pUMIDGO7RBSS1737Rtvr7rKDUIV1Fpe/1/e5hk7XAhuTJrjvJTpwTOcpvs+eJ8+FCO2cb6UFqbUe4kZZtCAKMh0itthd4yqdxtyUMDrP/47tcGtio5/gLygSJNnNo= X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Jun 2016 15:50:51.9317 (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: VI1PR08MB0687 X-MC-Unique: gdDiXkZYMWm5mK1ZxfTPGA-1 X-IsSubscribed: yes On Fri, Jun 03, 2016 at 12:39:42PM +0200, Richard Biener wrote: > On Thu, Jun 2, 2016 at 6:53 PM, James Greenhalgh > wrote: > > > > 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? > > How does the caller compute "predictable"? There are some archs where > an information on whether this is a forward or backward jump is more > useful I guess. Also at least for !speed_p the distance of the branch is > important given not all targets support arbitrary branch offsets. Just through a call to predictable_edge_p. It isn't perfect. My worry with adding more details of the branch is that you end up with a nonsense target implementation that tries way too hard to be clever. But, I don't mind passing the edge through to the target hook, that way a target has it if they want it. In this patch revision, I pass the edge through. > I remember that at the last Cauldron we discussed to change things to > compare costs of sequences of instructions rather than giving targets no > context with just asking for single (sub-)insn rtx costs. I've made better use of seq_cost in this respin. Bernd was right, constructing dummy RTX just for costs, then discarding it, then constructing the actual RTX for matching doesn't make sense as a pipeline. Better just to construct the real sequence and use the cost of that. In this patch revision, I started by removing the idea that this costs a branch at all. It doesn't, the use of this hook is really a target trying to limit if-convert to not end up pulling too much on to the unconditional path. It seems better to expose that limit directly by explicitly asking for the maximum cost of an unconditional sequence we would create, and comparing against seq_cost of the new RTL. This saves a target trying to figure out what is meant by a cost of a branch. Having done that, I think I can see a clearer path to getting the default hook implementation in shape. I've introduced two new params, which give maximum costs for the generated sequence (one for a "predictable" branch, one for "unpredictable") in the speed_p cases. I'm not expecting it to be useful to give the user control in the case we are compiling for size - whether this is a size win or not is independent of whether the branch is predictable. For the default implementation, if the parameters are not set, I just multiply BRANCH_COST through by COSTS_N_INSNS (1) for size and COSTS_N_INSNS (3) for speed. I know this is not ideal, but I'm still short of ideas on how best to form the default implementation. This means we're still potentially going to introduce performance regressions for targets that don't provide an implementation of the new hook, or a default value for the new parameters. It does mean we can keep the testsuite clean by setting parameter values suitably high for all targets that have conditional move instructions. The new default causes some changes in generated conditional move sequences for x86_64. Whether these changes are for the better or not I can't say. This first patch introduces the two new parameters, and uses them in the default implementation of the target hook. Bootstrapped on x86_64 and aarch64 with no issues. OK? Thanks, James --- 2016-06-21 James Greenhalgh * target.def (max_noce_ifcvt_seq_cost): New. * doc/tm.texi.in (TARGET_MAX_NOCE_IFCVT_SEQ_COST): Document it. * doc/tm.texi: Regenerate. * targhooks.h (default_max_noce_ifcvt_seq_cost): New. * targhooks.c (default_max_noce_ifcvt_seq_cost): New. * params.def (PARAM_MAX_RTL_IF_CONVERSION_PREDICTABLE_COST): New. (PARAM_MAX_RTL_IF_CONVERSION_UNPREDICTABLE_COST): Likewise. * doc/invoke.texi: Document new params. diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi index e000218..b71968f 100644 --- a/gcc/doc/invoke.texi +++ b/gcc/doc/invoke.texi @@ -8816,6 +8816,17 @@ considered for if-conversion. The default is 10, though the compiler will also use other heuristics to decide whether if-conversion is likely to be profitable. +@item max-rtl-if-conversion-precitable-cost +@item max-rtl-if-conversion-unprecitable-cost +RTL if-conversion tries to remove conditional branches around a block and +replace them with conditionally executed instructions. These parameters +give the maximum permissible cost for the sequence that would be generated +by if-conversion depending on whether the branch is statically determined +to be predictable or not. The units for this parameter are the same as +those for the GCC internal seq_cost metric. The compiler will try to +provide a reasonable default for this parameter using the BRANCH_COST +target macro. + @item max-crossjump-edges The maximum number of incoming edges to consider for cross-jumping. The algorithm used by @option{-fcrossjumping} is @math{O(N^2)} in diff --git a/gcc/doc/tm.texi b/gcc/doc/tm.texi index b318615..bbf6c1b 100644 --- a/gcc/doc/tm.texi +++ b/gcc/doc/tm.texi @@ -6526,6 +6526,31 @@ 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_MAX_NOCE_IFCVT_SEQ_COST (bool @var{speed_p}, edge @var{e}) +This hook should return a value in the same units as +@code{TARGET_RTX_COSTS}, giving the maximum acceptable cost for +a sequence generated by the RTL if-conversion pass when conditional +execution is not available. The RTL if-conversion pass attempts +to convert conditional operations that would require a branch to a +series of unconditional operations and @code{mov@var{mode}cc} insns. +This hook gives the maximum cost of the unconditional instructions and +the @code{mov@var{mode}cc} insns. RTL if-conversion is cancelled if the +cost of the converted sequence is greater than the value returned by this +hook. + +@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. A target may decide to implement this hook to +return a lower maximum cost for branches that the compiler believes +will be predictable. + +The default implementation of this hook uses +@code{BRANCH_COST * COSTS_N_INSNS (1)} if we are compiling for size, +uses the @code{max-rtl-if-conversion-[un]predictable} parameters if they +are set, and uses a multiple of @code{BRANCH_COST} if we are compiling +for speed and the appropriate parameter is not set. +@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 1e8423c..d2b7f41 100644 --- a/gcc/doc/tm.texi.in +++ b/gcc/doc/tm.texi.in @@ -4762,6 +4762,8 @@ Define this macro if a non-short-circuit operation produced by @hook TARGET_ADDRESS_COST +@hook TARGET_MAX_NOCE_IFCVT_SEQ_COST + @hook TARGET_NO_SPECULATION_IN_DELAY_SLOTS_P @node Scheduling diff --git a/gcc/params.def b/gcc/params.def index 894b7f3..682adbd 100644 --- a/gcc/params.def +++ b/gcc/params.def @@ -1217,6 +1217,20 @@ DEFPARAM (PARAM_MAX_RTL_IF_CONVERSION_INSNS, "if-conversion.", 10, 0, 99) +DEFPARAM (PARAM_MAX_RTL_IF_CONVERSION_PREDICTABLE_COST, + "max-rtl-if-conversion-predictable-cost", + "Maximum permissible cost for the sequence that would be " + "generated by the RTL if-conversion pass for a branch which " + "is considered predictable.", + 20, 0, 200) + +DEFPARAM (PARAM_MAX_RTL_IF_CONVERSION_UNPREDICTABLE_COST, + "max-rtl-if-conversion-unpredictable-cost", + "Maximum permissible cost for the sequence that would be " + "generated by the RTL if-conversion pass for a branch which " + "is considered predictable.", + 40, 0, 200) + DEFPARAM (PARAM_HSA_GEN_DEBUG_STORES, "hsa-gen-debug-stores", "Level of hsa debug stores verbosity", diff --git a/gcc/target.def b/gcc/target.def index a4df363..22e4898 100644 --- a/gcc/target.def +++ b/gcc/target.def @@ -3572,6 +3572,35 @@ 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 +(max_noce_ifcvt_seq_cost, + "This hook should return a value in the same units as\n\ +@code{TARGET_RTX_COSTS}, giving the maximum acceptable cost for\n\ +a sequence generated by the RTL if-conversion pass when conditional\n\ +execution is not available. The RTL if-conversion pass attempts\n\ +to convert conditional operations that would require a branch to a\n\ +series of unconditional operations and @code{mov@var{mode}cc} insns.\n\ +This hook gives the maximum cost of the unconditional instructions and\n\ +the @code{mov@var{mode}cc} insns. RTL if-conversion is cancelled if the\n\ +cost of the converted sequence is greater than the value returned by this\n\ +hook.\n\ +\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. A target may decide to implement this hook to\n\ +return a lower maximum cost for branches that the compiler believes\n\ +will be predictable.\n\ +\n\ +The default implementation of this hook uses\n\ +@code{BRANCH_COST * COSTS_N_INSNS (1)} if we are compiling for size,\n\ +uses the @code{max-rtl-if-conversion-[un]predictable} parameters if they\n\ +are set, and uses a multiple of @code{BRANCH_COST} if we are compiling\n\ +for speed and the appropriate parameter is not set.", +unsigned int, (bool speed_p, edge e), +default_max_noce_ifcvt_seq_cost) + /* Permit speculative instructions in delay slots during delayed-branch scheduling. */ DEFHOOK diff --git a/gcc/targhooks.c b/gcc/targhooks.c index 3e089e7..42dea3b 100644 --- a/gcc/targhooks.c +++ b/gcc/targhooks.c @@ -74,6 +74,8 @@ along with GCC; see the file COPYING3. If not see #include "intl.h" #include "opts.h" #include "gimplify.h" +#include "predict.h" +#include "params.h" bool @@ -1977,4 +1979,29 @@ default_optab_supported_p (int, machine_mode, machine_mode, optimization_type) return true; } +/* Default implementation of TARGET_RTX_BRANCH_COST. */ + +unsigned int +default_max_noce_ifcvt_seq_cost (bool speed_p, edge e) +{ + bool predictable_p = predictable_edge_p (e); + /* For size, some targets like to set a BRANCH_COST of zero to disable + ifcvt, continue to allow that. Then multiply through by + COSTS_N_INSNS (1) so we're in a comparable base. */ + + if (!speed_p) + return BRANCH_COST (speed_p, predictable_p) * COSTS_N_INSNS (1); + + enum compiler_param param = predictable_p + ? PARAM_MAX_RTL_IF_CONVERSION_PREDICTABLE_COST + : PARAM_MAX_RTL_IF_CONVERSION_UNPREDICTABLE_COST; + + /* If we have a parameter set, use that, otherwise take a guess using + BRANCH_COST. */ + if (global_options_set.x_param_values[param]) + return PARAM_VALUE (param); + else + return BRANCH_COST (speed_p, predictable_p) * COSTS_N_INSNS (3); +} + #include "gt-targhooks.h" diff --git a/gcc/targhooks.h b/gcc/targhooks.h index d6581cf..e1bae6b 100644 --- a/gcc/targhooks.h +++ b/gcc/targhooks.h @@ -255,4 +255,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_max_noce_ifcvt_seq_cost (bool, edge); + #endif /* GCC_TARGHOOKS_H */