From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 1737 invoked by alias); 21 Jun 2016 15:51:45 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Received: (qmail 1629 invoked by uid 89); 21 Jun 2016 15:51:44 -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=ham version=3.3.2 spammy=iff, powerpc***, powerpc*-*-* 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:33 +0000 Received: from emea01-am1-obe.outbound.protection.outlook.com (mail-am1lrp0013.outbound.protection.outlook.com [213.199.154.13]) (Using TLS) by eu-smtp-1.mimecast.com with ESMTP id uk-mta-73-dk_1XTlrP7-T1gxWmAQUwg-1; Tue, 21 Jun 2016 16:51:26 +0100 Received: from AM4PR08CA0027.eurprd08.prod.outlook.com (10.166.127.37) by DB5PR08MB0679.eurprd08.prod.outlook.com (10.169.33.17) with Microsoft SMTP Server (TLS) id 15.1.523.12; Tue, 21 Jun 2016 15:51:24 +0000 Received: from AM1FFO11FD056.protection.gbl (2a01:111:f400:7e00::178) by AM4PR08CA0027.outlook.office365.com (2603:10a6:200:1a::37) with Microsoft SMTP Server (TLS) id 15.1.523.12 via Frontend Transport; Tue, 21 Jun 2016 15:51:24 +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:24 +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:10 +0100 From: James Greenhalgh To: CC: , , , , , , Subject: [RFC: Patch 5/6 v2] Improve the cost model for multiple-sets Date: Tue, 21 Jun 2016 15:51:00 -0000 Message-ID: <1466524231-17412-5-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)(377424004)(199003)(189002)(50226002)(36756003)(8936002)(568964002)(11100500001)(2351001)(7846002)(7696003)(5003600100003)(106466001)(87936001)(76176999)(2906002)(50986999)(26826002)(229853001)(5000100001)(4326007)(84326002)(86362001)(92566002)(189998001)(77096005)(4610100001)(2476003)(246002)(8676002)(6806005)(33646002)(110136002)(104016004)(19580395003)(356003)(512874002)(5890100001)(2950100001)(586003)(19580405001);DIR:OUT;SFP:1101;SCL:1;SRVR:DB5PR08MB0679;H:nebula.arm.com;FPR:;SPF:Pass;PTR:fw-tnat.cambridge.arm.com;A:1;MX:1;LANG:en; X-Microsoft-Exchange-Diagnostics: 1;AM1FFO11FD056;1:vLb7+DGAnkaKYZSi59ykqsxDwNo7KR6+siV2yWI8ZTJFp/XNlbAPAYbhIVugCD52kaoB2/DhtAz+lfjE0xspvkyoKHPn2JWTSdHHPltsxP1/f441QZdQ9KMCvtXzCZHpNBpiSj2S3FScDZHJ3z/rHAg5hnUjHLY9oZDQYN19GyQxnwTxXzXLBtUo4fGSgFfBhlO/2bKzZfM8aiEFiLVqqjN1lTD9/i2lqbDzJMTq73MOVd28KuT9/ck4JmrZtsYIq9D4V/3psOkGnZYsjsnmasg3Fn4G66IMzMkPNTXAsAgYofQsCPRozm/Dxmypd9tDp5JtmFTi09c2VQwuyZkL7qCHiRMPNwnS6w6cV1uv0IeBW8nfK+2Tntn3XM4ZNJRcFuoBcj7LKuD0kT9uiKtlOgJ9tNC75dCBMqwjs2D9SQvGfABV1tkJ6Mo96hLcAvhBQMAGkErj5hNiKB4SHtcqm9tIcSmEvsICgS+F/JZAKbVy1tZG1yFRNvDdp5fluMWpSWR7df44yBDHGIwStcofR5GfjQ3JfMS9pIEYy5e+wkLOA9fQchLnAAS+lQdt0Ws/AXZteftFwUWY48XzbTJGxw== X-MS-Office365-Filtering-Correlation-Id: 44816225-98dd-4b0a-58b9-08d399ebe625 X-Microsoft-Exchange-Diagnostics: 1;DB5PR08MB0679;2:6B+FFn5u4WJrY/rCle9P6lDgZxp2soKIzRaOn2VMqy5KoasHm4LcfweT3tghMvDeYdEM2BVOXlcCt+4CWsZIyrfhcWtPBTm75PNXDi/Cm8XqC0YkJJdqJTeHiHua++OmjL4Lczr0ibpRq9C3i9e/MdAgBujmzyrBGlm/FJH2OsWZ4TrX3JDO4RlMSutHNHna;3:oJqXlv8cvUV7PMA0OVKk1wQoil2a5q+B1pAMLw55aEPfmFoONzdF7p4plgxtCi32oW2M0qoTVKcVHZB0EovM5GFLQm3N9Yq8FVLGPC1zS06dwL/GWyPlMWxUDwO7Afomi75XAg823vlKxAcwkgr/kicaisarGMdX9P7Mcc1wLFPa3GSnnt+qsgSnScPquIAHGQKanoI4t86h3hBaWpAeUdhtHTpcvlUxtb+GF6fMXTkfkdoTrlHBDI3swj38emKPT9fqqyeSB1J7vR4c/4t0/g== X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:(8251501002);SRVR:DB5PR08MB0679; X-Microsoft-Exchange-Diagnostics: 1;DB5PR08MB0679;25:FPJSRm3J6ITbp5T0qYtHdLwDlIg4QI6Ok67cwzZpjy4kge9f0CBH66jmzsg3YfPR6vc076W9lwII4fETtdymkoqSyVzTmWyNKPdSvPXb2OjtlIKwmlExxlndWLgbpfpWYfu7pZLMa+lvPXynWnxdqRDbF30/tyzK7moD3+XERvdPJa8lx+WqlA2nx8cQqVm34tmsVEJXeQroKePVp/CH9WNhn6TI8IFOs72u70JBj/gr9LLlH8cIpaIdypPfOdNNFG8hsSzOVrGjwK6hVsyJ/KauHpIbqADeztNAIWkfgEwUXbmg8+0DB8K06MiXyvTdSDkFaUIF4N7Uvo5RHkx4MbcCCoNSam5mcv4esyaYFVqTDaGeLQjigXGg/ObNHSn5Z4NOkmZg/QwnKthxvDTV5jcLkOqNl/GLY3xUOsIu+cCFhlxmI8Ta1TSxMHUm5Fm2ORkZLz2ld1CGFv/hn7cwWBUSJzI8dsTegREx2+dnPoEqC2YiSQIZFixxCK7U/jWM;20:Ampgnzrhde+4m0BB7DLOzrqLFjUeco8IH2Ilt2cfayFBXG4NXQ7X8EjmjK36KA+hsm1brQTk5WDk8h8pwJ+6hrL7sbQ+hyfksq0XVLoCylX3r/x6f1WzS6UfXRMRTxizrPFYIq2SGEDR0Q8//kJHtzhlKxCPyhrnXLwy/AaFI81M5uPkqxY71u/8b5zC8SpbDSpI4P0TKZ/0CDVLz0O0rkl9W9OdhaQy+3YiLU+px1Vmiff1Ok1grRDB0Q83heBk 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)(13020025)(8121501046)(13023025)(5005006)(13024025)(13013025)(3002001)(10201501046)(6055026);SRVR:DB5PR08MB0679;BCL:0;PCL:0;RULEID:;SRVR:DB5PR08MB0679; X-Microsoft-Exchange-Diagnostics: 1;DB5PR08MB0679;4:Em7HTyQ0Y1vUe+eIP9AihsbjANmyjYm2jul3d3oseMpC0DhuNO+WxNckm6G9coXOKHS4iGQY8qMYyH07Ll01A2cYrWftMFl5BfWF1xJBlZDXhOwVB+Ve5Uincf9umiMNI5RkZyXhyHYMpVuDDwu6EP0S2K/kl7ScCcx6Et1flj3wZg40l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yaRxjPQsZcs66LU8LVVN5OVHM3nj1LvIedU8Tx9UQCq74tsXSwVnC2kDDKg0qu4hs7qR7mZb0F+4z76+5+g==;5:3W3DV/hvA9iF53ZYYpgkxvsLLCPytLDDsYOFqOFxL8t8oJGkcLY2/afjYSG44OYQaGJOY+ElbruGLqmNu++iaNRXqsjb7gYpf1ksGDEuua42K5czf3C0Yeh82ZmJD+2J2fdG/l0Tb0u2Is0sl+GS2Q==;24:pY3uvHC3dxsdNiuPqjsGH6oxkucitdL8EfIbkCYiUGELsq30mvGVKPr2UHF9RSIrb/CpTKwOFhy6LRO4KiYD3yS3v7mIhbiUNEAl5zruO9o=;7:pJom5/vPEzTmTypPTOpAKe680PZklbd+PSBd8hK3MOU+Z5Cg3FuuHDoZIhj735Vf1mffyTWcUHsxoB29ZEJumP0bbyEsGl0cMRhOHp1a6Mb9N7cjs4f0ErkfyjXGrS9a4LJFJQR98cZuGa15LQFHYSYEHop+EcD3cFjIARkpSQ3BxLNQGK+8Mgbw00iRo5nFKtnquCDzKV9Zrok+46+KjaDoyN2BZWa3WjvUMkfRdLIZVALfvOq1N7zO+SVAccvL SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1;DB5PR08MB0679;20:QOmTyJQpNjZ4R8lQnyWUcJP4rbBf1k8Hih/b5LkvpsM4mDIkS5EKvrFbkxIS8HWMuoES3VqBHSjccrmD8YpX3tQnl43Y+ZoR65QABOIk4DyQeS6zy4DAyuUMysZbJX5hGN3pl7RBNEVdGuWsjh9L30qOBDG5qvU33yeArX+ZFN8= X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Jun 2016 15:51:24.4447 (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: DB5PR08MB0679 X-MC-Unique: dk_1XTlrP7-T1gxWmAQUwg-1 Content-Type: multipart/mixed; boundary="------------2.6.4.2.gae996d8" X-IsSubscribed: yes X-SW-Source: 2016-06/txt/msg01511.txt.bz2 --------------2.6.4.2.gae996d8 Content-Type: text/plain; charset=UTF-8; format=fixed Content-Transfer-Encoding: quoted-printable Content-length: 826 Hi, This patch is rewrites the cost model for bb_ok_for_noce_multiple_sets to use the max_seq_cost heuristic added in earlier patch revisions. As with the previous patch, I've used the new parameters to ensure that the testsuite is still testing the functionality rather than relying on the target setting the costs appropriately. Thanks, James --- gcc/ 2016-06-21 James Greenhalgh * ifcvt.c (noce_convert_multiple sets): Move cost model to here, check the sequence cost after constructing the converted sequence. (bb_of_for_noce_convert_multiple_sets): Move cost model. gcc/testsuite/ 2016-06-21 James Greenhalgh * gcc.dg/ifcvt-4.c: Use parameter to guide if-conversion heuristics. * gcc.dg/ifcvt-5.c: Use parameter to guide if-conversion heuristics. --------------2.6.4.2.gae996d8 Content-Type: text/x-patch; name=0005-RFC-Patch-5-6-v2-Improve-the-cost-model-for-multiple.patch Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="0005-RFC-Patch-5-6-v2-Improve-the-cost-model-for-multiple.patch" Content-length: 4715 diff --git a/gcc/ifcvt.c b/gcc/ifcvt.c index 78906d3..8f892b0 100644 --- a/gcc/ifcvt.c +++ b/gcc/ifcvt.c @@ -3191,6 +3191,7 @@ noce_convert_multiple_sets (struct noce_if_info *if_i= nfo) rtx_insn *jump =3D if_info->jump; rtx_insn *cond_earliest; rtx_insn *insn; + bool speed_p =3D optimize_bb_for_speed_p (if_info->test_bb); =20 start_sequence (); =20 @@ -3273,9 +3274,17 @@ noce_convert_multiple_sets (struct noce_if_info *if_= info) for (int i =3D 0; i < count; i++) noce_emit_move_insn (targets[i], temporaries[i]); =20 - /* Actually emit the sequence. */ + /* Actually emit the sequence if it isn't too expensive. */ rtx_insn *seq =3D get_insns (); =20 + /* Check the cost model to ensure this is profitable. */ + if (seq_cost (seq, speed_p) + > if_info->max_seq_cost) + { + end_sequence (); + return FALSE; + } + for (insn =3D seq; insn; insn =3D NEXT_INSN (insn)) set_used_flags (insn); =20 @@ -3325,23 +3334,16 @@ noce_convert_multiple_sets (struct noce_if_info *if= _info) =20 /* 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->max_seq_cost now guides the maximum number of set instructions in - a basic block which is considered profitable to completely - if-convert. */ + of conditional moves. Also check that we have more than one set + (other routines can handle a single set better than we would), and + fewer than PARAM_MAX_RTL_IF_CONVERSION_INSNS sets. */ =20 static bool -bb_ok_for_noce_convert_multiple_sets (basic_block test_bb, - struct noce_if_info *ii) +bb_ok_for_noce_convert_multiple_sets (basic_block test_bb) { rtx_insn *insn; unsigned count =3D 0; unsigned param =3D PARAM_VALUE (PARAM_MAX_RTL_IF_CONVERSION_INSNS); - /* TODO: Revisit this cost model. */ - unsigned limit =3D MIN (ii->max_seq_cost / COSTS_N_INSNS (1), param); =20 FOR_BB_INSNS (test_bb, insn) { @@ -3377,14 +3379,15 @@ bb_ok_for_noce_convert_multiple_sets (basic_block t= est_bb, if (!can_conditionally_move_p (GET_MODE (dest))) return false; =20 - /* 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++; } =20 - 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. + Some targets want to strictly limit the number of conditional moves + that are emitted, they set this through PARAM, we need to respect + that. */ + return count > 1 && count <=3D param; } =20 /* Given a simple IF-THEN-JOIN or IF-THEN-ELSE-JOIN block, attempt to conv= ert @@ -3420,7 +3423,7 @@ noce_process_if_block (struct noce_if_info *if_info) if (!else_bb && HAVE_conditional_move && !HAVE_cc0 - && bb_ok_for_noce_convert_multiple_sets (then_bb, if_info)) + && bb_ok_for_noce_convert_multiple_sets (then_bb)) { if (noce_convert_multiple_sets (if_info)) { diff --git a/gcc/testsuite/gcc.dg/ifcvt-4.c b/gcc/testsuite/gcc.dg/ifcvt-4.c index 319b583..0d1671c 100644 --- a/gcc/testsuite/gcc.dg/ifcvt-4.c +++ b/gcc/testsuite/gcc.dg/ifcvt-4.c @@ -1,4 +1,4 @@ -/* { dg-options "-fdump-rtl-ce1 -O2 --param max-rtl-if-conversion-insns=3D= 3" } */ +/* { dg-options "-fdump-rtl-ce1 -O2 --param max-rtl-if-conversion-insns=3D= 3 --param max-rtl-if-conversion-unpredictable-cost=3D100" } */ /* { dg-additional-options "-misel" { target { powerpc*-*-* } } } */ /* { dg-skip-if "Multiple set if-conversion not guaranteed on all subtarge= ts" { "arm*-*-* hppa*64*-*-* visium-*-*" } } */ =20 diff --git a/gcc/testsuite/gcc.dg/ifcvt-5.c b/gcc/testsuite/gcc.dg/ifcvt-5.c index 818099a..d2a9476 100644 --- a/gcc/testsuite/gcc.dg/ifcvt-5.c +++ b/gcc/testsuite/gcc.dg/ifcvt-5.c @@ -1,7 +1,8 @@ /* Check that multi-insn if-conversion is not done if the override - parameter would not allow it. */ + parameter would not allow it. Set the cost parameter very high + to ensure that the limiting factor is actually the count parameter. */ =20 -/* { dg-options "-fdump-rtl-ce1 -O2 --param max-rtl-if-conversion-insns=3D= 1" } */ +/* { dg-options "-fdump-rtl-ce1 -O2 --param max-rtl-if-conversion-insns=3D= 1 --param max-rtl-if-conversion-unpredictable-cost=3D200" } */ =20 typedef int word __attribute__((mode(word))); =20 --------------2.6.4.2.gae996d8--