Re: [arm-gnu] arm-2008q3 Vectorizing support
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [arm-gnu] arm-2008q3 Vectorizing support



Mark Deneen wrote:

> > Daniel Jacobowitz wrote:
> >   
>   
>> >> On Mon, Nov 17, 2008 at 05:52:44PM -0500, Mark Deneen wrote:
>> >>   
>> >>     
>>     
>>> >>> Well, the tool I used before obviously didn't get the disassembly
>>> >>> correct.  Here is what objdump produces:
>>> >>>
>>> >>>     sprintf((char *)buffer, "%s", "test");
>>> >>>  8001908:    f241 6096     movw    r0, #5782    ; 0x1696
>>> >>>  800190c:    f2c2 0000     movt    r0, #8192    ; 0x2000
>>> >>>  8001910:    f643 412c     movw    r1, #15404    ; 0x3c2c
>>> >>>  8001914:    f6c0 0100     movt    r1, #2048    ; 0x800
>>> >>>  8001918:    f04f 0205     mov.w    r2, #5    ; 0x5
>>> >>>  800191c:    f002 e8f4     blx    8003b08 <memcpy>
>>> >>>
>>> >>> ..................
>>> >>>
>>> >>> 08003b08 <memcpy>:
>>> >>>  8003b08:    e92d0070     push    {r4, r5, r6}
>>> >>>     
>>> >>>       
>>>       
>> >> This is ARM code.  If you link with the correct libraries, you'll get
>> >> a Thumb-2 version of memcpy instead - and then it'll work fine.  Your
>> >> other tool probably didn't disassemble the blx instruction because
>> >> it's very unusual to use one on Cortex-M3.  If you're using the SG++
>> >> libraries, you may have left your CFLAGS off when linking - that'll
>> >> make it select ARM mode libraries.
>> >>
>> >>   
>> >>     
>>     
>>> >>> I'm targeting an arm-cortex-m3.  Any idea why sprintf would branch to
>>> >>> memcpy?
>>> >>>     
>>> >>>       
>>>       
>> >> It's a compiler optimization.  The particular sprintf call you've
>> >> written above is equivalent to a memcpy.  You can disable this kind of
>> >> optimization with -fno-builtin.
>> >>
>> >>   
>> >>     
>>     
> >
> > Daniel,
> >
> > I made the change to my CFLAGS, and things look good.  I don't have my
> > board with me at the moment, but I'll let you know how it goes tomorrow
> > morning.
> >
> > This looks better to me:
> >
> >     sprintf((char *)buffer, "%s", "test");
> >  8001908:    f241 6096     movw    r0, #5782    ; 0x1696
> >  800190c:    f2c2 0000     movt    r0, #8192    ; 0x2000
> >  8001910:    f643 31c8     movw    r1, #15304    ; 0x3bc8
> >  8001914:    f6c0 0100     movt    r1, #2048    ; 0x800
> >  8001918:    f04f 0205     mov.w    r2, #5    ; 0x5
> >  800191c:    f002 f8f4     bl    8003b08 <memcpy>
> >
> > I have to say, I'm surprised that the linker didn't complain.   :-)  
> >
> > Thanks again!
> >
> > Best Regards,
> > Mark Deneen
> >   
>   
In case anybody was wondering, passing the proper flags to the linker
did, in fact, work.

Thanks Daniel!!

Best Regards,
Mark Deneen