From patchwork Tue Apr 18 22:38:48 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bill Schmidt X-Patchwork-Id: 752017 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 3w70Rj1QlYz9s3w for ; Wed, 19 Apr 2017 08:39:11 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="mXmgpo/S"; 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:to:cc :from:subject:date:mime-version:content-type :content-transfer-encoding:message-id; q=dns; s=default; b=qEDqF 8M8OigbNK6nk2GCTbMFS052AtYB05l0cZjtoTXtMRGFuJmBnMPMHLdnkMFpMfNVb Dom4NmOgUVXitFHt8+Sf3CAWsDuH3SHZPg9/gidYNnieXATVALjH5bNu0m/febVu BcvH6ISiUPPN0PBor+79Fe3LBAHUxxgX9tlr0E= 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:to:cc :from:subject:date:mime-version:content-type :content-transfer-encoding:message-id; s=default; bh=O2c9IJJ0tCo tvLvphYiVSec8hek=; b=mXmgpo/SZ27FZnDIpEI4UE0W52eLAFeu6OkFQoDVWpk GNc37W67gCzkOQ+GzVVwywxdRywXnufIGWT6josYS3LK6Y+g7cw27uY0KD5MA0D7 KNszXlXdcNEnmGegdoa6QzAMKr8xt8FxegOnZ90oqTEiC6q1Endf1weTRhmxS0Bg = Received: (qmail 25931 invoked by alias); 18 Apr 2017 22:38:56 -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 25900 invoked by uid 89); 18 Apr 2017 22:38:55 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-10.2 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_2, GIT_PATCH_3, KAM_ASCII_DIVIDERS, KAM_LAZY_DOMAIN_SECURITY, RCVD_IN_DNSWL_LOW autolearn=ham version=3.3.2 spammy=H*u:Mac, H*UA:Mac, H*u:Macintosh, H*UA:Macintosh X-HELO: mx0a-001b2d01.pphosted.com Received: from mx0a-001b2d01.pphosted.com (HELO mx0a-001b2d01.pphosted.com) (148.163.156.1) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 18 Apr 2017 22:38:53 +0000 Received: from pps.filterd (m0098396.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.20/8.16.0.20) with SMTP id v3IMcoWB099151 for ; Tue, 18 Apr 2017 18:38:53 -0400 Received: from e31.co.us.ibm.com (e31.co.us.ibm.com [32.97.110.149]) by mx0a-001b2d01.pphosted.com with ESMTP id 29wqq11t0d-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Tue, 18 Apr 2017 18:38:53 -0400 Received: from localhost by e31.co.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Tue, 18 Apr 2017 16:38:52 -0600 Received: from b03cxnp07028.gho.boulder.ibm.com (9.17.130.15) by e31.co.us.ibm.com (192.168.1.131) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Tue, 18 Apr 2017 16:38:50 -0600 Received: from b03ledav004.gho.boulder.ibm.com (b03ledav004.gho.boulder.ibm.com [9.17.130.235]) by b03cxnp07028.gho.boulder.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id v3IMcnXv14942674; Tue, 18 Apr 2017 15:38:49 -0700 Received: from b03ledav004.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 776EE78038; Tue, 18 Apr 2017 16:38:49 -0600 (MDT) Received: from bigmac.rchland.ibm.com (unknown [9.10.86.201]) by b03ledav004.gho.boulder.ibm.com (Postfix) with ESMTP id 45FC578037; Tue, 18 Apr 2017 16:38:49 -0600 (MDT) To: GCC Patches Cc: Richard Biener From: Bill Schmidt Subject: [PATCH] Fix PR80457 Date: Tue, 18 Apr 2017 17:38:48 -0500 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.12; rv:45.0) Gecko/20100101 Thunderbird/45.8.0 MIME-Version: 1.0 X-TM-AS-GCONF: 00 x-cbid: 17041822-8235-0000-0000-00000B5580C8 X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00006936; HX=3.00000240; KW=3.00000007; PH=3.00000004; SC=3.00000208; SDB=6.00849325; UDB=6.00419371; IPR=6.00627965; BA=6.00005300; NDR=6.00000001; ZLA=6.00000005; ZF=6.00000009; ZB=6.00000000; ZP=6.00000000; ZH=6.00000000; ZU=6.00000002; MB=3.00015089; XFM=3.00000013; UTC=2017-04-18 22:38:51 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17041822-8236-0000-0000-00003B3F222B Message-Id: <507725db-45cf-e734-095d-2225087c53a8@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2017-04-18_19:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=0 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1703280000 definitions=main-1704180181 X-IsSubscribed: yes 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? Thanks, Bill [gcc] 2017-04-18 Bill Schmidt PR tree-optimization/80457 * tree-vect-stmts.c (vectorizable_condition): Update the cost model when vectorizing a COND_EXPR. [gcc/testsuite] 2017-04-18 Bill Schmidt PR tree-optimization/80457 * gcc.target/powerpc/pr78604.c: Verify that vectorized COND_EXPRs call vect_model_simple_cost. Index: gcc/testsuite/gcc.target/powerpc/pr78604.c =================================================================== --- gcc/testsuite/gcc.target/powerpc/pr78604.c (revision 246948) +++ gcc/testsuite/gcc.target/powerpc/pr78604.c (working copy) @@ -2,7 +2,7 @@ /* { dg-skip-if "" { powerpc*-*-darwin* } { "*" } { "" } } */ /* { dg-require-effective-target powerpc_p8vector_ok } */ /* { dg-skip-if "do not override -mcpu" { powerpc*-*-* } { "-mcpu=*" } { "-mcpu=power8" } } */ -/* { dg-options "-mcpu=power8 -O2 -ftree-vectorize" } */ +/* { dg-options "-mcpu=power8 -O2 -ftree-vectorize -fdump-tree-vect-details" } */ #ifndef SIZE #define SIZE 1024 @@ -110,3 +110,4 @@ uns_gte (UNS_TYPE val1, UNS_TYPE val2) /* { dg-final { scan-assembler-times {\mvcmpgtsd\M} 4 } } */ /* { dg-final { scan-assembler-times {\mvcmpgtud\M} 4 } } */ /* { dg-final { scan-assembler-not {\mvcmpequd\M} } } */ +/* { dg-final { scan-tree-dump-times "vect_model_simple_cost" 8 "vect" } } */ Index: gcc/tree-vect-stmts.c =================================================================== --- gcc/tree-vect-stmts.c (revision 246948) +++ gcc/tree-vect-stmts.c (working copy) @@ -7746,7 +7746,7 @@ vectorizable_condition (gimple *stmt, gimple_stmt_ 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 dt[2], dts[4]; int ncopies; enum tree_code code, cond_code, bitop1 = NOP_EXPR, bitop2 = NOP_EXPR; stmt_vec_info prev_stmt_info = NULL; @@ -7813,10 +7813,10 @@ vectorizable_condition (gimple *stmt, gimple_stmt_ 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, &dt[0], &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, &dt[1], &vectype2)) return false; @@ -7900,8 +7900,12 @@ vectorizable_condition (gimple *stmt, gimple_stmt_ 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, dt, NULL, NULL); + return true; + } + return false; } /* Transform. */