From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 99098 invoked by alias); 7 Nov 2019 16:13:15 -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 98888 invoked by uid 89); 7 Nov 2019 16:13:14 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-10.7 required=5.0 tests=AWL,BAYES_00,FREEMAIL_FROM,GIT_PATCH_2,GIT_PATCH_3,RCVD_IN_DNSWL_NONE,SPF_PASS autolearn=ham version=3.3.1 spammy=HX-Received:a7b, H*i:sk:mpttv7f, H*f:sk:mpttv7f X-HELO: mail-wm1-f53.google.com Received: from mail-wm1-f53.google.com (HELO mail-wm1-f53.google.com) (209.85.128.53) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 07 Nov 2019 16:13:12 +0000 Received: by mail-wm1-f53.google.com with SMTP id v3so5252050wmh.1 for ; Thu, 07 Nov 2019 08:13:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:user-agent:in-reply-to:references:mime-version :content-transfer-encoding:subject:to:cc:from:message-id; bh=HAs8wEy9eDDKIpnxJ17cOhG8iOG0J40VfITjYA9ibkI=; b=mMo2Mh5z5hyNBitnps0cSJ3+4A+V2HvCzu6DpizTYb+0sYblYmowc0gOspnsr3Jmpa R9ChWxNR9DUoIsoJhX3RLdmBM5QdWIJq9XZ53mwM/Uqi7AAMMP10ik0tv/aKLtc1ZOzW Xt9FNLM4szgtuDxdK4ZVR6dE4RMXc16aN8+D2LO4F3BY9bG/pDQDz5OdWYJotLVpScPY Ne/oNG3jP1FDUoa6oIFxMF31FshVY5A2Lvf4GAD1BGEYFJVYQxDDp8layVe5POID+TYY rCbGIRLTcr3eDtbzuVRQYEOFW8QwvplqCkt9xoW+mG/6DMY+mZkBe58Ip/8FonDv0qN2 poDw== Return-Path: Received: from [192.168.178.32] (x4d044fe9.dyn.telefonica.de. [77.4.79.233]) by smtp.gmail.com with ESMTPSA id v19sm2165571wmh.16.2019.11.07.08.13.08 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 07 Nov 2019 08:13:09 -0800 (PST) Date: Thu, 07 Nov 2019 16:13:00 -0000 User-Agent: K-9 Mail for Android In-Reply-To: References: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Subject: Re: [1/6] Fix vectorizable_conversion costs To: Richard Sandiford CC: "gcc-patches@gcc.gnu.org" From: Richard Biener Message-ID: <11DA5480-898C-4515-924B-EDD7822F6FF6@gmail.com> X-IsSubscribed: yes X-SW-Source: 2019-11/txt/msg00522.txt.bz2 On November 7, 2019 4:14:14 PM GMT+01:00, Richard Sandiford wrote: >Richard Biener writes: >> On Tue, Nov 5, 2019 at 3:25 PM Richard Sandiford >> wrote: >>> >>> This patch makes two tweaks to vectorizable_conversion. The first >>> is to use "modifier" to distinguish between promotion, demotion, >>> and neither promotion nor demotion, rather than using a code for >>> some cases and "modifier" for others. The second is to take ncopies >>> into account for the promotion and demotion costs; previously we >gave >>> multiple copies the same cost as a single copy. >>> >>> Later patches test this, but it seemed worth splitting out. >> >> OK, but does ncopies properly handle unrolling with SLP? > >Bah, thanks for catching that. Here's a fixed version, tested as >before. OK.=20 Thanks,=20 Richard.=20 >Richard > > >2019-11-07 Richard Sandiford > >gcc/ > * tree-vect-stmts.c (vect_model_promotion_demotion_cost): Take the > number of ncopies as an additional argument. > (vectorizable_conversion): Update call accordingly. Use "modifier" > to check whether a conversion is between vectors with the same > numbers of units. > >Index: gcc/tree-vect-stmts.c >=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D >--- gcc/tree-vect-stmts.c 2019-11-07 15:11:49.000000000 +0000 >+++ gcc/tree-vect-stmts.c 2019-11-07 15:11:50.134775028 +0000 >@@ -917,26 +917,27 @@ vect_model_simple_cost (stmt_vec_info st > } >=20 >=20 >-/* Model cost for type demotion and promotion operations. PWR is >normally >- zero for single-step promotions and demotions. It will be one if=20 >- two-step promotion/demotion is required, and so on. Each >additional >+/* Model cost for type demotion and promotion operations. PWR is >+ normally zero for single-step promotions and demotions. It will be >+ one if two-step promotion/demotion is required, and so on. NCOPIES >+ is the number of vector results (and thus number of instructions) >+ for the narrowest end of the operation chain. Each additional > step doubles the number of instructions required. */ >=20 > static void > vect_model_promotion_demotion_cost (stmt_vec_info stmt_info, >- enum vect_def_type *dt, int pwr, >+ enum vect_def_type *dt, >+ unsigned int ncopies, int pwr, > stmt_vector_for_cost *cost_vec) > { >- int i, tmp; >+ int i; > int inside_cost =3D 0, prologue_cost =3D 0; >=20 > for (i =3D 0; i < pwr + 1; i++) > { >- tmp =3D (STMT_VINFO_TYPE (stmt_info) =3D=3D >type_promotion_vec_info_type) ? >- (i + 1) : i; >- inside_cost +=3D record_stmt_cost (cost_vec, vect_pow2 (tmp), >- vec_promote_demote, stmt_info, 0, >- vect_body); >+ inside_cost +=3D record_stmt_cost (cost_vec, ncopies, >vec_promote_demote, >+ stmt_info, 0, vect_body); >+ ncopies *=3D 2; > } >=20 > /* FORNOW: Assuming maximum 2 args per stmts. */ >@@ -4964,7 +4965,7 @@ vectorizable_conversion (stmt_vec_info s > if (!vec_stmt) /* transformation not required. */ > { > DUMP_VECT_SCOPE ("vectorizable_conversion"); >- if (code =3D=3D FIX_TRUNC_EXPR || code =3D=3D FLOAT_EXPR) >+ if (modifier =3D=3D NONE) > { > STMT_VINFO_TYPE (stmt_info) =3D type_conversion_vec_info_type; > vect_model_simple_cost (stmt_info, ncopies, dt, ndts, slp_node, >@@ -4973,14 +4974,24 @@ vectorizable_conversion (stmt_vec_info s > else if (modifier =3D=3D NARROW) > { > STMT_VINFO_TYPE (stmt_info) =3D type_demotion_vec_info_type; >- vect_model_promotion_demotion_cost (stmt_info, dt, multi_step_cvt, >- cost_vec); >+ /* The final packing step produces one vector result per copy. */ >+ unsigned int nvectors >+ =3D (slp_node ? SLP_TREE_NUMBER_OF_VEC_STMTS (slp_node) : ncopies); >+ vect_model_promotion_demotion_cost (stmt_info, dt, nvectors, >+ multi_step_cvt, cost_vec); > } > else > { > STMT_VINFO_TYPE (stmt_info) =3D type_promotion_vec_info_type; >- vect_model_promotion_demotion_cost (stmt_info, dt, multi_step_cvt, >- cost_vec); >+ /* The initial unpacking step produces two vector results >+ per copy. MULTI_STEP_CVT is 0 for a single conversion, >+ so >> MULTI_STEP_CVT divides by 2^(number of steps - 1). */ >+ unsigned int nvectors >+ =3D (slp_node >+ ? SLP_TREE_NUMBER_OF_VEC_STMTS (slp_node) >> multi_step_cvt >+ : ncopies * 2); >+ vect_model_promotion_demotion_cost (stmt_info, dt, nvectors, >+ multi_step_cvt, cost_vec); > } > interm_types.release (); > return true;