public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug optimization/15184] New: Direct access to byte inside word not working with -march=pentiumpro
@ 2004-04-27 23:52 cesarb at nitnet dot com dot br
  2004-04-28  0:33 ` [Bug target/15184] [3.3/3.4/3.5 Regression] " pinskia at gcc dot gnu dot org
                   ` (10 more replies)
  0 siblings, 11 replies; 12+ messages in thread
From: cesarb at nitnet dot com dot br @ 2004-04-27 23:52 UTC (permalink / raw)
  To: gcc-bugs

When compiling:

// gcc -Wall -std=c99 -O3 -ffast-math -fomit-frame-pointer -march=pentiumpro
// Works: gcc -Wall -std=c99 -O3 -ffast-math -fomit-frame-pointer -march=i486

#define regparm __attribute__((__regparm__(3)))

extern unsigned int x;
extern unsigned short y;

void regparm fl(unsigned char c)
{
        x = (x & 0xFFFFFF00) | (unsigned int)c;
}

void regparm fu(unsigned char c)
{
        x = (x & 0xFFFF00FF) | ((unsigned int)c << 8);
}

void regparm gl(unsigned char c)
{
        y = (y & 0xFF00) | (unsigned short)c;
}

void regparm gu(unsigned char c)
{
        y = (y & 0x00FF) | ((unsigned short)c << 8);
}

With:
gcc -Wall -std=c99 -O3 -ffast-math -fomit-frame-pointer -march=pentiumpro

The result is:

        .file   "testcase.c"
        .text
        .align 4
        .p2align 4,,15
.globl fl
        .type   fl, @function
fl:
        movb    %al, x
        ret
        .size   fl, .-fl
        .p2align 4,,15
.globl fu
        .type   fu, @function
fu:
        movb    %al, x+1
        ret
        .size   fu, .-fu
        .p2align 4,,15
.globl gl
        .type   gl, @function
gl:
        movb    %al, %dl
        movzwl  y, %eax
        movzbw  %dl, %dx
        andl    $-256, %eax
        orl     %edx, %eax
        movw    %ax, y
        ret
        .size   gl, .-gl
        .p2align 4,,15
.globl gu
        .type   gu, @function
gu:
        movzbl  y, %edx
        sall    $8, %eax
        orl     %eax, %edx
        movw    %dx, y
        ret
        .size   gu, .-gu
        .ident  "GCC: (GNU) 3.5.0 20040425 (experimental)"
        .section        .note.GNU-stack,"",@progbits

Notice that the optimization to directly change the byte inside the word
does not work with unsigned short (it uses a lot of instructions instead
of a simple "movb %al, y+1". Is it just me or some of them are
redundant? Like moving from al to dl and then zero extending to dx
instead of doing it at once?).

The problem seems to happen only with -march=pentiumpro. Here is the
result with i486 or athlon:

        .file   "testcase.c"
        .text
        .align 4
        .p2align 4,,15
.globl fl
        .type   fl, @function
fl:
        movb    %al, x
        ret
        .size   fl, .-fl
        .p2align 4,,15
.globl fu
        .type   fu, @function
fu:
        movb    %al, x+1
        ret
        .size   fu, .-fu
        .p2align 4,,15
.globl gl
        .type   gl, @function
gl:
        movb    %al, y
        ret
        .size   gl, .-gl
        .p2align 4,,15
.globl gu
        .type   gu, @function
gu:
        movb    %al, y+1
        ret
        .size   gu, .-gu
        .ident  "GCC: (GNU) 3.5.0 20040425 (experimental)"
        .section        .note.GNU-stack,"",@progbits

Which is exactly the expected result.

Even if a Pentium PRO is slower with words, the optimization uses byte
accesses (exactly the same thing it did with longs, even on pentiumpro),
so it should be used even on pentiumpro.


Reading specs from /usr/lib/gcc-snapshot/lib/gcc/i486-linux/3.5.0/specs
Configured with: ../src/configure -v --enable-languages=c,c++,java,f77,objc,treelang --prefix=/usr/lib/gcc-snapshot --enable-shared --with-system-zlib --enable-nls --enable-threads=posix --without-included-gettext --disable-werror --enable-__cxa_atexit --enable-clocale=gnu --enable-libstdcxx-debug --enable-java-gc=boehm --enable-java-awt=gtk i486-linux
Thread model: posix
gcc version 3.5.0 20040425 (experimental)

