The vectorizer doesn't appear to handle packed structures correctly and ultimately generates a vector store to an unaligned address which causes a segfault.
This was originally reported against a 4.4 variant, but investigation shows the bug is merely latent on the head of the trunk and can be exposed by reverting this change: 2009-03-29 Richard Guenther <rguent...@suse.de> * tree-ssa-forwprop.c (forward_propagate_addr_expr_1): Properly propagate addresses of array references. [ The 2009-03-29 patch changes the end condition of the loop which ultimately confuses the vectorizer into being unable to determine the number of iterations in the loop. That's clearly a weakness in the vectorizer as the loop bounds are easily shown to be compile-time constants. ] Compile the attached testcase with -O3 and search the resulting assembly for these two key insns: leaq 2(%rax,%rdi,4), %rdi This computes the base address for palette->ents which is at offset 2 in the Palette structure (which is packed). This insn appears in the vectorized loop pre-header. It's later used by: movdqa %xmm0, (%rdi,%rsi) The faulting vector insn. Note carefully this isn't a case where peeling iterations can be used to generate suitable alignment -- the packed nature of the structure results in all the elt members being unaligned. ISTM that vector_alignment_reachable_p is the place to fix this, but I'm not very familiar with the vectorizer and thus may be off base. -- Summary: vectorizer created unaligned vector insns Product: gcc Version: unknown Status: UNCONFIRMED Keywords: wrong-code Severity: normal Priority: P3 Component: tree-optimization AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: law at redhat dot com GCC build triplet: x86_64-unknown-linux-gnu GCC host triplet: x86_64-unknown-linux-gnu GCC target triplet: x86_64-unknown-linux-gnu http://gcc.gnu.org/bugzilla/show_bug.cgi?id=42652