From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 24779 invoked by alias); 23 Jun 2011 12:17:24 -0000 Received: (qmail 24760 invoked by uid 22791); 23 Jun 2011 12:17:16 -0000 X-SWARE-Spam-Status: No, hits=-2.7 required=5.0 tests=ALL_TRUSTED,AWL,BAYES_00 X-Spam-Check-By: sourceware.org Received: from localhost (HELO gcc.gnu.org) (127.0.0.1) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Thu, 23 Jun 2011 12:17:02 +0000 From: "vincenzo.innocente at cern dot ch" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/49513] PRE inhibits if-conversion and vectorization X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: tree-optimization X-Bugzilla-Keywords: missed-optimization X-Bugzilla-Severity: major X-Bugzilla-Who: vincenzo.innocente at cern dot ch X-Bugzilla-Status: NEW X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated Content-Type: text/plain; charset="UTF-8" MIME-Version: 1.0 Date: Thu, 23 Jun 2011 12:17:00 -0000 Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org X-SW-Source: 2011-06/txt/msg02075.txt.bz2 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49513 --- Comment #2 from vincenzo Innocente 2011-06-23 12:16:59 UTC --- thanks for the fast analysis. the code in question was there also to test what the vectorized code would do for x=0 and y=0 (it is extracted from a simplified version of atan2f that gcc can vectorize). Being a test, I can workaround (I've to test extreme conditions explicitely anyhow). In any case I think that any peeling will ruin alignmement. hoping gcc can find ways to avoid PRE and vectorization to clash. vincenzo On 23 Jun, 2011, at 1:55 PM, rguenth at gcc dot gnu.org wrote: > http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49513 > > Richard Guenther changed: > > What |Removed |Added > ---------------------------------------------------------------------------- > Status|UNCONFIRMED |NEW > Keywords| |missed-optimization > Last reconfirmed| |2011.06.23 11:55:09 > CC| |rguenth at gcc dot gnu.org > Ever Confirmed|0 |1 > Summary|introducing a product |PRE inhibits if-conversion > |inhibit vectorization |and vectorization > > --- Comment #1 from Richard Guenther 2011-06-23 11:55:09 UTC --- > That is because PRE decided to optimize the first iteration where it knows > that z == 0 and thus z*s[i] and z*c[i] are 0 and thus a[i] will be 0. Which > means we confuse if-conversion which in turn causes this missed vectorization. > IL before if-conversion: > > : > goto ; > > : > z_3 = (float) i_9; > D.3280_4 = c[i_9]; > D.3281_5 = D.3280_4 * z_3; > D.3282_6 = s[i_9]; > D.3283_7 = D.3282_6 * z_3; > yy_13 = ABS_EXPR ; > yy_14 = ABS_EXPR ; > if (yy_13 < yy_14) > goto ; > else > goto ; > > : > > : > # yy_28 = PHI > # yy_29 = PHI > > : > # yy_16 = PHI > # yy_15 = PHI > # i_30 = PHI > # ivtmp.44_24 = PHI > t_17 = yy_15 / yy_16; > a[i_30] = t_17; > i_9 = i_30 + 1; > ivtmp.44_10 = ivtmp.44_24 - 1; > if (ivtmp.44_10 != 0) > goto ; > else > goto ; > > : > return; > > The PHI nodes in bb 6 is what makes if-conversion fail (thus, the > irregular loop entry which really should be peeled off). > > This situation commonly occurs when PRE can compute the first iterations > result. Manually peeling off the iteration like the following is a > workaround: > > void foo2() { > a[0] = 0; > for (int i=1; i!=1024; ++i) { > float z = i; > a[i] = bar(z*s[i],z*c[i]); > } > } > > Not sure if your original issue you derived this testcase from really > matches the above problem though. > > -- > Configure bugmail: http://gcc.gnu.org/bugzilla/userprefs.cgi?tab=email > ------- You are receiving this mail because: ------- > You reported the bug. -- Il est bon de suivre sa pente, pourvu que ce soit en montant. A.G. http://www.flickr.com/photos/vin60/1320965757/