This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: x86 gcc lacks simple optimization
- From: "H.J. Lu" <hjl dot tools at gmail dot com>
- To: Richard Biener <richard dot guenther at gmail dot com>
- Cc: Konstantin Vladimirov <konstantin dot vladimirov at gmail dot com>, GCC Development <gcc at gcc dot gnu dot org>, GCC-help <gcc-help at gcc dot gnu dot org>
- Date: Fri, 6 Dec 2013 03:31:04 -0800
- Subject: Re: x86 gcc lacks simple optimization
- Authentication-results: sourceware.org; auth=none
- References: <CADn89gRZPDo1Z4gvime-PTC9aaeO6G5jgbN+0hOSZrnD8M1vtw at mail dot gmail dot com> <CAFiYyc0kZGi5XgXikvhqH5kHCXgBc=HtrB5OXHrqv2Z+HdNmhg at mail dot gmail dot com> <CADn89gSK0P4qXfGTNddW43XnP4KzThwNTQOBBNFBP9fO=raV3g at mail dot gmail dot com> <CAFiYyc30jVTphXoOeSnf9DbqpMg=C3069ZGWaBFVj1yAzbLMqg at mail dot gmail dot com>
On Fri, Dec 6, 2013 at 2:25 AM, Richard Biener
<richard.guenther@gmail.com> wrote:
> On Fri, Dec 6, 2013 at 11:19 AM, Konstantin Vladimirov
> <konstantin.vladimirov@gmail.com> wrote:
>> Hi,
>>
>> nothing changes if everything is unsigned and we are guaranteed to not
>> raise UB on overflow:
>>
>> unsigned foo(unsigned char *t, unsigned char *v, unsigned w)
>> {
>> unsigned i;
>>
>> for (i = 1; i != w; ++i)
>> {
>> unsigned x = i << 2;
>> v[x + 4] = t[x + 4];
>> }
>>
>> return 0;
>> }
>>
>> yields:
>>
>> .L5:
>> leal 0(,%eax,4), %edx
>> addl $1, %eax
>> movzbl 4(%edi,%edx), %ecx
>> cmpl %ebx, %eax
>> movb %cl, 4(%esi,%edx)
>> jne .L5
>>
>> What is SCEV infrastructure (guessing scalar evolutions?) and what
>> files/passes to look in?
>
> tree-scalar-evolution.c, look at where it handles MULT_EXPR but
> lacks LSHIFT_EXPR support.
>
For
--
int foo(char *t, char *v, int w)
{
int i;
for (i = 1; i != w; ++i)
{
int x = i * 2;
v[x + 4] = t[x + 4];
}
return 0;
}
---
-O2 gives:
.L6:
movzbl 4(%esi,%eax,2), %edx
movb %dl, 4(%ebx,%eax,2)
addl $1, %eax
cmpl %ecx, %eax
jne .L6
--
H.J.