From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 65046 invoked by alias); 13 May 2017 06:18:45 -0000 Mailing-List: contact gcc-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-owner@gcc.gnu.org Received: (qmail 65029 invoked by uid 89); 13 May 2017 06:18:44 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: =?ISO-8859-1?Q?No, score=1.9 required=5.0 tests=AWL,BAYES_00,BODY_8BITS,FREEMAIL_FROM,GARBLED_BODY,RCVD_IN_DNSWL_NONE,RCVD_IN_SORBS_SPAM,SPF_PASS autolearn=no version=3.3.2 spammy=8:=bd, 8:=ef=bf, wondering?= X-HELO: mail-wr0-f177.google.com Received: from mail-wr0-f177.google.com (HELO mail-wr0-f177.google.com) (209.85.128.177) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Sat, 13 May 2017 06:18:43 +0000 Received: by mail-wr0-f177.google.com with SMTP id l9so53430630wre.1 for ; Fri, 12 May 2017 23:18:45 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:user-agent:in-reply-to:references :mime-version:content-transfer-encoding:subject:to:from:message-id; bh=UIYAjpMxlrUftTbtAlIy/p2CGetCaY7JV0DUZoPTI6c=; b=PEg1iZSEMWjdt38XQF+SrAWhAgm59UCJCQBNk7wm8cwXVI79ukX8ekyIIMMSTV0u/I KTsRT75lWWP02MIQ66/Cge73gdRH6fte1bfGLkCZSklxIPhFoPTRP+1fPgHzJAvUr/8q L5FZy8mN0fdsVx5IwJVkVA4IhFJHFWm8xaYBP/pnNHh3p+UyT7fZ1rhxhF71dVARVAho hRcurCHrqc0Ve172oBIfCvVRhJ2+7Bh5g4tMeczkf/gjlN24ncjP63HjJdjUdddNbryu rDXm5SvVtdPPIj0eJTvQCr2dh7o7D8PAIwHKDxcNEC7OFG1+7LAoidczcHidVYo27+LY 8VhQ== X-Gm-Message-State: AODbwcDVNfdWb2FUKETrkmrES6Up1Ju5R3z6SDV4MVllcpR3d/f5ham1 7NAIr0bmhOXJV1Gu/RY= X-Received: by 10.223.136.227 with SMTP id g32mr5226253wrg.58.1494656323973; Fri, 12 May 2017 23:18:43 -0700 (PDT) Received: from android-4c5a376a18c0e957.fritz.box (p5494E583.dip0.t-ipconnect.de. [84.148.229.131]) by smtp.gmail.com with ESMTPSA id w186sm8716609wme.26.2017.05.12.23.18.42 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 12 May 2017 23:18:43 -0700 (PDT) Date: Sat, 13 May 2017 06:18:00 -0000 User-Agent: K-9 Mail for Android In-Reply-To: <201705122042.v4CKgYk1028704@sellcey-dt.caveonetworks.com> References: <201705122042.v4CKgYk1028704@sellcey-dt.caveonetworks.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Subject: Re: Duplicating loops and virtual phis To: sellcey@cavium.com,Steve Ellcey ,gcc@gcc.gnu.org From: Richard Biener Message-ID: <0BB8C390-74E8-45EA-A4FF-438B53197254@gmail.com> X-IsSubscribed: yes X-SW-Source: 2017-05/txt/msg00123.txt.bz2 On May 12, 2017 10:42:34 PM GMT+02:00, Steve Ellcey wr= ote: >(Short version of this email, is there a way to recalculate/rebuild >virtual >phi nodes after modifying the CFG.) > >I have a question about duplicating loops and virtual phi nodes. >I am trying to implement the following optimization as a pass: > >Transform: > > for (i =3D 0; i < n; i++) { > A[i] =3D A[i] + B[i]; > C[i] =3D C[i-1] + D[i]; > } > >Into: > > if (noalias between A&B, A&C, A&D) > for (i =3D 0; i < 100; i++) > A[i] =3D A[i] + B[i]; > for (i =3D 0; i < 100; i++) > C[i] =3D C[i-1] + D[i]; > else > for (i =3D 0; i < 100; i++) { > A[i] =3D A[i] + B[i]; > C[i] =3D C[i-1] + D[i]; > } > >Right now the vectorizer sees that 'C[i] =3D C[i-1] + D[i];' cannot be >vectorized so it gives up and does not vectorize the loop. If we split >up the loop into two loops then the vector add with A[i] could be >vectorized >even if the one with C[i] could not. Loop distribution does this transform but it doesn't know about versioning = for unknown dependences. >Currently I can introduce the first 'if' that checks for aliasing by >using loop_version() and that seems to work OK. (My actual compare >for aliasing is actually just an approximation for now.) > >Where I am running into problems is with splitting up the single loop >under the noalias if condition into two sequential loops (which I then >intend to 'thin out' by removing one or the other set of instructions. >I am using slpeel_tree_duplicate_loop_to_edge_cfg() for that loop >duplication >and while I get the CFG I want, the pass ends with verify_ssa failing >due >to bad virtual/MEM PHI nodes. Perhaps there is a different function >that >I should use duplicate the loop. >a.c: In function =EF=BF=BD=EF=BF=BD=EF=BF=BDfoo=EF=BF=BD=EF=BF=BD=EF=BF=BD: >a.c:2:5: error: PHI node with wrong VUSE on edge from BB 13 > int foo(int *a, int *b, int *c, int *d, int n) > ^~~ >.MEM_40 =3D PHI <.MEM_15(D)(13), .MEM_34(9)> >expected .MEM_58 >a.c:2:5: internal compiler error: verify_ssa failed > >I have tried to fix up the PHI node by hand using SET_PHI_ARG_DEF but >have not had any luck. I was wondering if there was any kind of >'update all the phi nodes' function or just a 'update the virtual phi >nodes' function. The non-virtual PHI nodes seem to be OK, it is just >the virtual ones that seem wrong after I duplicate the loop into two >consecutive loops. > >Steve Ellcey >sellcey@cavium.com