[cfe-dev] disabling loop idiom recognizer in clang

Eli Friedman eli.friedman at gmail.com
Sat Apr 30 10:15:04 PDT 2011


On Sat, Apr 30, 2011 at 9:54 AM, Damjan Marion <damjan.marion at gmail.com> wrote:
>
> On Apr 30, 2011, at 3:29 AM, Andrew Fish wrote:
>
>>>> # arm-none-eabi-objdump -S inflate-tramp.o | grep -B 5 -A 2 memset
>>>>   b58:      85900400        ldrhi   r0, [r0, #1024] ; 0x400
>>>>   b5c:      e58d104c        str     r1, [sp, #76]   ; 0x4c
>>>>   b60:      e3a01000        mov     r1, #0
>>>>   b64:      858d0030        strhi   r0, [sp, #48]   ; 0x30
>>>>   b68:      e24b0064        sub     r0, fp, #100    ; 0x64
>>>>   b6c:      ebfffffe        bl      0 <memset>
>>>>     for (i = 0; i < BMAX+1; i++) c [i] = 0;
>>>
>>> Should I fill bug for this or this is just not supported?
>>>
>>
>> Damjan,
>>
>> If you think it is a bug write a small example program that shows the problem. Post it to the mailing list and describe how you compiled the test program. Then describe the issue. Also it is good to mention the version of clang you are using. objdump greps are not bug reports folks can act on.
>
> Here it is:
>
> # clang -ccc-host-triple arm-unknown-freebsd  -O2 -ffreestanding -g -c i.c -o i.o
>
> void func1(unsigned *b)
> {
>  unsigned c[17];
>  unsigned i;
>  for (i=0; i < 17; i++)  c[i] = 0;
>  do { c[*b]++; b++; } while (--i);
> }
>
> will produce memset call even with -ffreestanding.

Ah... that isn't -loop-idiom triggering; that's the loop getting
unrolled and the stores getting merged into a memset by -memcpyopt.

-Eli




More information about the cfe-dev mailing list