public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "burnus at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug fortran/100988] New: Missed optimization: RESTRICT missing for optional arguments
Date: Wed, 09 Jun 2021 08:54:33 +0000	[thread overview]
Message-ID: <bug-100988-4@http.gcc.gnu.org/bugzilla/> (raw)

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

             reply	other threads:[~2021-06-09  8:54 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-06-09  8:54 burnus at gcc dot gnu.org [this message]
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

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