From patchwork Fri Nov 20 15:10:18 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ilya Enkovich X-Patchwork-Id: 546949 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 DAD8A140323 for ; Sat, 21 Nov 2015 02:11:17 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b=uYSuLoPc; 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:cc:subject:message-id:references:mime-version :content-type:in-reply-to; q=dns; s=default; b=C7jGI7YM78h8s7q1M v2NrccR1Ged7kXvwBVuShuA7L1i/qHoq19NlMZKbrHGbGmPO/GvLpmdjjYx/M79G S9ughTiV1/bswu9XND0ISt1LGYmBG4qykTm+/k38chbB9KXu/lPlczvpH/XltMPp 4jJu7NmmwFUN3UJRU1POWHORNQ= 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:cc:subject:message-id:references:mime-version :content-type:in-reply-to; s=default; bh=0RmCYB6Zkf65fJ3Ks2mj6Y/ qLps=; b=uYSuLoPcbO2qtWS4unIFnsad2LJlBG45wEumtnH2Hv67Li0JuKL8gPH XKyclN6ZEkN0TrULwwsN1V7PtSZv0xCXLEStbs2CVxb+vGlGIGwaUBcfM5b9A/nt jzUakoBkjZyZgm01mQ6NGCKblZaeO7jhPnB0BzYTcFR4wC+dREgw= Received: (qmail 127787 invoked by alias); 20 Nov 2015 15:11:08 -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 127634 invoked by uid 89); 20 Nov 2015 15:11:02 -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-ig0-f181.google.com Received: from mail-ig0-f181.google.com (HELO mail-ig0-f181.google.com) (209.85.213.181) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-GCM-SHA256 encrypted) ESMTPS; Fri, 20 Nov 2015 15:10:51 +0000 Received: by igcto18 with SMTP id to18so13770553igc.0 for ; Fri, 20 Nov 2015 07:10:49 -0800 (PST) X-Received: by 10.50.143.1 with SMTP id sa1mr2310301igb.8.1448032249465; Fri, 20 Nov 2015 07:10:49 -0800 (PST) Received: from msticlxl57.ims.intel.com ([134.134.139.76]) by smtp.gmail.com with ESMTPSA id z15sm788778iod.37.2015.11.20.07.10.47 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 20 Nov 2015 07:10:48 -0800 (PST) Date: Fri, 20 Nov 2015 18:10:18 +0300 From: Ilya Enkovich To: Richard Biener Cc: GCC Patches Subject: Re: [PATCH, PR tree-optimization/68327] Compute vectype for live phi nodes when copmputing VF Message-ID: <20151120151018.GJ42296@msticlxl57.ims.intel.com> References: <20151118110701.GB42296@msticlxl57.ims.intel.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.23 (2014-03-12) X-IsSubscribed: yes On 20 Nov 14:31, Ilya Enkovich wrote: > 2015-11-20 14:28 GMT+03:00 Richard Biener : > > On Wed, Nov 18, 2015 at 2:53 PM, Ilya Enkovich wrote: > >> 2015-11-18 16:44 GMT+03:00 Richard Biener : > >>> On Wed, Nov 18, 2015 at 12:34 PM, Ilya Enkovich wrote: > >>>> Hi, > >>>> > >>>> When we compute vectypes we skip non-relevant phi nodes. But we process non-relevant alive statements and thus may need vectype of non-relevant live phi node to compute mask vectype. This patch enables vectype computation for live phi nodes. Botostrapped and regtested on x86_64-unknown-linux-gnu. OK for trunk? > >>> > >>> Hmm. What breaks if you instead skip all !relevant stmts and not > >>> compute vectype for life but not relevant ones? We won't ever > >>> "vectorize" !relevant ones, that is, we don't need their vector type. > >> > >> I tried it and got regression in SLP. It expected non-null vectype > >> for non-releveant but live statement. Regression was in > >> gcc/gcc/testsuite/gfortran.fortran-torture/execute/pr43390.f90 > > > > Because somebody put a vector type check before > > > > if (!STMT_VINFO_RELEVANT_P (stmt_info) && !bb_vinfo) > > return false; > > > > @@ -7590,6 +7651,9 @@ vectorizable_comparison (gimple *stmt, g > > tree mask_type; > > tree mask; > > > > + if (!STMT_VINFO_RELEVANT_P (stmt_info) && !bb_vinfo) > > + return false; > > + > > if (!VECTOR_BOOLEAN_TYPE_P (vectype)) > > return false; > > > > @@ -7602,8 +7666,6 @@ vectorizable_comparison (gimple *stmt, g > > ncopies = LOOP_VINFO_VECT_FACTOR (loop_vinfo) / nunits; > > > > gcc_assert (ncopies >= 1); > > - if (!STMT_VINFO_RELEVANT_P (stmt_info) && !bb_vinfo) > > - return false; > > > > if (STMT_VINFO_DEF_TYPE (stmt_info) != vect_internal_def > > && !(STMT_VINFO_DEF_TYPE (stmt_info) == vect_nested_cycle > > > > fixes this particular fallout for me. > > I'll try it. With this fix it works fine, thanks! Bootstrapped and regtested on x86_64-unknown-linux-gnu. OK for trunk? Ilya --- gcc/ 2015-11-20 Ilya Enkovich Richard Biener * tree-vect-loop.c (vect_determine_vectorization_factor): Don't compute vectype for non-relevant mask producers. * gcc/tree-vect-stmts.c (vectorizable_comparison): Check stmt relevance earlier. gcc/testsuite/ 2015-11-20 Ilya Enkovich * gcc.dg/pr68327.c: New test. diff --git a/gcc/testsuite/gcc.dg/pr68327.c b/gcc/testsuite/gcc.dg/pr68327.c new file mode 100644 index 0000000..c3e6a94 --- /dev/null +++ b/gcc/testsuite/gcc.dg/pr68327.c @@ -0,0 +1,15 @@ +/* { dg-do compile } */ +/* { dg-options "-O3" } */ + +int a, d; +char b, c; + +void +fn1 () +{ + int i = 0; + for (; i < 1; i++) + d = 1; + for (; b; b++) + a = 1 && (d & b); +} diff --git a/gcc/tree-vect-loop.c b/gcc/tree-vect-loop.c index 80937ec..592372d 100644 --- a/gcc/tree-vect-loop.c +++ b/gcc/tree-vect-loop.c @@ -439,7 +439,8 @@ vect_determine_vectorization_factor (loop_vec_info loop_vinfo) compute a factor. */ if (TREE_CODE (scalar_type) == BOOLEAN_TYPE) { - mask_producers.safe_push (stmt_info); + if (STMT_VINFO_RELEVANT_P (stmt_info)) + mask_producers.safe_push (stmt_info); bool_result = true; if (gimple_code (stmt) == GIMPLE_ASSIGN diff --git a/gcc/tree-vect-stmts.c b/gcc/tree-vect-stmts.c index 0f64aaf..3723b26 100644 --- a/gcc/tree-vect-stmts.c +++ b/gcc/tree-vect-stmts.c @@ -7546,6 +7546,9 @@ vectorizable_comparison (gimple *stmt, gimple_stmt_iterator *gsi, tree mask_type; tree mask; + if (!STMT_VINFO_RELEVANT_P (stmt_info) && !bb_vinfo) + return false; + if (!VECTOR_BOOLEAN_TYPE_P (vectype)) return false; @@ -7558,9 +7561,6 @@ vectorizable_comparison (gimple *stmt, gimple_stmt_iterator *gsi, ncopies = LOOP_VINFO_VECT_FACTOR (loop_vinfo) / nunits; gcc_assert (ncopies >= 1); - if (!STMT_VINFO_RELEVANT_P (stmt_info) && !bb_vinfo) - return false; - if (STMT_VINFO_DEF_TYPE (stmt_info) != vect_internal_def && !(STMT_VINFO_DEF_TYPE (stmt_info) == vect_nested_cycle && reduc_def))