From patchwork Mon Nov 4 07:16:06 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Kewen.Lin" X-Patchwork-Id: 1188816 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-512290-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=linux.ibm.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="VEgz4hQk"; dkim-atps=neutral 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 4763xm2lV9z9sNx for ; Mon, 4 Nov 2019 18:16:25 +1100 (AEDT) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :subject:from:to:cc:references:date:mime-version:in-reply-to :content-type:message-id; q=dns; s=default; b=NWtu6gUkIRbcdpK3Gi F3a6LKmcBm7wAa2y6Mp7Ly70W5Fx9P8aLOycF6c35eXrEjavBaFZAMeD5cVjRPGE 0udvGtCpgdeXHKaBMczqVgAp7ffvJJHUYfe7VKVgP+hGLW5K+yB+eUcamASfBVkY zzy+45Iv8815YQMlejXoYpP0c= 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 :subject:from:to:cc:references:date:mime-version:in-reply-to :content-type:message-id; s=default; bh=dOx0mzAV2TxhE8cijwFYQlhC 36Y=; b=VEgz4hQkRXWwtb7J8aLYjZazPSVQtlhZUActN+Rqxk1fQe+wHq/ysXyk ugpVpEhYHZfwa7OMltDGg5zyCKItCdzMavxtEb2AsAvlXRmhDSJGngf+okE5sRG/ F0ZsdOSQ5w7v8mB3Qc9oL0c+LKptwLasLhj9lyKdkeFOksi0ns0= Received: (qmail 106379 invoked by alias); 4 Nov 2019 07:16:18 -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 106364 invoked by uid 89); 4 Nov 2019 07:16:18 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-20.1 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_NUMSUBJECT, RCVD_IN_DNSWL_LOW, SPF_PASS autolearn=ham version=3.3.1 spammy=profits, 1.19, Lin, costing X-HELO: mx0a-001b2d01.pphosted.com Received: from mx0b-001b2d01.pphosted.com (HELO mx0a-001b2d01.pphosted.com) (148.163.158.5) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 04 Nov 2019 07:16:17 +0000 Received: from pps.filterd (m0098417.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.27/8.16.0.27) with SMTP id xA47DewF126714 for ; Mon, 4 Nov 2019 02:16:14 -0500 Received: from e06smtp02.uk.ibm.com (e06smtp02.uk.ibm.com [195.75.94.98]) by mx0a-001b2d01.pphosted.com with ESMTP id 2w2ed02abb-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Mon, 04 Nov 2019 02:16:14 -0500 Received: from localhost by e06smtp02.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Mon, 4 Nov 2019 07:16:12 -0000 Received: from b06cxnps3074.portsmouth.uk.ibm.com (9.149.109.194) by e06smtp02.uk.ibm.com (192.168.101.132) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; (version=TLSv1/SSLv3 cipher=AES256-GCM-SHA384 bits=256/256) Mon, 4 Nov 2019 07:16:11 -0000 Received: from d06av24.portsmouth.uk.ibm.com (d06av24.portsmouth.uk.ibm.com [9.149.105.60]) by b06cxnps3074.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id xA47G98N44695628 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 4 Nov 2019 07:16:09 GMT Received: from d06av24.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 5870A4204C; Mon, 4 Nov 2019 07:16:09 +0000 (GMT) Received: from d06av24.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 3FAB242049; Mon, 4 Nov 2019 07:16:08 +0000 (GMT) Received: from kewenlins-mbp.cn.ibm.com (unknown [9.200.147.184]) by d06av24.portsmouth.uk.ibm.com (Postfix) with ESMTP; Mon, 4 Nov 2019 07:16:07 +0000 (GMT) Subject: [PATCH, rs6000] Make load cost more in vectorization cost for P8/P9 From: "Kewen.Lin" To: GCC Patches Cc: Segher Boessenkool , Bill Schmidt References: <562230cb-ec3c-e46c-f59f-b7d69f3000b7@linux.ibm.com> <804b71d6-40c3-7c0d-8bfa-b347a7b7fda4@linux.ibm.com> Date: Mon, 4 Nov 2019 15:16:06 +0800 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.14; rv:60.0) Gecko/20100101 Thunderbird/60.9.0 MIME-Version: 1.0 In-Reply-To: <804b71d6-40c3-7c0d-8bfa-b347a7b7fda4@linux.ibm.com> x-cbid: 19110407-0008-0000-0000-0000032A6C71 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 19110407-0009-0000-0000-00004A49C089 Message-Id: X-IsSubscribed: yes Hi, To align with rs6000_insn_cost costing more for load type insns, this patch is to make load insns cost more in vectorization cost function. Considering that the result of load usually is used somehow later (true-dep) but store won't, we keep the store as before. The SPEC2017 performance evaluation on Power8 shows 525.x264_r +9.56%, 511.povray_r +2.08%, 527.cam4_r 1.16% gains, no significant degradation, SPECINT geomean +0.88%, SPECFP geomean +0.26%. The SPEC2017 performance evaluation on Power9 shows no significant improvement or degradation, SPECINT geomean +0.04%, SPECFP geomean +0.04%. The SPEC2006 performance evaluation on Power8 shows 454.calculix +4.41% gain but 416.gamess -1.19% and 453.povray -3.83% degradation. I looked into the two degradation bmks, the degradation were NOT due to hotspot changes by vectorization, were all side effects. SPECINT geomean +0.10%, SPECFP geomean no changed considering the degradation. Bootstrapped and regress tested on powerpc64le-linux-gnu. Is OK for trunk? BR, Kewen --- gcc/ChangeLog 2019-11-04 Kewen Lin * config/rs6000/rs6000.c (rs6000_builtin_vectorization_cost): Make scalar_load, vector_load, unaligned_load and vector_gather_load cost a bit more on Power8 and up. diff --git a/gcc/config/rs6000/rs6000.c b/gcc/config/rs6000/rs6000.c index 5876714..876c7ef 100644 --- a/gcc/config/rs6000/rs6000.c +++ b/gcc/config/rs6000/rs6000.c @@ -4763,15 +4763,22 @@ rs6000_builtin_vectorization_cost (enum vect_cost_for_stmt type_of_cost, switch (type_of_cost) { case scalar_stmt: - case scalar_load: case scalar_store: case vector_stmt: - case vector_load: case vector_store: case vec_to_scalar: case scalar_to_vec: case cond_branch_not_taken: return 1; + case scalar_load: + case vector_load: + /* Like rs6000_insn_cost, make load insns cost a bit more. FIXME: the + benefits were observed on Power8 and up, we can unify it if similar + profits are measured on Power6 and Power7. */ + if (TARGET_P8_VECTOR) + return 2; + else + return 1; case vec_perm: /* Power7 has only one permute unit, make it a bit expensive. */ @@ -4792,8 +4799,9 @@ rs6000_builtin_vectorization_cost (enum vect_cost_for_stmt type_of_cost, case unaligned_load: case vector_gather_load: + /* Like rs6000_insn_cost, make load insns cost a bit more. */ if (TARGET_EFFICIENT_UNALIGNED_VSX) - return 1; + return 2; if (TARGET_VSX && TARGET_ALLOW_MOVMISALIGN) { @@ -4827,7 +4835,13 @@ rs6000_builtin_vectorization_cost (enum vect_cost_for_stmt type_of_cost, /* Misaligned loads are not supported. */ gcc_unreachable (); - return 2; + /* Like rs6000_insn_cost, make load insns cost a bit more. FIXME: the + benefits were observed on Power8 and up, we can unify it if similar + profits are measured on Power6 and Power7. */ + if (TARGET_P8_VECTOR) + return 4; + else + return 2; case unaligned_store: case vector_scatter_store: