From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 120298 invoked by alias); 9 Mar 2015 12:06:38 -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 Received: (qmail 120241 invoked by uid 48); 9 Mar 2015 12:06:35 -0000 From: "rguenth at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/65335] Potential optimization issue with 'tree-loop-vectorize' Date: Mon, 09 Mar 2015 12:06:00 -0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: tree-optimization X-Bugzilla-Version: 4.9.2 X-Bugzilla-Keywords: missed-optimization X-Bugzilla-Severity: normal X-Bugzilla-Who: rguenth at gcc dot gnu.org X-Bugzilla-Status: NEW X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: keywords bug_status cf_reconfirmed_on cc everconfirmed Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-SW-Source: 2015-03/txt/msg00924.txt.bz2 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65335 Richard Biener changed: What |Removed |Added ---------------------------------------------------------------------------- Keywords| |missed-optimization Status|UNCONFIRMED |NEW Last reconfirmed| |2015-03-09 CC| |law at gcc dot gnu.org, | |rguenth at gcc dot gnu.org Ever confirmed|0 |1 --- Comment #1 from Richard Biener --- This is if-conversion at work making the code vectorizable. You can disable it with -fno-tree-loop-if-convert. It's not easy to assess profitablility here (well, locally it should use bb frequencies), as computing a*a*a*a*a always could be a win if vectorizing the rest of the loop compensates for the cost. In this case the optimal thing to do is to turn the loop into a loop nest. Not sure how you'd call this kind of loop transform - sth with unswitching IV-based conditions (it's not exactly splitting in this case). We want for (int j = 0; j < 10000/1000; j++){ int i; for (i = j*1000; i < 999; ++i) buffer[i] = a; a = a * a * a * a * a; buffer[i] = a; } so we can vectorize the inner loop and don't need to evaluate the conditional there.