public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/100988] New: Missed optimization: RESTRICT missing for optional arguments
@ 2021-06-09  8:54 burnus at gcc dot gnu.org
  2021-09-09 21:09 ` [Bug fortran/100988] " anlauf at gcc dot gnu.org
                   ` (7 more replies)
  0 siblings, 8 replies; 9+ messages in thread
From: burnus at gcc dot gnu.org @ 2021-06-09  8:54 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 100988
           Summary: Missed optimization: RESTRICT missing for optional
                    arguments
           Product: gcc
           Version: 12.0
            Status: UNCONFIRMED
          Keywords: missed-optimization
          Severity: normal
          Priority: P3
         Component: fortran
          Assignee: unassigned at gcc dot gnu.org
          Reporter: burnus at gcc dot gnu.org
  Target Milestone: ---

For
  subroutine foo(a, b)
    integer :: a, b
    optional :: b
    ...
  end subroutine

only the TREE_TYPE of 'a' has the restrict qualifier – and not 'b'.

I think that there is no good reason for this – and wonder whether the
following should be applied:

diff --git a/gcc/fortran/trans-types.c b/gcc/fortran/trans-types.c
index 5582e404df9..c4b4387c1e2 100644
--- a/gcc/fortran/trans-types.c
+++ b/gcc/fortran/trans-types.c
@@ -2338,11 +2338,9 @@ gfc_sym_type (gfc_symbol * sym)
          || (sym->ns->proc_name && sym->ns->proc_name->attr.entry_master))
        type = build_pointer_type (type);
       else
-       {
-         type = build_reference_type (type);
-         if (restricted)
-           type = build_qualified_type (type, TYPE_QUAL_RESTRICT);
-       }
+       type = build_reference_type (type);
+      if (restricted)
+       type = build_qualified_type (type, TYPE_QUAL_RESTRICT);
     }

   return (type);

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug fortran/100988] Missed optimization: RESTRICT missing for optional arguments
  2021-06-09  8:54 [Bug fortran/100988] New: Missed optimization: RESTRICT missing for optional arguments burnus at gcc dot gnu.org
@ 2021-09-09 21:09 ` anlauf at gcc dot gnu.org
  2021-09-09 21:10 ` anlauf at gcc dot gnu.org
                   ` (6 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: anlauf at gcc dot gnu.org @ 2021-09-09 21:09 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #1 from anlauf at gcc dot gnu.org ---
*** Bug 53699 has been marked as a duplicate of this bug. ***

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug fortran/100988] Missed optimization: RESTRICT missing for optional arguments
  2021-06-09  8:54 [Bug fortran/100988] New: Missed optimization: RESTRICT missing for optional arguments burnus at gcc dot gnu.org
  2021-09-09 21:09 ` [Bug fortran/100988] " anlauf at gcc dot gnu.org
@ 2021-09-09 21:10 ` anlauf at gcc dot gnu.org
  2023-12-03 21:59 ` anlauf at gcc dot gnu.org
                   ` (5 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: anlauf at gcc dot gnu.org @ 2021-09-09 21:10 UTC (permalink / raw)
  To: gcc-bugs

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

anlauf at gcc dot gnu.org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Last reconfirmed|                            |2021-09-09
             Status|UNCONFIRMED                 |NEW
     Ever confirmed|0                           |1

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug fortran/100988] Missed optimization: RESTRICT missing for optional arguments
  2021-06-09  8:54 [Bug fortran/100988] New: Missed optimization: RESTRICT missing for optional arguments burnus at gcc dot gnu.org
  2021-09-09 21:09 ` [Bug fortran/100988] " anlauf at gcc dot gnu.org
  2021-09-09 21:10 ` anlauf at gcc dot gnu.org
@ 2023-12-03 21:59 ` anlauf at gcc dot gnu.org
  2023-12-04 21:53 ` anlauf at gcc dot gnu.org
                   ` (4 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: anlauf at gcc dot gnu.org @ 2023-12-03 21:59 UTC (permalink / raw)
  To: gcc-bugs

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

anlauf at gcc dot gnu.org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |anlauf at gcc dot gnu.org

--- Comment #2 from anlauf at gcc dot gnu.org ---
Created attachment 56781
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=56781&action=edit
Improved patch

When looking at testcases, it appeared that POINTER attributes of CLASS dummy
arguments were not properly handled.  This is fixed by the attached patch.

@Tobias: may I proceed with this PR, or is there something else I am missing?

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug fortran/100988] Missed optimization: RESTRICT missing for optional arguments
  2021-06-09  8:54 [Bug fortran/100988] New: Missed optimization: RESTRICT missing for optional arguments burnus at gcc dot gnu.org
                   ` (2 preceding siblings ...)
  2023-12-03 21:59 ` anlauf at gcc dot gnu.org
