From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id A22703858426; Thu, 20 Jul 2023 22:45:10 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org A22703858426 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1689893110; bh=iKVv0eFkSwnAhIxSiuMJ71eFpZR/ycDa6aYVE4eR1cU=; h=From:To:Subject:Date:In-Reply-To:References:From; b=PZk/5pO4aAWPshlcg4tdN44xpEqoj1PWUIL5FdUgKLDVHZRa897rzQaL9cUspRMSa sgo6c0AO4skg/sGpgKiI8ILn5JkOlh4hzKyXBme2HN+kih/pbr/a3lIhhyC73dHdTf sExASJFIrs2G0csnnHkBY/IWI7W8UzFDGf6fqi1w= From: "xry111 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:45:10 +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: xry111 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: 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 --- Comment #4 from Xi Ruoyao --- (In reply to Andrew Pinski from comment #2) > (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. >=20 > Yes because assume attribute is defined not to have any side effects. >=20 > Confirmed. >=20 > gimplifier produces: >=20 > [[assume (D.2786)]] > { > { > int n.0; >=20 > n.0 =3D n; > D.2786 =3D n.0 =3D=3D 1; > } > } >=20 > And then lowering produces: > _2 =3D n; > .ASSUME (_Z3bari._assume.0, _2); >=20 > But really it should have passed the address of n rather than the value > since n is volatile here . Alright, I mistakenly believed [[assume(x)]]; is same as if (!x) unreachable();.=