From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 30584 invoked by alias); 15 Oct 2004 18:00:33 -0000 Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org Received: (qmail 30552 invoked by uid 48); 15 Oct 2004 18:00:30 -0000 Date: Fri, 15 Oct 2004 18:00:00 -0000 From: "stuart at apple dot com" To: gcc-bugs@gcc.gnu.org Message-ID: <20041015180025.18019.stuart@apple.com> Reply-To: gcc-bugzilla@gcc.gnu.org Subject: [Bug c/18019] New: -march=pentium4 generates word fetch instead of byte fetch X-Bugzilla-Reason: CC X-SW-Source: 2004-10/txt/msg02141.txt.bz2 List-Id: When compiling the testcase (strcpy()) with -Os -march=pentium4, GCC generates a word-fetch instead of a byte-fetch. This can provoke memory faults (e.g. at the end of a page). Omitting "-march=pentium4" generates correct code. Here is the testcase: ------------------------------------------------ char * mystrcpy(char * __restrict to, const char * __restrict from) { char *save = to; for (; (*to = *from); ++from, ++to); return(save); } ---------------------------------------------------- And the invocation: % gcc.fsf.pure.obj/gcc/xgcc -B gcc.fsf.pure.obj/gcc -Os -S mystrcpy.c -march=pentium4 ---------------------------------------------------- And the result (error is marked): ---------------------------------------------------- .file "mystrcpy.c" .text .globl mystrcpy .type mystrcpy, @function mystrcpy: pushl %ebp movl %esp, %ebp movl 12(%ebp), %ecx movl 8(%ebp), %edx jmp .L2 .L3: incl %ecx incl %edx .L2: movl (%ecx), %eax #### should be 'movb' movb %al, (%edx) testb %al, %al jne .L3 movl 8(%ebp), %eax popl %ebp ret .size mystrcpy, .-mystrcpy .ident "GCC: (GNU) 4.0.0 20041015 (experimental)" .section .note.GNU-stack,"",@progbits ---------------------------------------------------------- Also reproducible on i686-apple-darwin. -- Summary: -march=pentium4 generates word fetch instead of byte fetch Product: gcc Version: 4.0.0 Status: UNCONFIRMED Severity: normal Priority: P2 Component: c AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: stuart at apple dot com CC: gcc-bugs at gcc dot gnu dot org GCC build triplet: i686-pc-linux GCC host triplet: i686-pc-linux GCC target triplet: i686-pc-linux http://gcc.gnu.org/bugzilla/show_bug.cgi?id=18019