From patchwork Tue Jun 21 15:50:29 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Greenhalgh X-Patchwork-Id: 70574 Delivered-To: patch@linaro.org Received: by 10.140.28.4 with SMTP id 4csp2087373qgy; Tue, 21 Jun 2016 08:53:43 -0700 (PDT) X-Received: by 10.98.92.133 with SMTP id q127mr29048457pfb.103.1466524423695; Tue, 21 Jun 2016 08:53:43 -0700 (PDT) Return-Path: Received: from sourceware.org (server1.sourceware.org. [209.132.180.131]) by mx.google.com with ESMTPS id yr6si18576529pab.245.2016.06.21.08.53.43 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 21 Jun 2016 08:53:43 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-return-430242-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-430242-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-430242-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=XnUifKdSr289maoc rRqVx91ZDztCeg4MUIpwWqYkybDpyD/pCwYEuuSaEgIurHApaqAPiBtMK7/xv9hB dg5XrQ0SVyy6IJkBoER5dscCzVg6NXRdPJBy+up2wIeh1J2zPWuS/rO19tevKK93 byNmI1NiDukN5eKvhDwc0uP1jG0= 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=WZ1frRM/Ch/XK+JAOhBjpb e8T8s=; b=jtRhLoCJI1WgWg4lyV+u3oaUrDzfK/OSUJg4Yqf/jJyvnbX4qWzp2M mUls1kjRTtXL5Dl5NRdgVaTzpL4eS2VzFQ9BgxV3e2jriSq9F/85kDXOghR70iv4 KYmZdikCv8YM/Ik+cozGzxocnO9nFAy5vJFWnfLWNW52GVBaEe9h0= Received: (qmail 8164 invoked by alias); 21 Jun 2016 15:53:26 -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 8066 invoked by uid 89); 21 Jun 2016 15:53:25 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.6 required=5.0 tests=AWL, BAYES_00, SPF_PASS autolearn=unavailable version=3.3.2 spammy= X-HELO: eu-smtp-delivery-143.mimecast.com Received: from eu-smtp-delivery-143.mimecast.com (HELO eu-smtp-delivery-143.mimecast.com) (207.82.80.143) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 21 Jun 2016 15:53:05 +0000 Received: from emea01-am1-obe.outbound.protection.outlook.com (mail-am1lrp0015.outbound.protection.outlook.com [213.199.154.15]) (Using TLS) by eu-smtp-1.mimecast.com with ESMTP id uk-mta-27-xCWSQ0wiPcKPYJit1wiuGQ-1; Tue, 21 Jun 2016 16:51:23 +0100 Received: from AM4PR08CA0018.eurprd08.prod.outlook.com (10.166.127.28) by HE1PR08MB0922.eurprd08.prod.outlook.com (10.166.125.10) with Microsoft SMTP Server (TLS) id 15.1.523.12; Tue, 21 Jun 2016 15:51:21 +0000 Received: from AM1FFO11FD056.protection.gbl (2a01:111:f400:7e00::196) by AM4PR08CA0018.outlook.office365.com (2603:10a6:200:1a::28) with Microsoft SMTP Server (TLS) id 15.1.523.12 via Frontend Transport; Tue, 21 Jun 2016 15:51:21 +0000 Received: from nebula.arm.com (217.140.96.140) by AM1FFO11FD056.mail.protection.outlook.com (10.174.65.75) with Microsoft SMTP Server (TLS) id 15.1.517.7 via Frontend Transport; Tue, 21 Jun 2016 15:51:21 +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:51:03 +0100 From: James Greenhalgh To: CC: , , , , , , Subject: [RFC: Patch 4/6 v2] Modify cost model for noce_cmove_arith Date: Tue, 21 Jun 2016 16:50:29 +0100 Message-ID: <1466524231-17412-4-git-send-email-james.greenhalgh@arm.com> In-Reply-To: <1466524231-17412-1-git-send-email-james.greenhalgh@arm.com> References: <1466524231-17412-1-git-send-email-james.greenhalgh@arm.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-Office365-Filtering-HT: Tenant 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)(189002)(377424004)(51444003)(199003)(7846002)(2476003)(104016004)(6806005)(4610100001)(92566002)(84326002)(87936001)(77096005)(586003)(106466001)(8676002)(110136002)(189998001)(11100500001)(246002)(5890100001)(2906002)(2950100001)(4326007)(356003)(8936002)(2351001)(26826002)(50226002)(36756003)(512874002)(229853001)(33646002)(19580405001)(568964002)(76176999)(50986999)(7696003)(5003600100003)(86362001)(19580395003); DIR:OUT; SFP:1101; SCL:1; SRVR:HE1PR08MB0922; H:nebula.arm.com; FPR:; SPF:Pass; PTR:fw-tnat.cambridge.arm.com; MX:1; A:1; LANG:en; X-Microsoft-Exchange-Diagnostics: 1; AM1FFO11FD056; 1:Vwa4BO2QD3EmKBXbq9hzgf+OxZJExdvXkCkDahDct+T7iapsydGVLmcIo8cex/MAZFQ7XrxHHgqQhdFO2FNKCpjQeLR9V9Xf7R4EgRrENGY+qEUH5YceIlenSKtPTLsBXmr72qFFLVyRGuQZ3oKWKPnAbmqkzOg732obk5L+B7nug0lugPoFuW1F8APixotyu+lZsK03liIOG35jwt6CkKZOPUnJFOmXwSfcf4MwOUUo6lJK1Q0dsDdbjcaq8lbyq7RSgeMpCpLSReXNuiNejjkWWzj4/TCqaC27duVVfQ7rbc9jftiTrGihgmZiZvAwlaWBB6AyGtVErStXrF04GO9H5kCJ570sx25ayiQJ9QaTFv0XPw4l1WLC9W2BBBmcn0Vhjm2Vh1ChcW6Gu1g2PVKqfJl4QWKWkSansTF/XKZ/8ekHVFnh/+zI7lv+1hfhOPwQyCWqGdfjaLONDjmv4wUSkKCnKLormHmCZjXxL9QqGf5DXHk86iCMEEOr9ov5TnjInPX6lp/m/EWQX0Uyzrw62XazpKGbVD/4g3nnz92WsFUSyx/AXllNM/0COKD6xpA+yTfmscjZxCclVmiR4Q== X-MS-Office365-Filtering-Correlation-Id: e009cf76-6ac5-4595-8f7d-08d399ebe457 X-Microsoft-Exchange-Diagnostics: 1; HE1PR08MB0922; 2:by5BXMCdXAsVDd95Yj+ssfpEZYSjkSg/tDxgNeVdwrnNaTK35DbtgNppWTfF1YZVlokyE17a2xYmhGR71Csy6OU488TKDVfwxZ+rpWbdOj0PBltDGOTHoUYLnpj+LooaGzWGVjKzdUx/tu92UX/c8F3cpk9Z28fOSThbBV4oHz953a3YOF+QY/429TRbmhxl; 3:MQkVZzdKO/gcc13YSC1ML/k3HKQ7Y+/Mk1/+6WwGECmSjXQyX23ofHK2S9HaBTjURMIewuO9OTH05gyizdi9wcq9qkd4QWIYcz+ELzLc6hTLTWibthZj2i4EtXZrr9OfcAFtyJQAUVeKSX+INdXUk0BlJs2FFPnSQG9X/MoHiRULVvpkDbuIIH6ajyUJuj4vdF9IMeLacUFXP27FbZyOwmf+fSHerV4sl8AHfOwSg92X908ImE0eH339tNIEmdhj58nq+/Rs9tz19KeaBZFr3Q== X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(8251501002); SRVR:HE1PR08MB0922; X-Microsoft-Exchange-Diagnostics: 1; HE1PR08MB0922; 25:FLXjJoNWyqqY6Ze4aood2ME/vbNZO1TtimdiHl1Lrz+cdp/KSasqHFr29TahrwROP8Wlcb9gSbe3MrDVtDEMWv811NcNs7G4EQRdRiciCVwTPTqzGd2MGvPqQTGQ46RljiZ/9/iJQMsTNINk0nMJYWF95iGokWc3vM149PWApqwK8MmWijKUluP+SvX1WZQJUhkFLzUnsurRPx1b8kb8dNnEoWgWmJpvQXilKTChSfmXllFQabr8VnIpBLt/xQnySl+KtHjfBNKosp+yKgsoijSY61nzvKqZc2D9iLzwAZoWQnKZeJRabJvQLP48/WsovcQn/e3OJO5U7jjDQLhuwmoeDv3VXkKK2Z4qe4mfVSymA+nEf9/CNPUT7AhbhGY79u8gmla/Hc4St58yElpBUtmyMYTdM4EhGmWwK3drPfyslVe/U7QKbF6rD/qh+05wTNcCCGogWo25LpB4x9HROhSntzquBSXii+roZ/ZU3HWK9PBkWex+HmnhO5Q0RNVXYBzzImOCvbLrtgKGaGqQLs8kyJEXYd+eO+OsQapHElZd+3JcE569DnpjxUNrqgFgcqDYD8EViE4R3OTbRQli1LzFUJbcptBgatVV/sFPbypsnIomogCntfzYPYZgnh2OzxWhQrnntAPLYMNCfIpL7NG53mBQdm22qk9mjc7IKmi1uReKB7iYdRJoBvDMRWsN5Wq4iJpywbI+YtpIVdjSzJKAZjNxmVfm7oJIkLN3ve75TWefa9m0lx4FpkwwjKx7j6uypR/Lm82wlbGOzZ7s6xAVbHk3UHXRVgUvxv4V5X7yy6+Sg6PXI9f3G2ZbNqePlI9IUwp22qcQNO/F013oJGP8XvOG+E2HhTinZodLMm17YADr7bWnDd4NZwsImZsWP5oiIn8ZSVEjVFZC8c8zPNiKX2QoKtpFfFXKgE94DNU= NoDisclaimer: True X-Microsoft-Exchange-Diagnostics: 1; HE1PR08MB0922; 20:2Eo30HDGQiM2LDhd+NfMVzJdqh9jdpFDyYnf4BVJM4RZvuvp8RO4NadT8E8i82upzbT+HR0FOtgh29Q/P7GAASMD09pcUxqhZ7PUkyovl9e04tMxpkRh7SxlH5qRDGeFkRauNDfne5N5wwQbw7Zb/NtWiJLfIZ7tX4ec8SH8CItXRH+IbuRkyKgu6JCndIafcjlGNjoawC5Q/0IRLSlleMYJuRsfv0dnQdkuILLBTfQlcoe+Q9Cna6fgwQHkYMVJ; 4:JXQHT66vo47VX7c7OGX2HfTQk/7HccWaQN/uGhAgvrCfJLXRdWskGii3fSd0mpFZCX7YyznkedOB7yAK51+Ea/RYuATWDAa8ZBrSIqzwjfcaOXkTFd66sXVEVfSPGZ9v2PtTyvjKK7ce8AAN0vBudTQm2afdzwdU9PphOuSuGmCi6vk7CEhqe/RTwDk3yRCDr/5WRvdh+tyxi3JnpIrV0fEn79jr9/NA1+dWJsxjTIP0RCd5DmCMFmqu5Ot5+niB/KR8NvPb2ZF+S4eyKsUfJ4Tj2dG8rh4suU5TmvoQLilHRb5MLS4ynTciQeAPP2DwCat0tHvg+4tVzX9i2EL09NHtUtJYRUs0S+1O71omLBtNdl++ed5hieWCNol+Ja8n7DTReocoCPTrYYziUu+b4pBD2NQM4wr1KTCu27R3qHQBRmoREuLVJQHROVMJpIVCqooIGRoe8d3Ya9mQm/GBTOaipfxVo/AXehDBSkq6ak4Z9gwg8fioeDhvuR4NAErL0tGFKT9eJRuIacVqh5Nhhw== 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)(13024025)(13013025)(13020025)(13023025)(5005006)(8121501046)(3002001)(10201501046)(6055026); SRVR:HE1PR08MB0922; BCL:0; PCL:0; RULEID:; SRVR:HE1PR08MB0922; X-Forefront-PRVS: 098076C36C X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; HE1PR08MB0922; 23:XDNruVbl9pgglgeUvuoa6hqYHWQQkAjGw2WW3Ia/Q?= =?us-ascii?Q?iVykYqyYfh6gvPINzv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mQg7I+l1wQjjL5jih9FBrRTcXvRrAln9tQ4FPGSV4qON5IrIGeMJigAF7uThYqGsD3yizQvGdCggustrYi6PIn2kzEwV6aixEbUrguiCQ3W0J6r SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; HE1PR08MB0922; 20:Uhgoy/F1s9p65OtWowW2K2Bh+NGaOD6vjtSRERKpPZXXWXe5HMo7+a/rZcShrh6at3ej69XK0j2otAswPTr/OWIdb/53iOXqe+8y0dNvAhUCFy0jLkWEa3uQC9bG9a2KqawAOY3yq+Loz/n6Fn0/9p7DRjFhE6CdyVfCAEQ+C/Y= X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Jun 2016 15:51:21.4183 (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: HE1PR08MB0922 X-MC-Unique: xCWSQ0wiPcKPYJit1wiuGQ-1 X-IsSubscribed: yes Hi, This patch clears up the cost model for noce_try_cmove_arith. We lose the "??? FIXME: Magic number 5" comment, and gain a more realistic cost model for if-converting memory accesses. This is the patch that has the chance to cause the largest behavioural changes for most targets - the current heuristic does not take in to consideration the cost of a conditional move - once we add that the cost of the converted sequence often looks higher than we allowed before. I think that missing the cost of the conditional move from these sequences is not a good idea, and that the cost model should rely on the target giving back good information. A target that finds tests failing after this patch should consider either reducing the cost of a conditional move sequence, or increasing TARGET_MAX_NOCE_IFCVT_SEQ_COST. As this ups the cost of if-convert dramatically, I've used the new parameters to ensure that the tests in the testsuite continue to pass on all targets. Bootstrapped in series on aarch64 and x86-64. OK? Thanks, James --- gcc/ 2016-06-21 James Greenhalgh * ifcvt.c (noce_try_cmove_arith): Check costs after constructing new sequence. gcc/testsuite/ 2016-06-21 James Greenhalgh * gcc.dg/ifcvt-2.c: Use parameter to guide if-conversion heuristics. * gcc.dg/ifcvt-3.c: Use parameter to guide if-conversion heuristics. * gcc.dg/pr68435.c: Use parameter to guide if-conversion heuristics. diff --git a/gcc/ifcvt.c b/gcc/ifcvt.c index f4ad037..78906d3 100644 --- a/gcc/ifcvt.c +++ b/gcc/ifcvt.c @@ -2092,7 +2092,8 @@ noce_try_cmove_arith (struct noce_if_info *if_info) rtx a = if_info->a; rtx b = if_info->b; rtx x = if_info->x; - rtx orig_a, orig_b; + rtx orig_a = a; + rtx orig_b = b; rtx_insn *insn_a, *insn_b; bool a_simple = if_info->then_simple; bool b_simple = if_info->else_simple; @@ -2102,16 +2103,15 @@ noce_try_cmove_arith (struct noce_if_info *if_info) int is_mem = 0; enum rtx_code code; rtx_insn *ifcvt_seq; + bool speed_p = optimize_bb_for_speed_p (if_info->test_bb); /* A conditional move from two memory sources is equivalent to a conditional on their addresses followed by a load. Don't do this early because it'll screw alias analysis. Note that we've already checked for no side effects. */ - /* ??? FIXME: Magic number 5. */ if (cse_not_expected && MEM_P (a) && MEM_P (b) - && MEM_ADDR_SPACE (a) == MEM_ADDR_SPACE (b) - && noce_estimate_conversion_profitable_p (if_info, 5)) + && MEM_ADDR_SPACE (a) == MEM_ADDR_SPACE (b)) { machine_mode address_mode = get_address_mode (a); @@ -2143,25 +2143,6 @@ noce_try_cmove_arith (struct noce_if_info *if_info) if (!can_conditionally_move_p (x_mode)) return FALSE; - unsigned int then_cost; - unsigned int else_cost; - if (insn_a) - then_cost = if_info->then_cost; - else - then_cost = 0; - - if (insn_b) - else_cost = if_info->else_cost; - else - else_cost = 0; - - /* We're going to execute one of the basic blocks anyway, so - bail out if the most expensive of the two blocks is unacceptable. */ - - /* TODO: Revisit cost model. */ - if (MAX (then_cost, else_cost) > if_info->max_seq_cost) - return FALSE; - /* Possibly rearrange operands to make things come out more natural. */ if (reversed_comparison_code (if_info->cond, if_info->jump) != UNKNOWN) { @@ -2353,6 +2334,12 @@ noce_try_cmove_arith (struct noce_if_info *if_info) if (!ifcvt_seq) return FALSE; + /* Check that our cost model will allow the transform. */ + + if (seq_cost (ifcvt_seq, speed_p) > if_info->max_seq_cost) + /* Just return false, the sequence has already been finalized. */ + return FALSE; + emit_insn_before_setloc (ifcvt_seq, if_info->jump, INSN_LOCATION (if_info->insn_a)); if_info->transform_name = "noce_try_cmove_arith"; diff --git a/gcc/testsuite/gcc.dg/ifcvt-2.c b/gcc/testsuite/gcc.dg/ifcvt-2.c index e0e1728..73e0dcc 100644 --- a/gcc/testsuite/gcc.dg/ifcvt-2.c +++ b/gcc/testsuite/gcc.dg/ifcvt-2.c @@ -1,5 +1,5 @@ /* { dg-do compile { target aarch64*-*-* x86_64-*-* } } */ -/* { dg-options "-fdump-rtl-ce1 -O2" } */ +/* { dg-options "-fdump-rtl-ce1 -O2 --param max-rtl-if-conversion-unpredictable-cost=100" } */ typedef unsigned char uint8_t; diff --git a/gcc/testsuite/gcc.dg/ifcvt-3.c b/gcc/testsuite/gcc.dg/ifcvt-3.c index 44233d4..b250bc1 100644 --- a/gcc/testsuite/gcc.dg/ifcvt-3.c +++ b/gcc/testsuite/gcc.dg/ifcvt-3.c @@ -1,5 +1,5 @@ /* { dg-do compile { target { { aarch64*-*-* i?86-*-* x86_64-*-* } && lp64 } } } */ -/* { dg-options "-fdump-rtl-ce1 -O2" } */ +/* { dg-options "-fdump-rtl-ce1 -O2 --param max-rtl-if-conversion-unpredictable-cost=100" } */ typedef long long s64; diff --git a/gcc/testsuite/gcc.dg/pr68435.c b/gcc/testsuite/gcc.dg/pr68435.c index 765699a..f86b7f8 100644 --- a/gcc/testsuite/gcc.dg/pr68435.c +++ b/gcc/testsuite/gcc.dg/pr68435.c @@ -1,5 +1,5 @@ /* { dg-do compile { target aarch64*-*-* x86_64-*-* } } */ -/* { dg-options "-fdump-rtl-ce1 -O2 -w" } */ +/* { dg-options "-fdump-rtl-ce1 -O2 -w --param max-rtl-if-conversion-unpredictable-cost=100" } */ typedef struct cpp_reader cpp_reader; enum cpp_ttype