-- 
           Summary: Direct access to byte inside word not working with -
                    march=pentiumpro
           Product: gcc
           Version: 3.5.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: optimization
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: cesarb at nitnet dot com dot br
                CC: gcc-bugs at gcc dot gnu dot org


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=15184


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

* [Bug target/15184] [3.3/3.4/3.5 Regression] Direct access to byte inside word not working with -march=pentiumpro
  2004-04-27 23:52 [Bug optimization/15184] New: Direct access to byte inside word not working with -march=pentiumpro cesarb at nitnet dot com dot br
@ 2004-04-28  0:33 ` pinskia at gcc dot gnu dot org
  2004-04-28  0:42 ` cesarb at nitnet dot com dot br
                   ` (9 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2004-04-28  0:33 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2004-04-27 23:55 -------
Confirmed a regression from 2.95.3.  For some werid reason -march=pentium4 works.

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
          Component|optimization                |target
     Ever Confirmed|                            |1
 GCC target triplet|                            |pentiumpro-*-*
           Keywords|                            |pessimizes-code
      Known to fail|                            |3.0.4 3.2.3 3.3.1 3.3.3
                   |                            |3.4.0 3.5.0
      Known to work|                            |2.95.3
   Last reconfirmed|0000-00-00 00:00:00         |2004-04-27 23:55:37
               date|                            |
            Summary|Direct access to byte inside|[3.3/3.4/3.5 Regression]
                   |word not working with -     |Direct access to byte inside
                   |march=pentiumpro            |word not working with -
                   |                            |march=pentiumpro
   Target Milestone|---                         |3.3.4


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=15184


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

* [Bug target/15184] [3.3/3.4/3.5 Regression] Direct access to byte inside word not working with -march=pentiumpro
  2004-04-27 23:52 [Bug optimization/15184] New: Direct access to byte inside word not working with -march=pentiumpro cesarb at nitnet dot com dot br
  2004-04-28  0:33 ` [Bug target/15184] [3.3/3.4/3.5 Regression] " pinskia at gcc dot gnu dot org
