From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 77139 invoked by alias); 2 Dec 2015 15:27: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 77129 invoked by uid 89); 2 Dec 2015 15:27:44 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.1 required=5.0 tests=AWL,BAYES_00,FREEMAIL_FROM,RCVD_IN_DNSWL_LOW,SPF_PASS autolearn=ham version=3.3.2 X-HELO: mail-yk0-f171.google.com Received: from mail-yk0-f171.google.com (HELO mail-yk0-f171.google.com) (209.85.160.171) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-GCM-SHA256 encrypted) ESMTPS; Wed, 02 Dec 2015 15:27:43 +0000 Received: by ykfs79 with SMTP id s79so50681153ykf.1 for ; Wed, 02 Dec 2015 07:27:40 -0800 (PST) MIME-Version: 1.0 X-Received: by 10.13.229.133 with SMTP id o127mr2486188ywe.267.1449070060530; Wed, 02 Dec 2015 07:27:40 -0800 (PST) Received: by 10.37.93.11 with HTTP; Wed, 2 Dec 2015 07:27:40 -0800 (PST) In-Reply-To: References: <20151112160843.GG51435@msticlxl57.ims.intel.com> Date: Wed, 02 Dec 2015 15:27:00 -0000 Message-ID: Subject: Re: [PATCH] Avoid false vector mask conversion From: Richard Biener To: Ilya Enkovich Cc: GCC Patches Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-IsSubscribed: yes X-SW-Source: 2015-12/txt/msg00291.txt.bz2 On Wed, Dec 2, 2015 at 4:24 PM, Ilya Enkovich wrot= e: > 2015-12-02 17:52 GMT+03:00 Richard Biener : >> On Thu, Nov 12, 2015 at 5:08 PM, Ilya Enkovich = wrote: >>> Hi, >>> >>> When we use LTO for fortran we may have a mix 32bit and 1bit scalar boo= leans. It means we may have conversion of one scalar type to another which = confuses vectorizer because values with different scalar boolean type may g= et the same vectype. This patch transforms such conversions into compariso= n. >>> >>> I managed to make a small fortran test which gets vectorized with this = patch but I didn't find how I can run fortran test with LTO and then scan t= ree dump to check it is vectorized. BTW here is a loop from the test: >>> >>> real*8 a(18) >>> logical b(18) >>> integer i >>> >>> do i=3D1,18 >>> if(a(i).gt.0.d0) then >>> b(i)=3D.true. >>> else >>> b(i)=3D.false. >>> endif >>> enddo >>> >>> Bootstrapped and tested on x86_64-unknown-linux-gnu. OK for trunk? >>> >>> Thanks, >>> Ilya >>> -- >>> gcc/ >>> >>> 2015-11-12 Ilya Enkovich >>> >>> * tree-vect-patterns.c (vect_recog_mask_conversion_pattern): >>> Transform useless boolean conversion into assignment. >>> >>> >>> diff --git a/gcc/tree-vect-patterns.c b/gcc/tree-vect-patterns.c >>> index b9d900c..62070da 100644 >>> --- a/gcc/tree-vect-patterns.c >>> +++ b/gcc/tree-vect-patterns.c >>> @@ -3674,6 +3674,38 @@ vect_recog_mask_conversion_pattern (vec *stmts, tree *type_in, >>> if (TREE_CODE (TREE_TYPE (lhs)) !=3D BOOLEAN_TYPE) >>> return NULL; >>> >>> + /* Check conversion between boolean types of different sizes. >>> + If no vectype is specified, then we have a regular mask >>> + assignment with no actual conversion. */ >>> + if (rhs_code =3D=3D CONVERT_EXPR >> >> CONVERT_EXPR_CODE_P (rhs_code) >> >>> + && !STMT_VINFO_DATA_REF (stmt_vinfo) >>> + && !STMT_VINFO_VECTYPE (stmt_vinfo)) >>> + { >>> + if (TREE_CODE (rhs1) !=3D SSA_NAME) >>> + return NULL; >>> + >>> + rhs1_type =3D search_type_for_mask (rhs1, vinfo); >>> + if (!rhs1_type) >>> + return NULL; >>> + >>> + vectype1 =3D get_mask_type_for_scalar_type (rhs1_type); >>> + >>> + if (!vectype1) >>> + return NULL; >>> + >>> + lhs =3D vect_recog_temp_ssa_var (TREE_TYPE (lhs), NULL); >>> + pattern_stmt =3D gimple_build_assign (lhs, rhs1); >> >> So what's the actual issue here? That the conversion is spurious? >> Why can't you accept this simply in vectorizable_assignment then? > > The problem is that conversion is supposed to be handled by > vectorizable_conversion, > but it fails to because it is not actually a conversion. I suppose it > may be handled > in vectorizable_assignment but I chose this pattern because it's meant > to handle mask > conversion issues. I think it's always better to avoid patterns if you can. Richard. > Thanks, > Ilya > >> >> Richard. >> >>> + *type_out =3D vectype1; >>> + *type_in =3D vectype1; >>> + stmts->safe_push (last_stmt); >>> + if (dump_enabled_p ()) >>> + dump_printf_loc (MSG_NOTE, vect_location, >>> + "vect_recog_mask_conversion_pattern: detected= :\n"); >>> + >>> + return pattern_stmt; >>> + } >>> + >>> if (rhs_code !=3D BIT_IOR_EXPR >>> && rhs_code !=3D BIT_XOR_EXPR >>> && rhs_code !=3D BIT_AND_EXPR)