From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 32584 invoked by alias); 18 Jul 2012 12:46:45 -0000 Received: (qmail 32574 invoked by uid 22791); 18 Jul 2012 12:46:44 -0000 X-SWARE-Spam-Status: No, hits=-4.3 required=5.0 tests=ALL_TRUSTED,AWL,BAYES_00,KHOP_THREADED 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; Wed, 18 Jul 2012 12:46:30 +0000 From: "burnus at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug fortran/53957] Polyhedron 11 benchmark: MP_PROP_DESIGN twice as long as other compiler Date: Wed, 18 Jul 2012 12:46:00 -0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: fortran X-Bugzilla-Keywords: missed-optimization X-Bugzilla-Severity: normal X-Bugzilla-Who: burnus 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: CC 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 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: 2012-07/txt/msg01397.txt.bz2 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53957 Tobias Burnus changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |burnus at gcc dot gnu.org --- Comment #4 from Tobias Burnus 2012-07-18 12:46:29 UTC --- (In reply to comment #3) > It would be better to have this similar to other loops I see, > > bool flag = end-value == i; > i = i + 1; > if (flag) goto loop_exit; That's not that simple as one might not reach the end value due to the step. If "step" is (plus or minus) unity and if one has integers (and not reals, added in Fortran 77, deleted in Fortran 90), it is simple. But if abs(step) != 1 or if the loop variable is not an integer, one either needs to calculate the number of trips beforehand, or has to use ">" or "<" rather than "==". The problem with "<" / ">" is that one has to do another comparison, unless the sign of "step" is known: if (step > 0 ? dovar > to : dovar < to) goto exit_label; I don't see whether that version is better than the current version. Suggestions or comments? The current code is (comment from trans-stmt.c's gfc_trans_do): ----------------------------- We translate a do loop from: DO dovar = from, to, step body END DO to: [evaluate loop bounds and step] empty = (step > 0 ? to < from : to > from); countm1 = (to - from) / step; dovar = from; if (empty) goto exit_label; for (;;) { body; cycle_label: dovar += step if (countm1 ==0) goto exit_label; countm1--; } exit_label: countm1 is an unsigned integer. It is equal to the loop count minus one, because the loop count itself can overflow. */ -----------------------------