From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 6FF263858402; Thu, 21 Dec 2023 12:57:11 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 6FF263858402 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1703163431; bh=FkCSXe0CvL5TIzoKY4u4RA92JPh2Czj1YgDAom20cwk=; h=From:To:Subject:Date:In-Reply-To:References:From; b=dfLSg/bGK0+nt+yc7jeb9hyy1bxhf3+tzDBWqz/LOzi58TI4LcE8S9zTRxWsCU50H d67UGZlx91mE79CRvjsYAm2RbMoxKU35rP5jB1QFGqx3GwC1P4rh/gUB753QGdwKBm daXUbFfVyxjnrtqJLF8CrOggf2nB/mMiZUhcA9ug= From: "ubizjak at gmail dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug c/113106] Missing CSE with cast to volatile Date: Thu, 21 Dec 2023 12:57:11 +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: 12.1.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: ubizjak at gmail 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: 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=3D113106 --- Comment #4 from Uro=C5=A1 Bizjak --- (In reply to Richard Biener from comment #3) > The situation with address-spaces isn't valid as we need to preserve the > second load because it's volatile. I think we simply refuse to combine > volatile loads out of caution in the first case. int __seg_gs b; return *(volatile __seg_gs int *) &b + b; But the above is the same w.r.t to volatile as: int a; return *(volatile int *) &a + a; ? BTW: I also checked with clang, and it creates expected code in all cases.=