public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "rguenth at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c++/112414] Does gcc need __builtin_assume_separate_storage?
Date: Tue, 07 Nov 2023 08:42:53 +0000	[thread overview]
Message-ID: <bug-112414-4-eexI7sVWfv@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-112414-4@http.gcc.gnu.org/bugzilla/>

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

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |rguenth at gcc dot gnu.org
         Resolution|---                         |WONTFIX
             Status|UNCONFIRMED                 |RESOLVED

--- Comment #1 from Richard Biener <rguenth at gcc dot gnu.org> ---
__builtin_assume_separate_storage

__builtin_assume_separate_storage is used to provide the optimizer with the
knowledge that its two arguments point to separately allocated objects.

Syntax:

__builtin_assume_separate_storage(const volatile void *, const volatile void *)

Example of Use:

int foo(int *x, int *y) {
    __builtin_assume_separate_storage(x, y);
    *x = 0;
    *y = 1;
    // The optimizer may optimize this to return 0 without reloading from *x.
    return *x;
}

Description:

The arguments to this function are assumed to point into separately allocated
storage (either different variable definitions or different dynamic storage
allocations). The optimizer may use this fact to aid in alias analysis. If the
arguments point into the same storage, the behavior is undefined. Note that the
definition of “storage” here refers to the outermost enclosing allocation of
any particular object (so for example, it’s never correct to call this function
passing the addresses of fields in the same struct, elements of the same array,
etc.).

Query for this feature with __has_builtin(__builtin_assume_separate_storage).


---

The given syntax makes it very unuseful given there's no data dependence
involved.  I assume it is supposed to work like

 typeof (x) __restrict xr = x;
 typeof (y) __restrict yr = y;
 *xr = 0;
 *yr = 1;

not sure why clang folks thought a new builtin is a great idea.  Even this
restrict form is more useful (but there's reasons we don't support that
either).

So no, RESOLVED BADFEATURE.

      parent reply	other threads:[~2023-11-07  8:42 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-11-06 20:14 [Bug c++/112414] New: " unlvsur at live dot com
2023-11-06 20:19 ` [Bug c++/112414] " pinskia at gcc dot gnu.org
2023-11-07  8:42 ` rguenth at gcc dot gnu.org [this message]

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