From patchwork Thu Nov 17 03:14:57 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bill Schmidt X-Patchwork-Id: 695973 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 3tK5qg4P5mz9sD5 for ; Thu, 17 Nov 2016 14:15:57 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="Z4pt/tIq"; 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 :subject:to:references:cc:from:date:mime-version:in-reply-to :content-type:content-transfer-encoding:message-id; q=dns; s= default; b=EcbfTYLgHWp1hZJRRHfZ264V1AK7C0CTveZFTeOtZ8knVscRFIvJ4 FDCi4GMZEKd7/BsAKqdi936zZ00DthfpjB+3eM0pesJnP6SR/X4BRfrulLVd7HXR iwnOz/Mcjp6dbrOMGuH3SVhP+yXUU5raCkSvekSzn3WNXOvDg+vZ+M= 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:to:references:cc:from:date:mime-version:in-reply-to :content-type:content-transfer-encoding:message-id; s=default; bh=LU4VXzOZdszI6ip8oeuF+fkPTmI=; b=Z4pt/tIqHY4cO2ttDLHlSueBPpUC 9FRpji++zCO61hNWBYdCwhyuV81rjQD5mtIQc2XfMUY0WVkbaToh5aGfqKRhckeg JROcaMrzwTghT4nJ1wa/VideS1DLD15eBYvKSEW5/knBZiLpAP6nh8BW0NPWHzCw TYJbxv53cUIIlhk= Received: (qmail 130174 invoked by alias); 17 Nov 2016 03:15:39 -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 130088 invoked by uid 89); 17 Nov 2016 03:15:34 -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_50, KAM_ASCII_DIVIDERS, KAM_LAZY_DOMAIN_SECURITY, RCVD_IN_DNSWL_LOW, RCVD_IN_SEMBACKSCATTER autolearn=no version=3.3.2 spammy=loop_outer, LOOP_VECTORIZED, enddo, 0d0 X-HELO: mx0a-001b2d01.pphosted.com Received: from mx0a-001b2d01.pphosted.com (HELO mx0a-001b2d01.pphosted.com) (148.163.156.1) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 17 Nov 2016 03:15:04 +0000 Received: from pps.filterd (m0098410.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.17/8.16.0.17) with SMTP id uAH3DgNK091026 for ; Wed, 16 Nov 2016 22:15:03 -0500 Received: from e34.co.us.ibm.com (e34.co.us.ibm.com [32.97.110.152]) by mx0a-001b2d01.pphosted.com with ESMTP id 26rvx31kuy-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Wed, 16 Nov 2016 22:15:02 -0500 Received: from localhost by e34.co.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Wed, 16 Nov 2016 20:15:01 -0700 Received: from d03dlp03.boulder.ibm.com (9.17.202.179) by e34.co.us.ibm.com (192.168.1.134) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Wed, 16 Nov 2016 20:14:58 -0700 Received: from b03cxnp08027.gho.boulder.ibm.com (b03cxnp08027.gho.boulder.ibm.com [9.17.130.19]) by d03dlp03.boulder.ibm.com (Postfix) with ESMTP id C720919D8040; Wed, 16 Nov 2016 20:14:20 -0700 (MST) Received: from b03ledav006.gho.boulder.ibm.com (b03ledav006.gho.boulder.ibm.com [9.17.130.237]) by b03cxnp08027.gho.boulder.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id uAH3EwwI39845980; Wed, 16 Nov 2016 20:14:58 -0700 Received: from b03ledav006.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 49881C604A; Wed, 16 Nov 2016 20:14:58 -0700 (MST) Received: from BigMac.local (unknown [9.85.138.244]) by b03ledav006.gho.boulder.ibm.com (Postfix) with ESMTP id C4915C6037; Wed, 16 Nov 2016 20:14:57 -0700 (MST) Subject: Re: [PATCH] Fix PR77848 To: Richard Biener References: <1d9bddb6-2005-a53b-fbcf-46c9dfe244db@linux.vnet.ibm.com> Cc: GCC Patches From: Bill Schmidt Date: Wed, 16 Nov 2016 21:14:57 -0600 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.12; rv:45.0) Gecko/20100101 Thunderbird/45.4.0 MIME-Version: 1.0 In-Reply-To: X-TM-AS-GCONF: 00 X-Content-Scanned: Fidelis XPS MAILER x-cbid: 16111703-0016-0000-0000-0000052F9EAC X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00006091; HX=3.00000240; KW=3.00000007; PH=3.00000004; SC=3.00000189; SDB=6.00781734; UDB=6.00377135; IPR=6.00559244; BA=6.00004886; NDR=6.00000001; ZLA=6.00000005; ZF=6.00000009; ZB=6.00000000; ZP=6.00000000; ZH=6.00000000; ZU=6.00000002; MB=3.00013354; XFM=3.00000011; UTC=2016-11-17 03:14:59 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 16111703-0017-0000-0000-000034B4D281 Message-Id: <8d249ad0-2df9-7939-c216-5e2f1d8d4035@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2016-11-16_09:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=0 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1609300000 definitions=main-1611170060 X-IsSubscribed: yes On 11/16/16 9:08 AM, Richard Biener wrote: > On Tue, Nov 15, 2016 at 9:03 PM, Bill Schmidt > wrote: >> - if ((any_pred_load_store || any_complicated_phi) >> - && !version_loop_for_if_conversion (loop)) >> + /* Since we have no cost model, always version loops if vectorization >> + is enabled. Either version this loop, or if the pattern is right >> + for outer-loop vectorization, version the outer loop. In the >> + latter case we will still if-convert the original inner loop. */ >> + /* FIXME: When SLP vectorization can handle if-conversion on its own, >> + predicate all of if-conversion on flag_tree_loop_vectorize. */ >> + if ((any_pred_load_store || any_complicated_phi || flag_tree_loop_vectorize) > I'd say given fun->has_force_vectorize_loops this should be > > if (flag_tree_loop_if_convert != 1 >> + && !version_loop_for_if_conversion >> + (versionable_outer_loop_p (loop_outer (loop)) >> + ? loop_outer (loop) : loop)) >> goto cleanup; > and thus always version if the user didnt' specify -ftree-loop-if-convert > (-ftree-loop-if-convert-stores is dead, I forgot to remove uses). > > Can you as a first patch (after fixing the minor things above) commit > the patch w/o changing the condition under which we version > (but _do_ version the outer loop if possible?). This should be a strict > improvement enabling more outer loop vectorization. Done and committed. Thanks! > > The 2nd patch can then fix the PR and change the condition. > > Thus, ok with the nits fixed and the condition unchanged. > > Can you re-test the 2nd part with my suggested changed predicate? Yes, the new predicate works fine. New patch below, bootstrapped and tested on powerpc64le-unknown-linux-gnu, with only the bb-slp-cond-1.c regressions previously discussed. Is this ok for trunk? Thanks, Bill > > Thanks, > Richard. > [gcc] 2016-11-16 Bill Schmidt Richard Biener PR tree-optimization/77848 * tree-if-conv.c (tree_if_conversion): Always version loops unless the user specified -ftree-loop-if-convert. [gcc/testsuite] 2016-11-16 Bill Schmidt Richard Biener PR tree-optimization/77848 * gfortran.dg/vect/pr77848.f: New test. Index: gcc/testsuite/gfortran.dg/vect/pr77848.f =================================================================== --- gcc/testsuite/gfortran.dg/vect/pr77848.f (revision 0) +++ gcc/testsuite/gfortran.dg/vect/pr77848.f (working copy) @@ -0,0 +1,24 @@ +! PR 77848: Verify versioning is on when vectorization fails +! { dg-do compile } +! { dg-options "-O3 -ffast-math -fdump-tree-ifcvt -fdump-tree-vect-details" } + + subroutine sub(x,a,n,m) + implicit none + real*8 x(*),a(*),atemp + integer i,j,k,m,n + real*8 s,t,u,v + do j=1,m + atemp=0.d0 + do i=1,n + if (abs(a(i)).gt.atemp) then + atemp=a(i) + k = i + end if + enddo + call dummy(atemp,k) + enddo + return + end + +! { dg-final { scan-tree-dump "LOOP_VECTORIZED" "ifcvt" } } +! { dg-final { scan-tree-dump "vectorized 0 loops in function" "vect" } } Index: gcc/tree-if-conv.c =================================================================== --- gcc/tree-if-conv.c (revision 242521) +++ gcc/tree-if-conv.c (working copy) @@ -2803,10 +2803,12 @@ tree_if_conversion (struct loop *loop) || loop->dont_vectorize)) goto cleanup; - /* Either version this loop, or if the pattern is right for outer-loop - vectorization, version the outer loop. In the latter case we will - still if-convert the original inner loop. */ - if ((any_pred_load_store || any_complicated_phi) + /* Since we have no cost model, always version loops unless the user + specified -ftree-loop-if-convert. Either version this loop, or if + the pattern is right for outer-loop vectorization, version the + outer loop. In the latter case we will still if-convert the + original inner loop. */ + if (flag_tree_loop_if_convert != 1 && !version_loop_for_if_conversion (versionable_outer_loop_p (loop_outer (loop)) ? loop_outer (loop) : loop))