From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 7B2213858C2C; Tue, 7 Nov 2023 08:42:58 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 7B2213858C2C DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1699346578; bh=yBZ5xQ7F8PWuG0Q+00SsZoZ2+sQ83ie++pEDSJP2jdU=; h=From:To:Subject:Date:In-Reply-To:References:From; b=dXS+DOFqGEsi1xJjA65Pflnjd1P4idg8TnVr5IoCay/SxBwDsNSMijHEW5oFUbh6c aodMSXn8GoT1tbxrnVK1KHczqLvm+jPxIr9T6puezmLFpkHDrZmkcJUgKoMcdkxdsc QjRMnLKeEdbpA+bGOgbTO1TtAKj/38OMYqdu0VtM= From: "rguenth at gcc dot 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 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c++ X-Bugzilla-Version: 14.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: enhancement X-Bugzilla-Who: rguenth at gcc dot gnu.org X-Bugzilla-Status: RESOLVED X-Bugzilla-Resolution: WONTFIX X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: cc resolution bug_status Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 List-Id: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D112414 Richard Biener changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |rguenth at gcc dot gnu.org Resolution|--- |WONTFIX Status|UNCONFIRMED |RESOLVED --- Comment #1 from Richard Biener --- __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 voi= d *) Example of Use: int foo(int *x, int *y) { __builtin_assume_separate_storage(x, y); *x =3D 0; *y =3D 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 allocat= ed 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 =E2=80=9Cstorage=E2=80=9D here refers to the outermost enclos= ing allocation of any particular object (so for example, it=E2=80=99s never correct to call t= his function passing the addresses of fields in the same struct, elements of the same ar= ray, 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 =3D x; typeof (y) __restrict yr =3D y; *xr =3D 0; *yr =3D 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.=