@ 2004-04-28  0:42 ` cesarb at nitnet dot com dot br
  2004-05-17 10:47 ` [Bug target/15184] [3.4/3.5 " gdr at gcc dot gnu dot org
                   ` (8 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: cesarb at nitnet dot com dot br @ 2004-04-28  0:42 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From cesarb at nitnet dot com dot br  2004-04-28 00:00 -------
As does i486 and athlon. It does not seem odd to me; I think it's a
collateral effect of something somewhere in the gcc code which tries to
avoid using 16-bit words on pentiumpro, as it's known that one of the
biggest problems Pentium PRO had was that it was designed with Unix in
mind and ran Windows slow exactly because Windows used 16-bit words all
the time.

-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=15184


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

* [Bug target/15184] [3.4/3.5 Regression] Direct access to byte inside word not working with -march=pentiumpro
  2004-04-27 23:52 [Bug optimization/15184] New: Direct access to byte inside word not working with -march=pentiumpro cesarb at nitnet dot com dot br
  2004-04-28  0:33 ` [Bug target/15184] [3.3/3.4/3.5 Regression] " pinskia at gcc dot gnu dot org
  2004-04-28  0:42 ` cesarb at nitnet dot com dot br
@ 2004-05-17 10:47 ` gdr at gcc dot gnu dot org
  2004-06-12 22:53 ` mmitchel at gcc dot gnu dot org
                   ` (7 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: gdr at gcc dot gnu dot org @ 2004-05-17 10:47 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From gdr at gcc dot gnu dot org  2004-05-16 22:07 -------
Will not be fixed in 3.3.x.

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
            Summary|[3.3/3.4/3.5 Regression]    |[3.4/3.5 Regression] Direct
                   |Direct access to byte inside|access to byte inside word
                   |word not working with -     |not working with -
                   |march=pentiumpro            |march=pentiumpro
   Target Milestone|3.3.4                       |3.4.1


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=15184


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

* [Bug target/15184] [3.4/3.5 Regression] Direct access to byte inside word not working with -march=pentiumpro
  2004-04-27 23:52 [Bug optimization/15184] New: Direct access to byte inside word not working with -march=pentiumpro cesarb at nitnet dot com dot br
                   ` (2 preceding siblings ...)
  2004-05-17 10:47 ` [Bug target/15184] [3.4/3.5 " gdr at gcc dot gnu dot org
@ 2004-06-12 22:53 ` mmitchel at gcc dot gnu dot org
  2004-06-21 21:20 ` mmitchel at gcc dot gnu dot org
                   ` (6 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: mmitchel at gcc dot gnu dot org @ 2004-06-12 22:53 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From mmitchel at gcc dot gnu dot org  2004-06-12 22:53 -------
Richard, got thoughts on this PR?

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |rth at redhat dot com


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=15184


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

* [Bug target/15184] [3.4/3.5 Regression] Direct access to byte inside word not working with -march=pentiumpro
  2004-04-27 23:52 [Bug optimization/15184] New: Direct access to byte inside word not working with -march=pentiumpro cesarb at nitnet dot com dot br
                   ` (3 preceding siblings ...)
  2004-06-12 22:53 ` mmitchel at gcc dot gnu dot org
@ 2004-06-21 21:20 ` mmitchel at gcc dot gnu dot org
  2004-08-29 18:58 ` mmitchel at gcc dot gnu dot org
                   ` (5 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: mmitchel at gcc dot gnu dot org @ 2004-06-21 21:20 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From mmitchel at gcc dot gnu dot org  2004-06-21 21:20 -------
Postponed until GCC 3.4.2.

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|3.4.1                       |3.4.2


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=15184


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

* [Bug target/15184] [3.4/3.5 Regression] Direct access to byte inside word not working with -march=pentiumpro
  2004-04-27 23:52 [Bug optimization/15184] New: Direct access to byte inside word not working with -march=pentiumpro cesarb at nitnet dot com dot br
                   ` (4 preceding siblings ...)
  2004-06-21 21:20 ` mmitchel at gcc dot gnu dot org
@ 2004-08-29 18:58 ` mmitchel at gcc dot gnu dot org
  2004-11-01  0:46 ` [Bug target/15184] [3.4/4.0 " mmitchel at gcc dot gnu dot org
                   ` (4 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: mmitchel at gcc dot gnu dot org @ 2004-08-29 18:58 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From mmitchel at gcc dot gnu dot org  2004-08-29 18:58 -------
Postponed until GCC 3.4.3.

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|3.4.2                       |3.4.3


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=15184


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

* [Bug target/15184] [3.4/4.0 Regression] Direct access to byte inside word not working with -march=pentiumpro
  2004-04-27 23:52 [Bug optimization/15184] New: Direct access to byte inside word not working with -march=pentiumpro cesarb at nitnet dot com dot br
                   ` (5 preceding siblings ...)
  2004-08-29 18:58 ` mmitchel at gcc dot gnu dot org
@ 2004-11-01  0:46 ` mmitchel at gcc dot gnu dot org
  2005-02-25  2:06 ` rth at gcc dot gnu dot org
                   ` (3 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: mmitchel at gcc dot gnu dot org @ 2004-11-01  0:46 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From mmitchel at gcc dot gnu dot org  2004-11-01 00:46 -------
Postponed until GCC 3.4.4.

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|3.4.3                       |3.4.4


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=15184


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

* [Bug target/15184] [3.4/4.0 Regression] Direct access to byte inside word not working with -march=pentiumpro
  2004-04-27 23:52 [Bug optimization/15184] New: Direct access to byte inside word not working with -march=pentiumpro cesarb at nitnet dot com dot br
                   ` (6 preceding siblings ...)
  2004-11-01  0:46 ` [Bug target/15184] [3.4/4.0 " mmitchel at gcc dot gnu dot org
@ 2005-02-25  2:06 ` rth at gcc dot gnu dot org
  2005-05-19 17:30 ` [Bug target/15184] [3.4/4.0/4.1 " mmitchel at gcc dot gnu dot org
                   ` (2 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: rth at gcc dot gnu dot org @ 2005-02-25  2:06 UTC (permalink / raw)
  To: gcc-bugs



-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
           Severity|normal                      |minor


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=15184


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

* [Bug target/15184] [3.4/4.0/4.1 Regression] Direct access to byte inside word not working with -march=pentiumpro
  2004-04-27 23:52 [Bug optimization/15184] New: Direct access to byte inside word not working with -march=pentiumpro cesarb at nitnet dot com dot br
                   ` (7 preceding siblings ...)
  2005-02-25  2:06 ` rth at gcc dot gnu dot org
@ 2005-05-19 17:30 ` mmitchel at gcc dot gnu dot org
  2005-07-22 21:18 ` pinskia at gcc dot gnu dot org
  2005-09-27 16:13 ` mmitchel at gcc dot gnu dot org
  10 siblings, 0 replies; 12+ messages in thread
From: mmitchel at gcc dot gnu dot org @ 2005-05-19 17:30 UTC (permalink / raw)
  To: gcc-bugs



-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|3.4.4                       |3.4.5


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=15184


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

* [Bug target/15184] [3.4/4.0/4.1 Regression] Direct access to byte inside word not working with -march=pentiumpro
  2004-04-27 23:52 [Bug optimization/15184] New: Direct access to byte inside word not working with -march=pentiumpro cesarb at nitnet dot com dot br
                   ` (8 preceding siblings ...)
  2005-05-19 17:30 ` [Bug target/15184] [3.4/4.0/4.1 " mmitchel at gcc dot gnu dot org
@ 2005-07-22 21:18 ` pinskia at gcc dot gnu dot org
  2005-09-27 16:13 ` mmitchel at gcc dot gnu dot org
  10 siblings, 0 replies; 12+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-07-22 21:18 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2005-07-22 21:13 -------
Moving to 4.0.2 pre Mark.

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|3.4.5                       |4.0.2


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=15184


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

* [Bug target/15184] [3.4/4.0/4.1 Regression] Direct access to byte inside word not working with -march=pentiumpro
  2004-04-27 23:52 [Bug optimization/15184] New: Direct access to byte inside word not working with -march=pentiumpro cesarb at nitnet dot com dot br
                   ` (9 preceding siblings ...)
  2005-07-22 21:18 ` pinskia at gcc dot gnu dot org
@ 2005-09-27 16:13 ` mmitchel at gcc dot gnu dot org
  10 siblings, 0 replies; 12+ messages in thread
From: mmitchel at gcc dot gnu dot org @ 2005-09-27 16:13 UTC (permalink / raw)
  To: gcc-bugs



-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|4.0.2                       |4.0.3


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=15184


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

end of thread, other threads:[~2005-09-27 16:10 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-04-27 23:52 [Bug optimization/15184] New: Direct access to byte inside word not working with -march=pentiumpro cesarb at nitnet dot com dot br
2004-04-28  0:33 ` [Bug target/15184] [3.3/3.4/3.5 Regression] " pinskia at gcc dot gnu dot org
2004-04-28  0:42 ` cesarb at nitnet dot com dot br
2004-05-17 10:47 ` [Bug target/15184] [3.4/3.5 " gdr at gcc dot gnu dot org
2004-06-12 22:53 ` mmitchel at gcc dot gnu dot org
2004-06-21 21:20 ` mmitchel at gcc dot gnu dot org
2004-08-29 18:58 ` mmitchel at gcc dot gnu dot org
2004-11-01  0:46 ` [Bug target/15184] [3.4/4.0 " mmitchel at gcc dot gnu dot org
2005-02-25  2:06 ` rth at gcc dot gnu dot org
2005-05-19 17:30 ` [Bug target/15184] [3.4/4.0/4.1 " mmitchel at gcc dot gnu dot org
2005-07-22 21:18 ` pinskia at gcc dot gnu dot org
2005-09-27 16:13 ` mmitchel 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).