This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug rtl-optimization/42586] New: load-modify-store on x86 should be single instruction
- From: "andi-gcc at firstfloor dot org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 3 Jan 2010 06:04:26 -0000
- Subject: [Bug rtl-optimization/42586] New: load-modify-store on x86 should be single instruction
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
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