@ 2023-12-04 21:53 ` anlauf at gcc dot gnu.org
  2023-12-05 18:16 ` cvs-commit at gcc dot gnu.org
                   ` (3 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: anlauf at gcc dot gnu.org @ 2023-12-04 21:53 UTC (permalink / raw)
  To: gcc-bugs

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

anlauf at gcc dot gnu.org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Assignee|unassigned at gcc dot gnu.org      |anlauf at gcc dot gnu.org

--- Comment #3 from anlauf at gcc dot gnu.org ---
Submitted: https://gcc.gnu.org/pipermail/fortran/2023-December/059985.html

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug fortran/100988] Missed optimization: RESTRICT missing for optional arguments
  2021-06-09  8:54 [Bug fortran/100988] New: Missed optimization: RESTRICT missing for optional arguments burnus at gcc dot gnu.org
                   ` (3 preceding siblings ...)
  2023-12-04 21:53 ` anlauf at gcc dot gnu.org
@ 2023-12-05 18:16 ` cvs-commit at gcc dot gnu.org
  2023-12-05 20:58 ` anlauf at gcc dot gnu.org
                   ` (2 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2023-12-05 18:16 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #4 from GCC Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Harald Anlauf <anlauf@gcc.gnu.org>:

https://gcc.gnu.org/g:9c3a880feecf81c310b4ade210fbd7004c9aece7

commit r14-6191-g9c3a880feecf81c310b4ade210fbd7004c9aece7
Author: Harald Anlauf <anlauf@gmx.de>
Date:   Mon Dec 4 22:44:53 2023 +0100

    Fortran: allow RESTRICT qualifier also for optional arguments [PR100988]

    gcc/fortran/ChangeLog:

            PR fortran/100988
            * gfortran.h (IS_PROC_POINTER): New macro.
            * trans-types.cc (gfc_sym_type): Use macro in determination if the
            restrict qualifier can be used for a dummy variable.  Fix logic to
            allow the restrict qualifier also for optional arguments, and to
            not apply it to pointer or proc_pointer arguments.

    gcc/testsuite/ChangeLog:

            PR fortran/100988
            * gfortran.dg/coarray_poly_6.f90: Adjust pattern.
            * gfortran.dg/coarray_poly_7.f90: Likewise.
            * gfortran.dg/coarray_poly_8.f90: Likewise.
            * gfortran.dg/missing_optional_dummy_6a.f90: Likewise.
            * gfortran.dg/pr100988.f90: New test.

    Co-authored-by: Tobias Burnus  <tobias@codesourcery.com>

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug fortran/100988] Missed optimization: RESTRICT missing for optional arguments
  2021-06-09  8:54 [Bug fortran/100988] New: Missed optimization: RESTRICT missing for optional arguments burnus at gcc dot gnu.org
                   ` (4 preceding siblings ...)
  2023-12-05 18:16 ` cvs-commit at gcc dot gnu.org
