From patchwork Thu Jun 2 16:53:57 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Greenhalgh X-Patchwork-Id: 69196 Delivered-To: patch@linaro.org Received: by 10.140.106.246 with SMTP id e109csp217052qgf; Thu, 2 Jun 2016 09:55:21 -0700 (PDT) X-Received: by 10.98.72.219 with SMTP id q88mr6319221pfi.6.1464886521021; Thu, 02 Jun 2016 09:55:21 -0700 (PDT) Return-Path: Received: from sourceware.org (server1.sourceware.org. [209.132.180.131]) by mx.google.com with ESMTPS id zf8si4930514pab.235.2016.06.02.09.55.20 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 02 Jun 2016 09:55:21 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-return-428926-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-428926-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-428926-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=ZLrQTzCOwiZxrKFj t4N8aWQ4T7UgiNSdA3wR2GvjABbZ2t4e5xDkLYEUPHC1gBxBrMOrBwpUU6turlfT e/uEYkZsm0PUc0XbQfeAJqBqKO/QzGwmXJDVRvSa8zCfBYzjTN+cp7jhDb8d+91r C6O22M/tL9/qtBF60BClYnVROXU= 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=xwG/5XHwjXxaTqbJrKI5FE fs9jY=; b=LqHM46Hiy6oUpS2427f4pOTJTi8Ug0k6hrY8E0HxBPOOQoupaTCWTR Na2cJR/IrR2ToJhMHrHe54xMDSnHPaOGP6E/T0iRwXIdZTRjocYLAucsdZ80Xrg6 przgEmctpTASZrVJjZctshfoMNhdVFxGOCkDsnGOCkTQAguca8/Dc= Received: (qmail 23976 invoked by alias); 2 Jun 2016 16:55:03 -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 23804 invoked by uid 89); 2 Jun 2016 16:55:02 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-0.5 required=5.0 tests=AWL, BAYES_00, SPF_PASS, UNSUBSCRIBE_BODY autolearn=no version=3.3.2 spammy=strategies, comprised, Hx-spam-relays-external:15.1.511.8, H*RU:15.1.511.8 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:49 +0000 Received: from EUR01-DB5-obe.outbound.protection.outlook.com (mail-db5eur01lp0177.outbound.protection.outlook.com [213.199.154.177]) (Using TLS) by eu-smtp-1.mimecast.com with ESMTP id uk-mta-7-35oySbZKPS26Vma2G9orMg-1; Thu, 02 Jun 2016 17:54:33 +0100 Received: from AM4PR08CA0005.eurprd08.prod.outlook.com (10.166.127.15) by DB5PR08MB0390.eurprd08.prod.outlook.com (10.161.241.16) with Microsoft SMTP Server (TLS) id 15.1.506.9; Thu, 2 Jun 2016 16:54:32 +0000 Received: from AM1FFO11FD003.protection.gbl (2a01:111:f400:7e00::175) by AM4PR08CA0005.outlook.office365.com (2603:10a6:200:1a::15) with Microsoft SMTP Server (TLS) id 15.1.511.8 via Frontend Transport; Thu, 2 Jun 2016 16:54:32 +0000 Received: from nebula.arm.com (217.140.96.140) by AM1FFO11FD003.mail.protection.outlook.com (10.174.64.85) with Microsoft SMTP Server (TLS) id 15.1.497.8 via Frontend Transport; Thu, 2 Jun 2016 16:54:31 +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:30 +0100 From: James Greenhalgh To: CC: , , , , , Subject: [RFC: Patch 5/6] Improve the cost model for multiple-sets Date: Thu, 2 Jun 2016 17:53:57 +0100 Message-ID: <1464886438-17892-6-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)(189002)(199003)(377424004)(586003)(36756003)(8936002)(33646002)(4610100001)(8676002)(19580395003)(19580405001)(2950100001)(77096005)(11100500001)(2476003)(2906002)(4326007)(84326002)(5890100001)(6806005)(76176999)(50986999)(512874002)(5003600100002)(104016004)(86362001)(92566002)(106466001)(5008740100001)(2351001)(50226002)(229853001)(189998001)(110136002)(5000100001)(87936001)(568964002); DIR:OUT; SFP:1101; SCL:1; SRVR:DB5PR08MB0390; H:nebula.arm.com; FPR:; SPF:Pass; MLV:sfv; MX:1; A:1; LANG:en; X-Microsoft-Exchange-Diagnostics: 1; AM1FFO11FD003; 1:FV7GHGQ+RI04csi5hUOGy0DRycZukHKJWTvppY/PTcAQOnXrnnQn/sv0q/XCmDIC7uy+Q2V+nL26j3yXCaPkH/AZwrsZNAkUBxvp3NLuffSEHyRZD427046aODeImxRD/WbByf9qgh1+gHkbE18pGbPZIRFWeudqEVobCR62D5P1mVac6pEUyP4D5MCr8AMymb1xn1z3lpcmfkYVc5jC+rPpzfKWEEDUrdv6J5qb6L0z+R+QCa1oE9VtZMNtw4zSxbUT5S8bvg16G4Cd/DudAKU63A6Fh75/4I82Y0v/yOzZ5UK3fzzyanntnMdtG6VJhHu6030d+GvX9ZqJj3jYZzNmBJ+WWnCQ9jTVOuk67WfdvPPtmB74rNdswJqI0qPlrYeVJzOddZkCjrCGU8p4HpU4LeGAvGUwY+LVx61KoNgeaMdyiumtM41wLc0SfBvjjz6USWzOSEQzCXZeI4S0f9QmQQwpeKZY6HiOyiQzp3seLEAiysNsmSBBVBZ5UJ+upA3gWEEB3zHONp4cB9KBl972WC4xE5wTJjvtzs73MKATv91aMmlxFl4Ku1X5paNZ X-MS-Office365-Filtering-Correlation-Id: 578c1a0c-b451-4bf4-1941-08d38b0691bd X-Microsoft-Exchange-Diagnostics: 1; DB5PR08MB0390; 2:zIlUAohTbF6UOjdkmw4QqOSqnmDWBlKAbgP0iBbLss8GaTLJ9paI6HyxumEY3dAdMhbA9P1RYWAfsLCdkxPX8Rm47QA3pHD+rj0QR3kKa0nBIYpVcSDxpt+DkL1FReS8AND3ZHr51ZvZKCF9+fo/4muI/vIZUH1YInRH/RIr2CL5WRNxhGj8h6xmfhXXi/ht; 3:Y2QqyVC3Pst6gB0LGujtMGlRft4IKuK4qkLSvZQs0hWKFFMdMzi7f+849v6u1YWIfVFq8I7JlxU8W9W1/xpl49jJuuuNlLOkOyaVs5VnipktKdFHUGvLsvb6yD2GKY1WZysA8GFAdlFdFbfGLLBl0TwKNpJDJmhlL0NLzFDk2mGvOx44TQlEKf6Q+8girpdoKfPhoQrT1/IyzzhYN6jM5VHcB0KvJCULmIbXxxuQWMblkZ9S0Z3yLuKAYDvcqS2mcChDPYSyXxAL0BgZu/DU4w== X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(8251501002); SRVR:DB5PR08MB0390; X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F7bpvW5CsLNKibFlDk0oinJ133as/f7irok4AIqCcvGAlQQh4rTkb6XH71Zu5mO80VU2msBZMPUYO/fonnJxrfOfcwlRKca/pzS+GYjdpWQo6Xvnx/IJiL/tz4gx5KxB1l6APLnEgUpxve8tk1i9YHQ8hIjZ2bR9tFi3Z9ZE+XEeYy5zBKqGXZ7ft4pf7MAaMeSbf00iH98Cxqad; 4:WgJDYMrK0+Xp2z0YRcNuLX542WH3qGzUsBD8OSOkWcAJDvKHTxxoTtDr/1QyeT1bpiuuq3eClkE/fA8PS2DH/5LaifASnkc3gOzKoAZd/4oUW7NhlbBkHlfEXeF9pMB219GdG7e+PrINB0sfgCktFW+yOcO3YorCHoxFoxN9JfycfOLVnWbiCp+A9grRUrsMnTtqZqqZkENkkfaTToWsAOLgviRAk29JM+nZI/IBeXt9cwDCR6xDUmjmT9SUKexK1AnTRAlq05q31FdN5131vaRbkPDAsKtilDcnEIF2gp2sFKBNAKu5cmpzhkuZGr1CUuzrnTA2KsJI8lXxUSt+XpABnYiI4nJB1rtpMerti0KJSGV+8KBDyccc/zb+lWj8EwADWewwAH+Y4E9RxSfAuT2aVB4HBwTlQfmm1WfUq1yMG5o6nV2sb0GHUa1dmRhfWRgAf0fjjrUbDNPPQPhVJwbB1vud2lmr1UqIQKK0Pl2HzRLwBEC9imAEQpCRKKMnIn9oxHK3Lg9pB97x+ugD7g== 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)(8121501046)(13013025)(5005006)(13023025)(13024025)(13020025)(10201501046)(3002001)(6055026); SRVR:DB5PR08MB0390; BCL:0; PCL:0; RULEID:; SRVR:DB5PR08MB0390; X-Forefront-PRVS: 0961DF5286 X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; DB5PR08MB0390; 23:6TBzG0QKDwoTFxBWe9Y3qHrLY82TX6VFhzUi7F9r1?= =?us-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QPKYWG/?= =?us-ascii?Q?rwVRIKJW8v2wD+Fig7PIPbYyCUP8LpMXZweAiH3WIJuEZGFZ5FIwvK44oKQq?= =?us-ascii?Q?u48n0nug1eKsEEV9aPfiyLdnKE+7MkirfH+mObhbMmldt0KKabQHyL7x/rgb?= =?us-ascii?Q?R71QBc=3D?= X-Microsoft-Exchange-Diagnostics: 1; DB5PR08MB0390; 5:wv695KQh/neuOc6Fz37iwY8zO1iaeu3goMIu1eG8iOIySaR1nOUo35k7SAB2GNyHa1y3vU/7J54tsFjW9kI0A4mp6qP3H4VGejdrHaOo/dHgC1rkFUTqJpwxWco6/z8NAE9lbWhYEBh1wslbXcMTxQ==; 24:OTPDAEW6EnqhkO8HJWda2hK1JTpZ60OsarY/UZYnTmo4FToSiLUIQVjj5cukKtBBZJeaEbkWuBfc+Zc0kqu1fBHDccon+eFNAKCVTZDUJn8=; 7:Out1zV3FSKLbr8r1sZ9x9f+BpizAGPj8Gw20GNKMMG2j5eqYi6CZsGJ+AoHVVbQ//DkSpWQV30fv6r5qzCE0KRVdFkZWJ7/RipZbQFbEpHXZt8baeHydEkZZUP0LMord7G7uKcDW8XfrYmUVvkapA5BWTSoluEsfOQnk3ir+XRqouER1ShECeEtU1t5dsf01; 20:SOyP7bfKtysH1i1QvlYbd5sLRuj/pHLG8CgjvSGmjrPs3Ph9AfKn4wmEl9LIYLUaxGDT9lNzOq+bvwedjRCNtO3XxCfD+EqWEThlBwrwHMSPIoVskeMR06XtUOgcxLEVeP0V7K1kWX8ZxRrsG0uI8tdhwvk89axErNy7HIY5oOE= SpamDiagnosticOutput: 1:23 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Jun 2016 16:54:31.8029 (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: DB5PR08MB0390 X-MC-Unique: 35oySbZKPS26Vma2G9orMg-1 X-IsSubscribed: yes Hi, This patch is a small rewrite to the cost model for bb_ok_for_noce_multiple_sets to use the new noce_cmove_estimate_cost function added in the previous patches. Thanks, James --- 2016-06-02 James Greenhalgh * ifcvt.c (bb_of_for_noce_convert_multiple_sets): Change cost model. diff --git a/gcc/ifcvt.c b/gcc/ifcvt.c index bd3f55d..f71889e 100644 --- a/gcc/ifcvt.c +++ b/gcc/ifcvt.c @@ -3373,12 +3373,7 @@ noce_convert_multiple_sets (struct noce_if_info *if_info) /* Return true iff basic block TEST_BB is comprised of only (SET (REG) (REG)) insns suitable for conversion to a series of conditional moves. FORNOW: Use II to find the expected cost of - the branch into/over TEST_BB. - - TODO: This creates an implicit "magic number" for if conversion. - II->rtx_edge_cost now guides the maximum number of set instructions in - a basic block which is considered profitable to completely - if-convert. */ + the branch into/over TEST_BB. */ static bool bb_ok_for_noce_convert_multiple_sets (basic_block test_bb, @@ -3387,8 +3382,11 @@ bb_ok_for_noce_convert_multiple_sets (basic_block test_bb, rtx_insn *insn; unsigned count = 0; unsigned param = PARAM_VALUE (PARAM_MAX_RTL_IF_CONVERSION_INSNS); - /* TODO: Revisit this cost model. */ - unsigned limit = MIN (ii->rtx_edge_cost / COSTS_N_INSNS (1), param); + unsigned cost_limit = ii->rtx_edge_cost; + unsigned cost = 0; + bool speed_p = optimize_bb_for_speed_p (ii->test_bb); + rtx_code code = GET_CODE (ii->cond); + machine_mode cmode = GET_MODE (XEXP (ii->cond, 0)); FOR_BB_INSNS (test_bb, insn) { @@ -3404,6 +3402,9 @@ bb_ok_for_noce_convert_multiple_sets (basic_block test_bb, rtx dest = SET_DEST (set); rtx src = SET_SRC (set); + cost += noce_cmove_estimate_cost (cmode, GET_MODE (dest), + code, speed_p); + /* We can possibly relax this, but for now only handle REG to REG moves. This avoids any issues that might come from introducing loads/stores that might violate data-race-freedom guarantees. */ @@ -3418,14 +3419,14 @@ bb_ok_for_noce_convert_multiple_sets (basic_block test_bb, if (!can_conditionally_move_p (GET_MODE (dest))) return false; - /* FORNOW: Our cost model is a count of the number of instructions we - would if-convert. This is suboptimal, and should be improved as part - of a wider rework of branch_cost. */ - if (++count > limit) - return false; + count++; } - return count > 1; + /* If we would only put out one conditional move, the other strategies + this pass tries are better optimized and will be more appropriate. + If the cost in instructions is higher than the limit we've imposed, + also give up. */ + return (count > 1 && cost <= cost_limit && count <= param); } /* Given a simple IF-THEN-JOIN or IF-THEN-ELSE-JOIN block, attempt to convert