From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 5228 invoked by alias); 22 Mar 2013 13:30:23 -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 5095 invoked by uid 48); 22 Mar 2013 13:29:58 -0000 From: "rguenth at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/56688] Fortran save statement prevents loop vectorization. Date: Fri, 22 Mar 2013 13:30: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-Keywords: 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-Changed-Fields: Status Last reconfirmed Blocks Ever Confirmed 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 X-SW-Source: 2013-03/txt/msg01513.txt.bz2 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=56688 Richard Biener changed: What |Removed |Added ---------------------------------------------------------------------------- Status|UNCONFIRMED |NEW Last reconfirmed| |2013-03-22 Blocks| |53947 Ever Confirmed|0 |1 --- Comment #1 from Richard Biener 2013-03-22 13:29:57 UTC --- The issue is that x is kept live by applying store-motion: : # prephitmp_26 = PHI <1(2), i.3_14(4)> # ivtmp_30 = PHI <700(2), ivtmp_15(4)> _5 = (integer(kind=8)) prephitmp_26; _6 = _5 + -1; _7 = my_data.x1[_6]; _8 = my_data.y1[_6]; x.1_9 = _7 - _8; _11 = my_data.t1[_6]; _12 = x.1_9 * _11; my_data.z1[_6] = _12; i.3_14 = prephitmp_26 + 1; ivtmp_15 = ivtmp_30 - 1; if (ivtmp_15 == 0) goto ; else goto ; : goto ; : # x_lsm.7_25 = PHI x = x_lsm.7_25; i = 701; return; because it appears that 'save' makes all variables global ones. This kind of "reduction" is not handled by the vectorizer. If would be handled by a pass that re-materializes x_lsm.7_25 from memory and operations after the loop. Or by handling the "final" value properly by means of vector extraction or in the epilogue loop, simply using it, or forcing at least one iteration of the epilogue loop by adjusting the number of iterations of the vectorized loop. I like the last option most ;)