public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "cvs-commit at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug fortran/107424] [13/14 Regression] ICE in gfc_trans_omp_do, at fortran/trans-openmp.cc:5397 - and wrong code - with non-rectangular loops
Date: Wed, 19 Jul 2023 08:19:49 +0000	[thread overview]
Message-ID: <bug-107424-4-o2b9oiAzpg@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-107424-4@http.gcc.gnu.org/bugzilla/>

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107424

--- Comment #15 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Tobias Burnus <burnus@gcc.gnu.org>:

https://gcc.gnu.org/g:85da0b40538fb0d17d89de1e7905984668e3dfef

commit r14-2634-g85da0b40538fb0d17d89de1e7905984668e3dfef
Author: Tobias Burnus <tobias@codesourcery.com>
Date:   Wed Jul 19 10:18:49 2023 +0200

    OpenMP/Fortran: Non-rectangular loops with constant steps other than 1 or
-1 [PR107424]

    Before this commit, gfortran produced with OpenMP for 'do i = 1,10,2'
    the code
      for (count.0 = 0; count.0 < 5; count.0 = count.0 + 1)
        i = count.0 * 2 + 1;

    While such an inner loop can be collapsed, a non-rectangular could not.
    With this commit and for all constant loop steps, a simple loop such
    as 'for (i = 1; i <= 10; i = i + 2)' is created. (Before only for the
    constant steps of 1 and -1.)

    The constant step permits to know the direction (increasing/decreasing)
    that is required for the loop condition.

    The new code is only valid if one assumes no overflow of the loop variable.
    However, the Fortran standard can be read that this must be ensured by
    the user. Namely, the Fortran standard requires (F2023, 10.1.5.2.4):
    "The execution of any numeric operation whose result is not defined by
    the arithmetic used by the processor is prohibited."

    And, for DO loops, F2023's "11.1.7.4.3 The execution cycle" has the
    following: The number of loop iterations handled by an iteration count,
    which would permit code like 'do i = huge(i)-5, huge(i),4'. However,
    in step (3), this count is not only decremented by one but also:
      "... The DO variable, if any, is incremented by the value of the
      incrementation parameter m3."
    And for the example above, 'i' would be 'huge(i)+3' in the last
    execution cycle, which exceeds the largest model number and should
    render the example as invalid.

            PR fortran/107424

    gcc/fortran/ChangeLog:

            * trans-openmp.cc (gfc_nonrect_loop_expr): Accept all
            constant loop steps.
            (gfc_trans_omp_do): Likewise; use sign to determine
            loop direction.

    libgomp/ChangeLog:

            * libgomp.texi (Impl. Status 5.0): Add link to new PR110735.
            * testsuite/libgomp.fortran/non-rectangular-loop-1.f90: Enable
            commented tests.
            * testsuite/libgomp.fortran/non-rectangular-loop-1a.f90: Remove
            test file; tests are in non-rectangular-loop-1.f90.
            * testsuite/libgomp.fortran/non-rectangular-loop-5.f90: Change
            testcase to use a non-constant step to retain the 'sorry' test.
            * testsuite/libgomp.fortran/non-rectangular-loop-6.f90: New test.

    gcc/testsuite/ChangeLog:

            * gfortran.dg/gomp/linear-2.f90: Update dump to remove
            the additional count variable.

  parent reply	other threads:[~2023-07-19  8:20 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-10-26 18:37 [Bug fortran/107424] New: [13 Regression] ICE in gfc_trans_omp_do, at fortran/trans-openmp.cc:5397 gscfq@t-online.de
2022-10-27  8:50 ` [Bug fortran/107424] " marxin at gcc dot gnu.org
2022-10-28 11:35 ` rguenth at gcc dot gnu.org
2023-01-11 15:30 ` [Bug fortran/107424] [13 Regression] ICE in gfc_trans_omp_do, at fortran/trans-openmp.cc:5397 - and wrong code - with non-rectangular loops burnus at gcc dot gnu.org
2023-01-11 15:59 ` burnus at gcc dot gnu.org
2023-01-13 10:46 ` burnus at gcc dot gnu.org
2023-01-13 10:53 ` burnus at gcc dot gnu.org
2023-01-13 11:07 ` jakub at gcc dot gnu.org
2023-01-13 11:46 ` burnus at gcc dot gnu.org
2023-01-13 11:51 ` jakub at gcc dot gnu.org
2023-01-18 22:24 ` burnus at gcc dot gnu.org
2023-01-25 14:50 ` burnus at gcc dot gnu.org
2023-02-09 14:51 ` cvs-commit at gcc dot gnu.org
2023-02-09 14:54 ` burnus at gcc dot gnu.org
2023-04-26  6:56 ` [Bug fortran/107424] [13/14 " rguenth at gcc dot gnu.org
2023-07-17 11:15 ` burnus at gcc dot gnu.org
2023-07-19  8:19 ` cvs-commit at gcc dot gnu.org [this message]
2023-07-19  8:27 ` burnus at gcc dot gnu.org

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-107424-4-o2b9oiAzpg@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).