From patchwork Fri Apr 21 10:41:13 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Greenhalgh X-Patchwork-Id: 753267 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3w8XNn2T9tz9rxl for ; Fri, 21 Apr 2017 20:41:58 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="NDCYsqSN"; dkim-atps=neutral DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:date :from:to:cc:subject:message-id:references:mime-version :content-type:in-reply-to; q=dns; s=default; b=HLBCydhXQRoEcqEnA O3f2BOz+Cyk4cVaKN15hnD96Oo04+xqpjVEM8bCrsXJW3T+6zyxyuXXct9mHEpYj uzQZtCIO8TPGMNeg12IudwY5WDmBcr1I8ye8pIGmpeYSO6wTLY6U1APEdJNiZUO+ YifXQ6hwqWdaabqafgFapBRe7A= 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:date :from:to:cc:subject:message-id:references:mime-version :content-type:in-reply-to; s=default; bh=AUItziC8A5WuWneUVoMhbFl VcDM=; b=NDCYsqSNhoCJSQe0NIuv0u4WZwLUd308oL21Lu0Rrbvf/DYXd4dUtd7 yp7WfkpjgX2C8EaCvNdDJgngI35afqqVJWkHbtzn2no8so5d2PwCQdPQzxYiVkRS gpUQTgbaCeY1phC4VHV5v7kjZUgHmSOz0FIqzvRgD+GkZIgH0g1s= Received: (qmail 5367 invoked by alias); 21 Apr 2017 10:41:41 -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 5287 invoked by uid 89); 21 Apr 2017 10:41:38 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-24.4 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_HELO_PASS, SPF_PASS autolearn=ham version=3.3.2 spammy=james.greenhalgh@arm.com, sk:james.g, HX-Exchange-Antispam-Report-Test:180628864354917, H*r:10.1.2 X-HELO: EUR02-HE1-obe.outbound.protection.outlook.com Received: from mail-eopbgr10082.outbound.protection.outlook.com (HELO EUR02-HE1-obe.outbound.protection.outlook.com) (40.107.1.82) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 21 Apr 2017 10:41:35 +0000 Received: from VI1PR0802CA0013.eurprd08.prod.outlook.com (10.172.253.151) by VI1PR0801MB1981.eurprd08.prod.outlook.com (10.173.74.14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1034.10; Fri, 21 Apr 2017 10:41:31 +0000 Received: from VE1EUR03FT054.eop-EUR03.prod.protection.outlook.com (2a01:111:f400:7e09::205) by VI1PR0802CA0013.outlook.office365.com (2603:10a6:800:aa::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1047.13 via Frontend Transport; Fri, 21 Apr 2017 10:41:31 +0000 Authentication-Results: spf=pass (sender IP is 217.140.96.140) smtp.mailfrom=arm.com; gmail.com; dkim=none (message not signed) header.d=none; gmail.com; dmarc=bestguesspass action=none header.from=arm.com; Received-SPF: Pass (protection.outlook.com: domain of arm.com designates 217.140.96.140 as permitted sender) receiver=protection.outlook.com; client-ip=217.140.96.140; helo=nebula.arm.com; Received: from nebula.arm.com (217.140.96.140) by VE1EUR03FT054.mail.protection.outlook.com (10.152.19.64) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA_P384) id 15.1.1019.14 via Frontend Transport; Fri, 21 Apr 2017 10:41:31 +0000 Received: from arm.com (10.1.2.79) by mail.arm.com (10.1.105.66) with Microsoft SMTP Server id 14.3.294.0; Fri, 21 Apr 2017 11:41:13 +0100 Date: Fri, 21 Apr 2017 11:41:13 +0100 From: James Greenhalgh To: Bill Schmidt CC: GCC Patches , Richard Biener , Subject: Re: [PATCH] Fix PR80457 Message-ID: <20170421104113.GA8839@arm.com> References: <507725db-45cf-e734-095d-2225087c53a8@linux.vnet.ibm.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <507725db-45cf-e734-095d-2225087c53a8@linux.vnet.ibm.com> User-Agent: Mutt/1.5.21 (2010-09-15) 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)(39850400002)(39860400002)(39450400003)(39840400002)(39410400002)(39400400002)(2980300002)(438002)(199003)(189002)(54534003)(24454002)(377424004)(39060400002)(38730400002)(229853002)(305945005)(5890100001)(86362001)(106466001)(110136004)(2906002)(33656002)(77096006)(260700001)(2950100002)(4610100001)(4001350100001)(36756003)(1076002)(84326002)(2476003)(104016004)(6246003)(7696004)(5660300001)(568964002)(512954002)(6916009)(76176999)(189998001)(8676002)(50986999)(8936002)(6286002)(4326008)(54356999)(54906002)(356003)(83506001)(55016002)(18370500001)(2700100001); DIR:OUT; SFP:1101; SCL:1; SRVR:VI1PR0801MB1981; H:nebula.arm.com; FPR:; SPF:Pass; MLV:ovrnspm; A:1; MX:1; PTR:fw-tnat.cambridge.arm.com; LANG:en; X-Microsoft-Exchange-Diagnostics: 1; VE1EUR03FT054; 1:erK6dwx/Fun6q57FrLTxVIum+zt35FjjFtjoJC37eXcZbJ1ZW7MpF2s57/xi0/C8LEwowEYxdPLZX3OtOJ8ZmmdYYdaWSRk99amWaGFsGk/KmvYniXH0guP+PAY9mProWPzJ6Pljq/PDLBXre0Yq3nlKbmqhQRl28/Q+6lt5jZvUtX1s6vNycLsmFNvWt9zMd0SqtMJ5DaTUoD6CaUgIfCLk+GxP6GkUkeuXQBwy3HkcwqvN4gyP4/95RoQszUVm5xLtGm+xcPJweitZlxdgF8Byu5BXHrUgEJyhX/2OrYzebLf543UAEUkAH8fXxu8LZIQhO/E+RMvP2yH8P7kQ2HutBIcxMwVg2U9nAUh1pVZ4wXPA4XPrEiHvsRU7/JZHrXBuU3MESzJydXWZoCyFQQZmKJBd9EBVQ/tnXh5SEudeVbnIAXl4S9VwsDR8n5IGlV0UpQgXYDw2VMvCxrGsQK+XgagkWi5txbsDKhI8IUjHj6jjKb7lEE+tkROVB9lFTsNvNbb7LNyI8phVtfe1dAOTLFEtY3ZKOtLsk0e5siJetMAZDrCkiIFG8nvJYgdSMJ0tH9uhyHngyGLvsvOWdLVQwjKeNFSZAbnRnlMjBkprQG2WTnNzFDQ9pG9H2U98 X-MS-Office365-Filtering-Correlation-Id: 7be95835-4f9f-4b0e-7554-08d488a2f989 X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(22001)(8251501002)(2017030254075)(201703131423075)(201703031133081); SRVR:VI1PR0801MB1981; X-Microsoft-Exchange-Diagnostics: 1; VI1PR0801MB1981; 3:pCm2bv8w1fipFyv0fP8CvEhwRA5WzKXw60DQlTjVxk6wVPKwGlIX3ENG4agv96yRInGFMwjef1UnFd1cgiDmHccsIXd7Cm71Moy5zMF5kDtJwMwP7mpvj8WzEckO/s5PSz89x8RVRUb7nf5UOFNtBdzvRqZRGQxY/LI78Ij1Gbrpj/9l8g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EF/4lCuxLB8FLTRTIPmdMWbZ+wdTUBg+SBWPIFsgKrP/I5mm9MV+0Kud9AdOBdvdO+YJTsTlMgHSdV1NR4WvBP3bxMabfh174g4eU2e4Mzx2t2XzXBBX/PabXBvvl9WEXHSCs/zcr0uc4rdnDwFUxuZ5K2eKNjYYpC+t5x13/Q== NoDisclaimer: True X-Microsoft-Exchange-Diagnostics: 1; VI1PR0801MB1981; 20:vdPZSlue43OKHtsBf1gk95Axjg+gDhhebQqhb9WOzsOAzSDpMRmYzFKwr0H5tt6yjtPmmwd8f3fBJ09CFNyj9YVa9QxhKs0X7X1eM/UWKOOMdEictKVInSKW14IiAny9s2SzI7IuKBpg1LcSgIav44M4E5a3hUxoVPo53hgFjNncBlao9Qb5hYUQ5cuB18lTJOksOYRQKu6V0JUAMcSIvk3lhHSqhM4Dks+U04mCm/lANLPXYsV3Q6VvOg8pKkpR X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(180628864354917); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(102415395)(6040450)(601004)(2401047)(13013025)(5005006)(8121501046)(13023025)(13024025)(13020025)(93006095)(93004095)(3002001)(10201501046)(6055026)(6041248)(20161123564025)(20161123562025)(20161123560025)(201703131423075)(201703011903075)(201702281528075)(201703061421075)(20161123555025)(6072148); SRVR:VI1PR0801MB1981; BCL:0; PCL:0; RULEID:; SRVR:VI1PR0801MB1981; X-Microsoft-Exchange-Diagnostics: 1; VI1PR0801MB1981; 4:nNkmwNBmdpK0/qXSXMKJ0iYh6mtSz4/61O2xioZurcY0s74HB71QyKeEDUdOXDCBwYsFB3j2URJmHQIC0C29agIu7H8PeYLu6Gzh63RHVFvFhyyDUhACbXyaI+0cPm+AQPORB3I44Rblgj4c7jrp2yqY1pvxNEmkBlZZjAt6/rbzC6WYkAV/q0VLDzoRGhYX/tKY1mk6sUjQx0lFXjTAajMMv9jHxEsuXgKXuW6t9eO3R2Pn5gyyKWMbuhYH7IMD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H4AB3bcF7k10G7UkPYwROkbycs6nmSD4= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; VI1PR0801MB1981; 7:x8jyNUc8F3Iyrh8YGoC8HvVJK71AQXaLn+JEzCk9gwGZjCeU5zP1O4fmgZUz+3yCs28FqAnPVKlJY4T/CSHWL3ZPqC9Zwq1SULgaAFZkTTqjDNTCVCrkC//9Pn0RlYnKpnrQ7ucV2XyYUYFZ4U1B8H92U+il4V2H1DebyvNaV/QHEdaLmrtOFxc9HzGqOWaQFu+cWJqErC6XOoEPHEGCUZiDQ33O+kGdPGstbJEFIMrM9q7uNCEpgJKs0qe3ABcCFehICUK8/ZXQwQzKqwxNm9JWFriiB7ymUPRhOoqFprsP27lo0WpD/qnNUWt7FjpXB2WmSqLH/NgqEVQ/v/28/w== X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Apr 2017 10:41:31.5572 (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: VI1PR0801MB1981 X-IsSubscribed: yes On Tue, Apr 18, 2017 at 05:38:48PM -0500, Bill Schmidt wrote: > Hi, > > While investigating a performance issue, I happened to notice that vectorized > COND_EXPRs were not contributing to the vectorizer cost model. This patch > addresses that. > > Bootstrapped and tested on powerpc64le-unknown-linux-gnu. Is this ok for > trunk, or should it wait for GCC 8? Hi Bill, I had a similar patch sitting in my tree waiting for GCC 8, with a few differences. The main one is that you don't record the cost of the vector conditional itself, only of the then/else branches. I've attached what I was working on. In my patch I first generalize vect_model_simple_cost to fix the FORNOW: Assuming maximum 2 args per stmts, and to cost the broadcast as a broadcast rather than a vector statiement as the conditionals need a judgement on the prologue cost of 4 args. That means taking an extra argument for the number of arguments a statement needs to cost which in turn means updating the rest of the functions which call vect_model_simple_cost. I haven't hacked on the vector cost model before, and your patch acheieves the main part of what I was looking to do, but if you think any parts of this are still valuable after your change, I'd be happy to rebase it once the branch opens. My patch was bootstrapped and tested on aarch64-none-linux-gnu with no issues, with a ChangeLog which looks like: gcc/ 2017-04-21 James Greenhalgh * tree-vect-stmts.c (vect_model_simple_cost): Model the cost of all arguments to a statement as scalar_to_vec operations. (vectorizable_call): Adjust call to vect_model_simple_cost for new parameter. (vectorizable_conversion): Likewise. (vectorizable_assignment): Likewise. (vectorizable_shift): Likewise. (vectorizable_operation): Likewise. (vectorizable_comparison): Likewise. (vect_is_simple_cond): Record the def types for operands. (vectorizable_condition): Likewise, call vect_model_simple_cost. * tree-vectorizer.h (vect_model_simple_cost): Add new parameter for statement argument count. Thanks, James diff --git a/gcc/tree-vect-stmts.c b/gcc/tree-vect-stmts.c index bfb7185..4b6f337 100644 --- a/gcc/tree-vect-stmts.c +++ b/gcc/tree-vect-stmts.c @@ -801,6 +801,7 @@ vect_mark_stmts_to_be_vectorized (loop_vec_info loop_vinfo) void vect_model_simple_cost (stmt_vec_info stmt_info, int ncopies, enum vect_def_type *dt, + int ndts, stmt_vector_for_cost *prologue_cost_vec, stmt_vector_for_cost *body_cost_vec) { @@ -811,10 +812,12 @@ vect_model_simple_cost (stmt_vec_info stmt_info, int ncopies, if (PURE_SLP_STMT (stmt_info)) return; - /* FORNOW: Assuming maximum 2 args per stmts. */ - for (i = 0; i < 2; i++) + /* Cost the "broadcast" of a scalar operand in to a vector operand. + Use scalar_to_vec to cost the broadcast, as elsewhere in the vector + cost model. */ + for (i = 0; i < ndts; i++) if (dt[i] == vect_constant_def || dt[i] == vect_external_def) - prologue_cost += record_stmt_cost (prologue_cost_vec, 1, vector_stmt, + prologue_cost += record_stmt_cost (prologue_cost_vec, 1, scalar_to_vec, stmt_info, 0, vect_prologue); /* Pass the inside-of-loop statements to the target-specific cost model. */ @@ -2599,6 +2602,7 @@ vectorizable_call (gimple *gs, gimple_stmt_iterator *gsi, gimple **vec_stmt, gimple *def_stmt; enum vect_def_type dt[3] = {vect_unknown_def_type, vect_unknown_def_type, vect_unknown_def_type}; + int ndts = 3; gimple *new_stmt = NULL; int ncopies, j; vec vargs = vNULL; @@ -2804,7 +2808,7 @@ vectorizable_call (gimple *gs, gimple_stmt_iterator *gsi, gimple **vec_stmt, if (dump_enabled_p ()) dump_printf_loc (MSG_NOTE, vect_location, "=== vectorizable_call ===" "\n"); - vect_model_simple_cost (stmt_info, ncopies, dt, NULL, NULL); + vect_model_simple_cost (stmt_info, ncopies, dt, ndts, NULL, NULL); if (ifn != IFN_LAST && modifier == NARROW && !slp_node) add_stmt_cost (stmt_info->vinfo->target_cost_data, ncopies / 2, vec_promote_demote, stmt_info, 0, vect_body); @@ -4023,6 +4027,7 @@ vectorizable_conversion (gimple *stmt, gimple_stmt_iterator *gsi, tree new_temp; gimple *def_stmt; enum vect_def_type dt[2] = {vect_unknown_def_type, vect_unknown_def_type}; + int ndts = 2; gimple *new_stmt = NULL; stmt_vec_info prev_stmt_info; int nunits_in; @@ -4301,7 +4306,7 @@ vectorizable_conversion (gimple *stmt, gimple_stmt_iterator *gsi, if (code == FIX_TRUNC_EXPR || code == FLOAT_EXPR) { STMT_VINFO_TYPE (stmt_info) = type_conversion_vec_info_type; - vect_model_simple_cost (stmt_info, ncopies, dt, NULL, NULL); + vect_model_simple_cost (stmt_info, ncopies, dt, ndts, NULL, NULL); } else if (modifier == NARROW) { @@ -4610,7 +4615,8 @@ vectorizable_assignment (gimple *stmt, gimple_stmt_iterator *gsi, loop_vec_info loop_vinfo = STMT_VINFO_LOOP_VINFO (stmt_info); tree new_temp; gimple *def_stmt; - enum vect_def_type dt[2] = {vect_unknown_def_type, vect_unknown_def_type}; + enum vect_def_type dt[1] = {vect_unknown_def_type}; + int ndts = 1; int ncopies; int i, j; vec vec_oprnds = vNULL; @@ -4710,7 +4716,7 @@ vectorizable_assignment (gimple *stmt, gimple_stmt_iterator *gsi, if (dump_enabled_p ()) dump_printf_loc (MSG_NOTE, vect_location, "=== vectorizable_assignment ===\n"); - vect_model_simple_cost (stmt_info, ncopies, dt, NULL, NULL); + vect_model_simple_cost (stmt_info, ncopies, dt, ndts, NULL, NULL); return true; } @@ -4822,6 +4828,7 @@ vectorizable_shift (gimple *stmt, gimple_stmt_iterator *gsi, machine_mode optab_op2_mode; gimple *def_stmt; enum vect_def_type dt[2] = {vect_unknown_def_type, vect_unknown_def_type}; + int ndts = 2; gimple *new_stmt = NULL; stmt_vec_info prev_stmt_info; int nunits_in; @@ -5080,7 +5087,7 @@ vectorizable_shift (gimple *stmt, gimple_stmt_iterator *gsi, if (dump_enabled_p ()) dump_printf_loc (MSG_NOTE, vect_location, "=== vectorizable_shift ===\n"); - vect_model_simple_cost (stmt_info, ncopies, dt, NULL, NULL); + vect_model_simple_cost (stmt_info, ncopies, dt, ndts, NULL, NULL); return true; } @@ -5196,6 +5203,7 @@ vectorizable_operation (gimple *stmt, gimple_stmt_iterator *gsi, gimple *def_stmt; enum vect_def_type dt[3] = {vect_unknown_def_type, vect_unknown_def_type, vect_unknown_def_type}; + int ndts = 3; gimple *new_stmt = NULL; stmt_vec_info prev_stmt_info; int nunits_in; @@ -5407,7 +5415,7 @@ vectorizable_operation (gimple *stmt, gimple_stmt_iterator *gsi, if (dump_enabled_p ()) dump_printf_loc (MSG_NOTE, vect_location, "=== vectorizable_operation ===\n"); - vect_model_simple_cost (stmt_info, ncopies, dt, NULL, NULL); + vect_model_simple_cost (stmt_info, ncopies, dt, ndts, NULL, NULL); return true; } @@ -7659,15 +7667,16 @@ vectorizable_load (gimple *stmt, gimple_stmt_iterator *gsi, gimple **vec_stmt, Output: *COMP_VECTYPE - the vector type for the comparison. + *DTS - The def types for the arguments of the comparison Returns whether a COND can be vectorized. Checks whether condition operands are supportable using vec_is_simple_use. */ static bool -vect_is_simple_cond (tree cond, vec_info *vinfo, tree *comp_vectype) +vect_is_simple_cond (tree cond, vec_info *vinfo, + tree *comp_vectype, enum vect_def_type *dts) { tree lhs, rhs; - enum vect_def_type dt; tree vectype1 = NULL_TREE, vectype2 = NULL_TREE; /* Mask case. */ @@ -7676,7 +7685,7 @@ vect_is_simple_cond (tree cond, vec_info *vinfo, tree *comp_vectype) { gimple *lhs_def_stmt = SSA_NAME_DEF_STMT (cond); if (!vect_is_simple_use (cond, vinfo, &lhs_def_stmt, - &dt, comp_vectype) + &dts[0], comp_vectype) || !*comp_vectype || !VECTOR_BOOLEAN_TYPE_P (*comp_vectype)) return false; @@ -7692,21 +7701,25 @@ vect_is_simple_cond (tree cond, vec_info *vinfo, tree *comp_vectype) if (TREE_CODE (lhs) == SSA_NAME) { gimple *lhs_def_stmt = SSA_NAME_DEF_STMT (lhs); - if (!vect_is_simple_use (lhs, vinfo, &lhs_def_stmt, &dt, &vectype1)) + if (!vect_is_simple_use (lhs, vinfo, &lhs_def_stmt, &dts[0], &vectype1)) return false; } - else if (TREE_CODE (lhs) != INTEGER_CST && TREE_CODE (lhs) != REAL_CST - && TREE_CODE (lhs) != FIXED_CST) + else if (TREE_CODE (lhs) == INTEGER_CST || TREE_CODE (lhs) == REAL_CST + || TREE_CODE (lhs) == FIXED_CST) + dts[0] = vect_constant_def; + else return false; if (TREE_CODE (rhs) == SSA_NAME) { gimple *rhs_def_stmt = SSA_NAME_DEF_STMT (rhs); - if (!vect_is_simple_use (rhs, vinfo, &rhs_def_stmt, &dt, &vectype2)) + if (!vect_is_simple_use (rhs, vinfo, &rhs_def_stmt, &dts[1], &vectype2)) return false; } - else if (TREE_CODE (rhs) != INTEGER_CST && TREE_CODE (rhs) != REAL_CST - && TREE_CODE (rhs) != FIXED_CST) + else if (TREE_CODE (rhs) == INTEGER_CST || TREE_CODE (rhs) == REAL_CST + || TREE_CODE (rhs) == FIXED_CST) + dts[1] = vect_constant_def; + else return false; if (vectype1 && vectype2 @@ -7746,7 +7759,10 @@ vectorizable_condition (gimple *stmt, gimple_stmt_iterator *gsi, tree vec_compare; tree new_temp; loop_vec_info loop_vinfo = STMT_VINFO_LOOP_VINFO (stmt_info); - enum vect_def_type dt, dts[4]; + enum vect_def_type dts[4] + = {vect_unknown_def_type, vect_unknown_def_type, + vect_unknown_def_type, vect_unknown_def_type}; + int ndts = 4; int ncopies; enum tree_code code, cond_code, bitop1 = NOP_EXPR, bitop2 = NOP_EXPR; stmt_vec_info prev_stmt_info = NULL; @@ -7808,15 +7824,16 @@ vectorizable_condition (gimple *stmt, gimple_stmt_iterator *gsi, then_clause = gimple_assign_rhs2 (stmt); else_clause = gimple_assign_rhs3 (stmt); - if (!vect_is_simple_cond (cond_expr, stmt_info->vinfo, &comp_vectype) + if (!vect_is_simple_cond (cond_expr, stmt_info->vinfo, + &comp_vectype, &dts[0]) || !comp_vectype) return false; gimple *def_stmt; - if (!vect_is_simple_use (then_clause, stmt_info->vinfo, &def_stmt, &dt, + if (!vect_is_simple_use (then_clause, stmt_info->vinfo, &def_stmt, &dts[2], &vectype1)) return false; - if (!vect_is_simple_use (else_clause, stmt_info->vinfo, &def_stmt, &dt, + if (!vect_is_simple_use (else_clause, stmt_info->vinfo, &def_stmt, &dts[3], &vectype2)) return false; @@ -7900,8 +7917,13 @@ vectorizable_condition (gimple *stmt, gimple_stmt_iterator *gsi, return false; } } - return expand_vec_cond_expr_p (vectype, comp_vectype, - cond_code); + if (expand_vec_cond_expr_p (vectype, comp_vectype, + cond_code)) + { + vect_model_simple_cost (stmt_info, ncopies, dts, ndts, NULL, NULL); + return true; + } + return false; } /* Transform. */ @@ -8104,6 +8126,7 @@ vectorizable_comparison (gimple *stmt, gimple_stmt_iterator *gsi, tree new_temp; loop_vec_info loop_vinfo = STMT_VINFO_LOOP_VINFO (stmt_info); enum vect_def_type dts[2] = {vect_unknown_def_type, vect_unknown_def_type}; + int ndts = 2; unsigned nunits; int ncopies; enum tree_code code, bitop1 = NOP_EXPR, bitop2 = NOP_EXPR; @@ -8229,7 +8252,7 @@ vectorizable_comparison (gimple *stmt, gimple_stmt_iterator *gsi, { STMT_VINFO_TYPE (stmt_info) = comparison_vec_info_type; vect_model_simple_cost (stmt_info, ncopies * (1 + (bitop2 != NOP_EXPR)), - dts, NULL, NULL); + dts, ndts, NULL, NULL); if (bitop1 == NOP_EXPR) return expand_vec_cmp_expr_p (vectype, mask_type, code); else diff --git a/gcc/tree-vectorizer.h b/gcc/tree-vectorizer.h index 12bb904..c0bc493 100644 --- a/gcc/tree-vectorizer.h +++ b/gcc/tree-vectorizer.h @@ -1079,7 +1079,7 @@ extern bool supportable_narrowing_operation (enum tree_code, tree, tree, extern stmt_vec_info new_stmt_vec_info (gimple *stmt, vec_info *); extern void free_stmt_vec_info (gimple *stmt); extern void vect_model_simple_cost (stmt_vec_info, int, enum vect_def_type *, - stmt_vector_for_cost *, + int, stmt_vector_for_cost *, stmt_vector_for_cost *); extern void vect_model_store_cost (stmt_vec_info, int, vect_memory_access_type, enum vect_def_type, slp_tree, --------------2.6.4.2.gae996d8--