public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug rtl-optimization/42586]  New: load-modify-store on x86 should be single instruction
@ 2010-01-03  6:04 andi-gcc at firstfloor dot org
  2010-01-03  6:27 ` [Bug rtl-optimization/42586] " pinskia at gcc dot gnu dot org
                   ` (19 more replies)
  0 siblings, 20 replies; 21+ messages in thread
From: andi-gcc at firstfloor dot org @ 2010-01-03  6:04 UTC (permalink / raw)
  To: gcc-bugs

Continuation from 42585

>From one of the examples of
http://embed.cs.utah.edu/embarrassing/dec_09/harvest/gcc-head_llvm-gcc-head/

struct _fat_ptr
{
  unsigned char *curr;
  unsigned char *base;
  unsigned char *last_plus_one;
};
int Cyc_string_ungetc (int ignore, struct _fat_ptr *sptr);
int
Cyc_string_ungetc (int ignore, struct _fat_ptr *sptr)
{
  struct _fat_ptr *_T0;
  struct _fat_ptr *_T1;
  struct _fat_ptr _T2;
  int _T3;
  struct _fat_ptr _ans;
  int _change;

  {
    _T0 = sptr;
    _T1 = sptr;
    _T2 = *sptr;
    _T3 = -1;
    _ans = _T2;
    _change = -1;
    _ans.curr += 4294967295U;
    *sptr = _ans;
    return (0);
  }
}

when compiled with -O2 -m32 on 4.5.0 20091219 generates

Cyc_string_ungetc:
        subl    $32, %esp
        movl    40(%esp), %eax
        movl    (%eax), %edx
        subl    $1, %edx
        movl    %edx, (%eax)
        xorl    %eax, %eax
        addl    $32, %esp
        ret

Apart from the useless stack frame manipulation it should use

       subl $1,(%eax) 

not load-modify-store as recommended in the Intel/AMD optimization
manuals for any modern CPU.

I experimented with different -mtune=s
(thinking it was maybe optimizing for Pentium5 where this made sense), but that
didn't help (apart from turning the subl into a decl). The code snippet
above is for -mtune=generic -m32


-- 
           Summary: load-modify-store on x86 should be single instruction
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: rtl-optimization
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: andi-gcc at firstfloor dot org
  GCC host triplet: x86_64-linux
GCC target triplet: x86_64-linux -m32


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


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

end of thread, other threads:[~2010-01-25 17:51 UTC | newest]

Thread overview: 21+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-01-03  6:04 [Bug rtl-optimization/42586] New: load-modify-store on x86 should be single instruction andi-gcc at firstfloor dot org
2010-01-03  6:27 ` [Bug rtl-optimization/42586] " pinskia at gcc dot gnu dot org
2010-01-03  6:28 ` pinskia at gcc dot gnu dot org
2010-01-03  6:30 ` [Bug tree-optimization/42586] SRA does not always work pinskia at gcc dot gnu dot org
2010-01-03  6:33 ` pinskia at gcc dot gnu dot org
2010-01-03  6:35 ` pinskia at gcc dot gnu dot org
2010-01-03  6:39 ` pinskia at gcc dot gnu dot org
2010-01-03  6:55 ` [Bug tree-optimization/42586] New: load-modify-store on x86 should be \ single instruction andi-gcc at firstfloor dot org
2010-01-03  6:57 ` pinskia at gcc dot gnu dot org
2010-01-03  7:00 ` andi-gcc at firstfloor dot org
2010-01-03  7:02 ` pinskia at gcc dot gnu dot org
2010-01-03  7:03 ` andi-gcc at firstfloor dot org
2010-01-03  7:07 ` pinskia at gcc dot gnu dot org
2010-01-03  7:10 ` pinskia at gcc dot gnu dot org
2010-01-03  7:10 ` pinskia at gcc dot gnu dot org
2010-01-03  7:47 ` andi-gcc at firstfloor dot org
2010-01-03  7:49 ` pinskia at gcc dot gnu dot org
2010-01-03  8:13 ` andi-gcc at firstfloor dot org
2010-01-03 11:11 ` [Bug tree-optimization/42586] load-modify-store on x86 should be a " rguenth at gcc dot gnu dot org
2010-01-03 13:19 ` andi-gcc at firstfloor dot org
2010-01-25 17:51 ` jamborm 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).