public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/18019] New: -march=pentium4 generates word fetch instead of byte fetch
@ 2004-10-15 18:00 stuart at apple dot com
  2004-10-15 18:05 ` [Bug c/18019] " stuart at apple dot com
                   ` (22 more replies)
  0 siblings, 23 replies; 24+ messages in thread
From: stuart at apple dot com @ 2004-10-15 18:00 UTC (permalink / raw)
  To: gcc-bugs

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


^ permalink raw reply	[flat|nested] 24+ messages in thread

end of thread, other threads:[~2004-12-30 13:21 UTC | newest]

Thread overview: 24+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-10-15 18:00 [Bug c/18019] New: -march=pentium4 generates word fetch instead of byte fetch stuart at apple dot com
2004-10-15 18:05 ` [Bug c/18019] " stuart at apple dot com
2004-10-15 18:12 ` [Bug target/18019] " pinskia at gcc dot gnu dot org
2004-10-15 18:23 ` pinskia at gcc dot gnu dot org
2004-10-15 18:27 ` stuart at apple dot com
2004-10-15 18:36 ` [Bug target/18019] [4.0 Regression] " pinskia at gcc dot gnu dot org
2004-10-28 15:19 ` steven at gcc dot gnu dot org
2004-10-28 15:22 ` steven at gcc dot gnu dot org
2004-11-09  4:50 ` pinskia at gcc dot gnu dot org
2004-11-09 18:10 ` roger at eyesopen dot com
2004-11-09 19:34 ` stuart at apple dot com
2004-11-09 20:56 ` roger at eyesopen dot com
2004-11-16 19:40 ` stuart at apple dot com
2004-11-27 18:28 ` neroden at gcc dot gnu dot org
2004-12-02  1:08 ` stuart at apple dot com
2004-12-02  3:35 ` neroden at gcc dot gnu dot org
2004-12-02  9:02 ` jh at suse dot cz
2004-12-10 17:09 ` neroden at gcc dot gnu dot org
2004-12-18 22:49 ` steven at gcc dot gnu dot org
2004-12-19 16:16 ` jh at suse dot cz
2004-12-19 19:58 ` pinskia at gcc dot gnu dot org
2004-12-22 12:20 ` steven at gcc dot gnu dot org
2004-12-30 13:16 ` cvs-commit at gcc dot gnu dot org
2004-12-30 13:21 ` steven at gcc dot gnu dot org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).