From patchwork Thu Nov 12 16:08:43 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ilya Enkovich X-Patchwork-Id: 543420 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 44EED14142F for ; Fri, 13 Nov 2015 03:09:20 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b=wKjBGCNo; 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:subject:message-id:mime-version:content-type; q=dns; s= default; b=TXEG9SXLejXIpQjHmVc+y9c+l6ydaTziQQXd8N1DMxEBcLVkq3TwJ eTmBurV8ohcsD4FHGmQ3l8qH78lMcPTb+pBnLqy3+DvYiwi5NQi0GcY8r9H5Mh4D 2rphRsNeKNSgWvHEDAIglQUi/p9gUdTKwrbwvoozlNDHhE3xc/8vdc= 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:subject:message-id:mime-version:content-type; s= default; bh=ot4RB5sixBEDGJNjHvRldhclLG4=; b=wKjBGCNoG0grfHsxw4MM 0Vf1PN9E56Jd24708n0pPKuawN/j1om0oLAeRTvneacWpmmnMpYJf86iDVKb8/9o Q81HMq7oNXHEQGy+svNhJtSa295AwKyI++7YMq8G9LxhddwggDsRtBJAALR/VqeT cYKe9Ov3gLHzOyQ8bMr+sag= Received: (qmail 43210 invoked by alias); 12 Nov 2015 16:09:12 -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 43189 invoked by uid 89); 12 Nov 2015 16:09:11 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.5 required=5.0 tests=AWL, BAYES_00, FREEMAIL_FROM, RCVD_IN_DNSWL_LOW, SPF_PASS autolearn=ham version=3.3.2 X-HELO: mail-io0-f174.google.com Received: from mail-io0-f174.google.com (HELO mail-io0-f174.google.com) (209.85.223.174) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-GCM-SHA256 encrypted) ESMTPS; Thu, 12 Nov 2015 16:09:10 +0000 Received: by iofh3 with SMTP id h3so69546025iof.3 for ; Thu, 12 Nov 2015 08:09:08 -0800 (PST) X-Received: by 10.107.18.159 with SMTP id 31mr14700142ios.130.1447344547921; Thu, 12 Nov 2015 08:09:07 -0800 (PST) Received: from msticlxl57.ims.intel.com (jfdmzpr03-ext.jf.intel.com. [134.134.139.72]) by smtp.gmail.com with ESMTPSA id 42sm5199688iol.44.2015.11.12.08.09.06 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 12 Nov 2015 08:09:07 -0800 (PST) Date: Thu, 12 Nov 2015 19:08:43 +0300 From: Ilya Enkovich To: gcc-patches@gcc.gnu.org Subject: [PATCH] Avoid false vector mask conversion Message-ID: <20151112160843.GG51435@msticlxl57.ims.intel.com> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.23 (2014-03-12) X-IsSubscribed: yes Hi, When we use LTO for fortran we may have a mix 32bit and 1bit scalar booleans. It means we may have conversion of one scalar type to another which confuses vectorizer because values with different scalar boolean type may get the same vectype. This patch transforms such conversions into comparison. 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 tree 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=1,18 if(a(i).gt.0.d0) then b(i)=.true. else b(i)=.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)) != 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 == CONVERT_EXPR + && !STMT_VINFO_DATA_REF (stmt_vinfo) + && !STMT_VINFO_VECTYPE (stmt_vinfo)) + { + if (TREE_CODE (rhs1) != SSA_NAME) + return NULL; + + rhs1_type = search_type_for_mask (rhs1, vinfo); + if (!rhs1_type) + return NULL; + + vectype1 = get_mask_type_for_scalar_type (rhs1_type); + + if (!vectype1) + return NULL; + + lhs = vect_recog_temp_ssa_var (TREE_TYPE (lhs), NULL); + pattern_stmt = gimple_build_assign (lhs, rhs1); + + *type_out = vectype1; + *type_in = 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 != BIT_IOR_EXPR && rhs_code != BIT_XOR_EXPR && rhs_code != BIT_AND_EXPR)