public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "rguenther at suse dot de" <gcc-bugzilla@gcc.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 13:18:00 -0000	[thread overview]
Message-ID: <bug-53957-4-RVJbD441V8@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-53957-4@http.gcc.gnu.org/bugzilla/>

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53957

--- Comment #5 from rguenther at suse dot de <rguenther at suse dot de> 2012-07-18 13:18:13 UTC ---
On Wed, 18 Jul 2012, burnus at gcc dot gnu.org wrote:

> http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53957
> 
> Tobias Burnus <burnus at gcc dot gnu.org> changed:
> 
>            What    |Removed                     |Added
> ----------------------------------------------------------------------------
>                  CC|                            |burnus at gcc dot gnu.org
> 
> --- Comment #4 from Tobias Burnus <burnus at gcc dot gnu.org> 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):
> 
> ------------<cut>-----------------
>    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.  */

If you do

>    [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
         exit = countm1 == 0;
         countm1--;
>        if (exit) goto exit_label;
>      }
> exit_label:

it would work for this case.


  parent reply	other threads:[~2012-07-18 13:18 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-07-13 20:00 [Bug middle-end/53957] New: " burnus at gcc dot gnu.org
2012-07-18 11:26 ` [Bug middle-end/53957] " rguenth at gcc dot gnu.org
2012-07-18 12:02 ` rguenth at gcc dot gnu.org
2012-07-18 12:09 ` [Bug fortran/53957] " rguenth at gcc dot gnu.org
2012-07-18 12:46 ` burnus at gcc dot gnu.org
2012-07-18 13:18 ` rguenther at suse dot de [this message]
2012-07-18 14:05 ` burnus at gcc dot gnu.org
2012-07-18 14:48 ` rguenth at gcc dot gnu.org
2012-07-26  9:59 ` burnus at gcc dot gnu.org
2012-07-26 10:19 ` rguenth at gcc dot gnu.org
2012-09-11 15:02 ` rguenth at gcc dot gnu.org
2013-01-16 22:53 ` burnus at gcc dot gnu.org
2013-06-10  4:41 ` prop_design at yahoo dot com
2013-06-10 17:44 ` prop_design at yahoo dot com
2013-06-22 13:04 ` dominiq at lps dot ens.fr
2013-06-23  5:25 ` prop_design at yahoo dot com
2020-06-27 23:34 ` prop_design at protonmail dot com
2020-06-28 10:49 ` tkoenig at gcc dot gnu.org
2020-06-28 11:03 ` tkoenig at gcc dot gnu.org
2020-06-28 15:40 ` prop_design at protonmail dot com
2020-06-29  9:36 ` rguenther at suse dot de
2020-06-29 14:09 ` prop_design at protonmail dot com
2020-07-29 22:25 ` prop_design at protonmail dot com

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-53957-4-RVJbD441V8@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).