From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 97E303858CDB; Thu, 18 Apr 2024 13:19:52 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 97E303858CDB DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1713446392; bh=DFusAjbVvJtDE2Y2aIzgKqyt9AcD51+hHRlooxLJnCY=; h=From:To:Subject:Date:From; b=Tt6Uvz/jiBh/kP6+6pOxzmmgEXCXqyH967fQB0DbDcqyH2gxjx0JGzEj2Zs/yx3Rt Pmi4IPIhwKO7/BeIW9jebVbJ22FGf1/SFv3uJnHQFHC3g6Eg3HvpI1Vod9JcWzGzFn c1LmdxD3rHiFe7V4iMEcD/Gnxg0RdrMxu4rSkQxc= From: "bouanto at zoho dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug rtl-optimization/114768] New: Volatile reads can be optimized away Date: Thu, 18 Apr 2024 13:19:52 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: rtl-optimization X-Bugzilla-Version: 14.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: bouanto at zoho dot com X-Bugzilla-Status: UNCONFIRMED 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: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter target_milestone Message-ID: 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=3D114768 Bug ID: 114768 Summary: Volatile reads can be optimized away Product: gcc Version: 14.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: rtl-optimization Assignee: unassigned at gcc dot gnu.org Reporter: bouanto at zoho dot com Target Milestone: --- In the following code: void test(int *ptr) { *ptr =3D *(volatile int *)ptr; } The volatile read is optimized away and GCC produces the following asm: test(int*): ret Godbolt link: https://gcc.godbolt.org/z/rabToGfqj Clang produces the following code: test(int*): # @test(int*) mov eax, dword ptr [rdi] ret which is likely to be the expected behavior.=