From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id A20903858C53; Thu, 20 Jul 2023 22:42:02 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org A20903858C53 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1689892922; bh=MTBmVivcxArKxmjYgE+cmD6qI5002ib1cwpn8sjUxEg=; h=From:To:Subject:Date:In-Reply-To:References:From; b=BOmuPOETY7pPIAUpAi5pzAntr501NHvtYd4+8NNauo+aY8CRfKizgcFXStzS9o36q w/r3oUGeIIu01BYHwHypu4FSEBNFPSJNNhRp4mBSwB6kGy0DUnt0aulM0DzJ2LrRIR 3d49Qrvbn+PQ7gfbPjGYNfYNrMSqMjkYYrEHHJAg= From: "pinskia at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug middle-end/110754] assume create spurious load for volatile variable Date: Thu, 20 Jul 2023 22:42:02 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: middle-end X-Bugzilla-Version: 14.0 X-Bugzilla-Keywords: wrong-code X-Bugzilla-Severity: normal X-Bugzilla-Who: pinskia at gcc dot gnu.org X-Bugzilla-Status: NEW X-Bugzilla-Resolution: 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: cf_reconfirmed_on bug_status everconfirmed keywords component 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=3D110754 Andrew Pinski changed: What |Removed |Added ---------------------------------------------------------------------------- Last reconfirmed| |2023-07-20 Status|UNCONFIRMED |NEW Ever confirmed|0 |1 Keywords| |wrong-code Component|c++ |middle-end --- Comment #2 from Andrew Pinski --- (In reply to Xi Ruoyao from comment #1) > Is this a bug? The standard defines accessing volatile objects as > side-effects so it's not allowed to merge volatile loads, AFAIU. Yes because assume attribute is defined not to have any side effects. Confirmed. gimplifier produces: [[assume (D.2786)]] { { int n.0; n.0 =3D n; D.2786 =3D n.0 =3D=3D 1; } } And then lowering produces: _2 =3D n; .ASSUME (_Z3bari._assume.0, _2); But really it should have passed the address of n rather than the value sin= ce n is volatile here .=