[ECOS] gcc 4.1.2, some testcases fail when built with optimizations

Gary Thomas gary@mlbassoc.com
Tue Jun 19 11:22:00 GMT 2007

Hash: SHA1

Hans Rosenfeld wrote:
> I analyzed the problem and it is clear that it is a bug in the
> optimizer. 
> In scalbn() (packages/language/c/libm/current/src/double/portable-api/s_scalbn.c:109)
> the code reads:
> 	{CYG_LIBM_HI(x) = (hx&0x800fffff)|(k<<20); return x;}
> The generated code looks like this:
> 800485a4:       e3cc347f        bic     r3, ip, #2130706432     ; 0x7f000000
> 800485a8:       e3c3360f        bic     r3, r3, #15728640       ; 0xf00000
> 800485ac:       e89d0003        ldmia   sp, {r0, r1}
> 800485b0:       e1833a02        orr     r3, r3, r2, lsl #20
> 800485b4:       e5853000        str     r3, [r5]
> 800485b8:       eaffffe6        b       80048558 <scalbn+0x78>
> Whats happening here is that the return value is read from memory before
> it is calculated and stored there. Obviously the ldmia belongs after the str.
> After fixing the instruction order in the compiled binary it even works.
> On Mon, Jun 18, 2007 at 07:20:42AM -0600, Gary Thomas wrote:
>> Can you try something newer?  4.2 is now out.
> This is what I will try next.

If it's not fixed in 4.2, it looks like you have a well documented
test case to pass on to the GCC team (that's how bugs get fixed :-)

- --
- ------------------------------------------------------------
Gary Thomas                 |  Consulting for the
MLB Associates              |    Embedded world
- ------------------------------------------------------------
Version: GnuPG v1.4.7 (GNU/Linux)
Comment: Using GnuPG with Fedora - http://enigmail.mozdev.org


Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss

More information about the Ecos-discuss mailing list