From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 23416 invoked by alias); 7 Aug 2013 09:15:08 -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 22557 invoked by uid 48); 7 Aug 2013 09:14:34 -0000 From: "mikpe at it dot uu.se" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/58039] -ftree-vectorizer makes a loop crash on a non-aligned memory Date: Wed, 07 Aug 2013 09:15:00 -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.7.2 X-Bugzilla-Keywords: X-Bugzilla-Severity: major X-Bugzilla-Who: mikpe at it dot uu.se X-Bugzilla-Status: UNCONFIRMED 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: 2013-08/txt/msg00429.txt.bz2 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58039 --- Comment #3 from Mikael Pettersson --- Your code performs mis-aligned uint16_t stores, which x86 allows. The vectorizer turns those into larger and still mis-aligned `movdqa' stores, which x86 does not allow, hence the SEGV. Replace the non-portable mis-aligned stores with portable code like #define int2store_little_endian(s,A) memcpy((s), &(A), 2) or gcc-specific code like struct __attribute__((__packed__)) packed_uint16 { uint16_t u16; }; #define int2store_little_endian(s,A) ((struct packed_uint16*)(s))->u16 = (A) and then the vectorizer generates large `movdqu' stores, which is pretty much the best you can hope for unless you rewrite the code to avoid mis-aligned stores.