From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 40194 invoked by alias); 24 Sep 2015 15:14:05 -0000 Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org Received: (qmail 40053 invoked by uid 48); 24 Sep 2015 15:14:00 -0000 From: "ebotcazou at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug target/67701] Unnecessary/bad instructions for u32-casted access to external symbol (assumes misaligned, superfluous load) Date: Thu, 24 Sep 2015 15:14:00 -0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: target X-Bugzilla-Version: 5.2.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: ebotcazou 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: 7bit X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-SW-Source: 2015-09/txt/msg01971.txt.bz2 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67701 --- Comment #7 from Eric Botcazou --- > Yes, AFAIK this was some obscure situation with SSE on x86. IIRC > code doing unaligned scalar accesses (which is ok on x86) but then > vectorized using peeling for alignment (which cannot succeed if the > element is not naturally aligned) and segfaulting for the emitted > aligned move instructions. I see, thanks for the insight. > Maybe these days the legacy has been cleaned up enough so we can > remove that conservative handling again... I think it also causes > us to handle > > char c[4]; > > int main() > { > if (!((unsigned long)c & 3)) > return *(int *)c; > return c[0]; > } > > too conservatively as we expand > > _5 = MEM[(int *)&c]; > > and thus lost the flow-sensitive info. The problem is that, in order to fix a legitimate issue on x86, the change pessimizes the code for strict-alignment platforms, where the said issue doesn't exist since there are unaligned accesses in the source code. And of course only for them, since x86 has unaligned load/stores. So, in the end, this is a net loss for strict-alignment platforms.