@ 2023-12-05 20:58 ` anlauf at gcc dot gnu.org
  2024-03-15 21:08 ` cvs-commit at gcc dot gnu.org
  2024-03-15 21:16 ` anlauf at gcc dot gnu.org
  7 siblings, 0 replies; 9+ messages in thread
From: anlauf at gcc dot gnu.org @ 2023-12-05 20:58 UTC (permalink / raw)
  To: gcc-bugs

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

anlauf at gcc dot gnu.org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Resolution|---                         |FIXED
   Target Milestone|---                         |14.0
             Status|NEW                         |RESOLVED

--- Comment #5 from anlauf at gcc dot gnu.org ---
Fixed in gcc-14.

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug fortran/100988] Missed optimization: RESTRICT missing for optional arguments
  2021-06-09  8:54 [Bug fortran/100988] New: Missed optimization: RESTRICT missing for optional arguments burnus at gcc dot gnu.org
                   ` (5 preceding siblings ...)
  2023-12-05 20:58 ` anlauf at gcc dot gnu.org
@ 2024-03-15 21:08 ` cvs-commit at gcc dot gnu.org
  2024-03-15 21:16 ` anlauf at gcc dot gnu.org
  7 siblings, 0 replies; 9+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2024-03-15 21:08 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #6 from GCC Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-13 branch has been updated by Harald Anlauf
<anlauf@gcc.gnu.org>:

https://gcc.gnu.org/g:337dc58139595bd9ab4101b988078c5d54d8506a

commit r13-8444-g337dc58139595bd9ab4101b988078c5d54d8506a
Author: Harald Anlauf <anlauf@gmx.de>
Date:   Mon Dec 4 22:44:53 2023 +0100

    Fortran: allow RESTRICT qualifier also for optional arguments [PR100988]

    gcc/fortran/ChangeLog:

            PR fortran/100988
            * gfortran.h (IS_PROC_POINTER): New macro.
            * trans-types.cc (gfc_sym_type): Use macro in determination if the
            restrict qualifier can be used for a dummy variable.  Fix logic to
            allow the restrict qualifier also for optional arguments, and to
            not apply it to pointer or proc_pointer arguments.

    gcc/testsuite/ChangeLog:

            PR fortran/100988
            * gfortran.dg/coarray_poly_6.f90: Adjust pattern.
            * gfortran.dg/coarray_poly_7.f90: Likewise.
            * gfortran.dg/coarray_poly_8.f90: Likewise.
            * gfortran.dg/missing_optional_dummy_6a.f90: Likewise.
            * gfortran.dg/pr100988.f90: New test.

    Co-authored-by: Tobias Burnus  <tobias@codesourcery.com>
    (cherry picked from commit 9c3a880feecf81c310b4ade210fbd7004c9aece7)

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug fortran/100988] Missed optimization: RESTRICT missing for optional arguments
  2021-06-09  8:54 [Bug fortran/100988] New: Missed optimization: RESTRICT missing for optional arguments burnus at gcc dot gnu.org
                   ` (6 preceding siblings ...)
  2024-03-15 21:08 ` cvs-commit at gcc dot gnu.org
@ 2024-03-15 21:16 ` anlauf at gcc dot gnu.org
  7 siblings, 0 replies; 9+ messages in thread
From: anlauf at gcc dot gnu.org @ 2024-03-15 21:16 UTC (permalink / raw)
  To: gcc-bugs

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

anlauf at gcc dot gnu.org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|14.0                        |13.3

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2024-03-15 21:16 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-06-09  8:54 [Bug fortran/100988] New: Missed optimization: RESTRICT missing for optional arguments burnus at gcc dot gnu.org
2021-09-09 21:09 ` [Bug fortran/100988] " anlauf at gcc dot gnu.org
2021-09-09 21:10 ` anlauf at gcc dot gnu.org
2023-12-03 21:59 ` anlauf at gcc dot gnu.org
2023-12-04 21:53 ` anlauf at gcc dot gnu.org
2023-12-05 18:16 ` cvs-commit at gcc dot gnu.org
2023-12-05 20:58 ` anlauf at gcc dot gnu.org
2024-03-15 21:08 ` cvs-commit at gcc dot gnu.org
2024-03-15 21:16 ` anlauf at gcc dot gnu.org

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).