From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 3277 invoked by alias); 26 Apr 2009 12:44:32 -0000 Received: (qmail 3254 invoked by uid 48); 26 Apr 2009 12:44:19 -0000 Date: Sun, 26 Apr 2009 12:44:00 -0000 Subject: [Bug tree-optimization/39907] New: Aligned access to unaligned address X-Bugzilla-Reason: CC Message-ID: Reply-To: gcc-bugzilla@gcc.gnu.org To: gcc-bugs@gcc.gnu.org From: "irar at il dot ibm dot com" 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 X-SW-Source: 2009-04/txt/msg02393.txt.bz2 The following code (a reduced gcc.target/x86_64/abi/test_struct_returning.c) fails during execution with segmentation fault when compiled with -O1 -ftree-vectorize -fno-vect-cost-model asm-support.S (in directory gcc.target/x86_64/abi/): #include #include "defines.h" #include "macros.h" #include "args.h" struct S_600 { float f[4]; }; struct S_600 f_600 () { struct S_600 s; int i; for (i = 0; i < 4; i++) s.f[i] = 42; return s; } int main (void) { struct S_600 s; s = WRAP_RET(f_600) (); return 0; } The failure occurs in 0x000000000040063b in f_600 () 1: x/i $pc 0x40063b : movaps %xmm0,0xffffffffffffffd8(%rsp) (gdb) Program received signal SIGSEGV, Segmentation fault. 0x000000000040063b in f_600 () 1: x/i $pc 0x40063b : movaps %xmm0,0xffffffffffffffd8(%rsp) rsp 0x7fff408944c0 0x7fff408944c0 xmm0 {v4_float = {0x2a, 0x2a, 0x2a, 0x2a}, v2_double = {0xc00002114, 0xc00002114}, v16_int8 = {0x0, 0x0, 0x28, 0x42, 0x0, 0x0, 0x28, 0x42, 0x0, 0x0, 0x28, 0x42, 0x0, 0x0, 0x28, 0x42}, v8_int16 = {0x0, 0x4228, 0x0, 0x4228, 0x0, 0x4228, 0x0, 0x4228}, v4_int32 = {0x42280000, 0x42280000, 0x42280000, 0x42280000}, v2_int64 = {0x4228000042280000, 0x4228000042280000}, uint128 = 0x42280000422800004228000042280000} The alignment is forced by the vectorizer in function vect_compute_data_ref_alignment() the same way as in pass pass_ipa_increase_alignment. But if 's' is global and not local in f_600 (i.e., when the alignment is forced in pass_ipa_increase_alignment) there is no segfault. I also tried to remove WRAP_RET(), and put f_600 and main in different files (in order to prevent their elimination). But this way there was no segfault either. Another check: if the vectorizer forces alignment but also uses peeling (with the help of a hack), there is still a segfault: 0x000000000040065f in f_600 () 1: x/i $pc 0x40065f : movaps 362(%rip),%xmm0 # 0x4007d0 <_IO_stdin_used+16> (gdb) 1: x/i $pc 0x400666 : movaps %xmm0,(%rdx) (gdb) Program received signal SIGSEGV, Segmentation fault. 0x0000000000400666 in f_600 () 1: x/i $pc 0x400666 : movaps %xmm0,(%rdx) (gdb) info all-registers rdx 0x7fff2a759358 140733905736536 rip 0x400666 0x400666 If after forcing the alignment, the vectorizer escapes and doesn't do anything else, there is no segfault. -- Summary: Aligned access to unaligned address Product: gcc Version: 4.5.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: tree-optimization AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: irar at il dot ibm dot com GCC build triplet: x86_64-suse-linux GCC host triplet: x86_64-suse-linux GCC target triplet: x86_64-suse-linux http://gcc.gnu.org/bugzilla/show_bug.cgi?id=39907