From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id AFB2D386F012; Mon, 20 Apr 2020 08:57:16 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org AFB2D386F012 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1587373036; bh=9APGaZYaEqbYiiD1tqLlxaS0N8RJ8Bz3CHDGUgfnBWI=; h=From:To:Subject:Date:In-Reply-To:References:From; b=jFbDMfMgzrCKSOPGYVGsxFy0U1iJnl7XbDJ/KDDhPDjFswHF7/T3qR4r7Xq+67s2V U+4efByzUUDqWhh3S1TcnhXWRqCWFzBL/ueCKtbkjnpFlib3c3REHB6xO6LIsw2vMA 2pO+NcrH8or19kChDX6SV18dSQWyW5WChAPWWjW0= From: "rguenth at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/57359] store motion causes wrong code for union access at -O3 Date: Mon, 20 Apr 2020 08:57:15 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: tree-optimization X-Bugzilla-Version: 4.9.0 X-Bugzilla-Keywords: alias, wrong-code X-Bugzilla-Severity: normal X-Bugzilla-Who: rguenth at gcc dot gnu.org X-Bugzilla-Status: ASSIGNED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: rguenth at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: attachments.created 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 X-BeenThere: gcc-bugs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-bugs mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 20 Apr 2020 08:57:16 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D57359 --- Comment #22 from Richard Biener --- Created attachment 48311 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=3D48311&action=3Dedit patch Note that apart from the possible bad impact on optimization when fixing th= is bug an actual fix is complicated by the custom "optimized" dependence analy= sis code in the loop invariant motion pass. A conservative "simple" patch would be the attached but that doesn't preser= ve store-motion for the following (because the LIM data dependence code doesn't care about stmt order): typedef int A; typedef float B; void __attribute__((noinline,noclone)) foo(A *p, B *q, long unk) { for (long i =3D 0; i < unk; ++i) { q[i] =3D 42; *p =3D 1; } } usually this bug doesn't manifest itself but of course the fix will be experienced everywhere. Benchmarking the simple patch might reveal it's not an issue (but I doubt that...).=