public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "hubicka at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug tree-optimization/103266] [12 regression] llvm-13 miscompilation: __builtin_assume_aligned causes over-aggressive dce
Date: Mon, 15 Nov 2021 21:15:20 +0000	[thread overview]
Message-ID: <bug-103266-4-CLtR9lVSFR@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-103266-4@http.gcc.gnu.org/bugzilla/>

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

Jan Hubicka <hubicka at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |rguenther at suse dot de

--- Comment #2 from Jan Hubicka <hubicka at gcc dot gnu.org> ---
Thanks for a nice testcase!

We use "1cX " fnspec string_for assume aligned which indeed is problematic
since 'X' means that parameter is unused and thus we thus that it is not
returned.
"1" however specifies that function returns first parameter which is bit in a
contradiction with parameter being unused.  PTA codes takes precedence to "1"
and thus works, while modref sees 'X' and ignore the parameters and thus
propagation breaks.

In general we may have a specifier for pointer parameter that is used only as a
scalar value and never read/written from.  Perhaps 'S'? However I can also
teach modref to ignore unused for return handling.

Following untesed patch should fix the issue
diff --git a/gcc/builtins.c b/gcc/builtins.c
index 7d0f61fc98b..baeaff6eb1f 100644
--- a/gcc/builtins.c
+++ b/gcc/builtins.c
@@ -11101,7 +11101,7 @@ builtin_fnspec (tree callee)
       case BUILT_IN_STACK_SAVE:
        return ".c";
       case BUILT_IN_ASSUME_ALIGNED:
-       return "1cX ";
+       return "1cW ";
       /* But posix_memalign stores a pointer into the memory pointed to
         by its first argument.  */
       case BUILT_IN_POSIX_MEMALIGN:

  parent reply	other threads:[~2021-11-15 21:15 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-11-15 19:24 [Bug tree-optimization/103266] New: " slyfox at gcc dot gnu.org
2021-11-15 19:45 ` [Bug tree-optimization/103266] " jakub at gcc dot gnu.org
2021-11-15 21:15 ` hubicka at gcc dot gnu.org [this message]
2021-11-15 21:33 ` hubicka at gcc dot gnu.org
2021-11-16  7:26 ` rguenther at suse dot de
2021-11-16 10:03 ` hubicka at kam dot mff.cuni.cz
2021-11-16 10:23 ` rguenther at suse dot de
2021-11-18 17:08 ` hubicka at gcc dot gnu.org
2021-11-18 17:42 ` cvs-commit at gcc dot gnu.org
2021-11-20 10:34 ` hubicka 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-103266-4-CLtR9lVSFR@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).