cancel
Showing results for 
Search instead for 
Did you mean: 

RE Cosmic compiler optimisation problems

patm4
Associate II
Posted on February 13, 2008 at 05:52

RE Cosmic compiler optimisation problems

6 REPLIES 6
patm4
Associate II
Posted on February 06, 2008 at 07:52

I posted on here a while ago about a problem with the Cosmic compiler optimiser V4.5d. I have now tracked this down. Current version is V4.5.5. Changes between V4.5d and V4.4.5 are not relevant, so this bug is still outstanding.

C code written was :-

if( wAddr & 0x8000 )

Code produced with optimisation OFF was :-

ld a,_ee_GetBlock$L

bcp a,#128

jreq L116 ; correct

Code produced with optimisation ON was :-

jrpl L116 ; incorrect, test optimised away

wolfgang2399
Associate II
Posted on February 06, 2008 at 10:50

Hi,

jrpl is really the most effective way to test the Most Significant Bit. A good compiler will do it this way.

In detail:

Some commands e.g ld a,_ee_GetBlock$L will set the N-flag of the Condition Code Register (CC) when the MSbit is set. Then with jrpl you will jump on condition positiv - means N=0.

ld a,_ee_GetBlock$L

jrpl L116

will meet the condition (only for the MSbit) correctly and is most effective.

Regards

WoRo

luca239955_st
Associate III
Posted on February 07, 2008 at 05:39

Pat,

as Woro says, the optimization seems to be correct.

Why do you think it's a bug? What do you get on your application and what would you expect instead?

Regards,

Luca (Cosmic)

patm4
Associate II
Posted on February 08, 2008 at 17:50

Hi luca

Thanks for you response.

I think you have misinterpreted my post.

The code is optimised down to a single jrpl instruction !

There is no instruction preceding it to set the flags for the conditional jump.

Strangely, further along in the code the exact same test is coded correctly.

luca239955_st
Associate III
Posted on February 09, 2008 at 05:09

please send me a compilable example reproducing the problem at

mailto:luca.ubiali@cosmic.fr

; I'll provide an explanation or a fix as necessary.

Regards,

Luca (Cosmic)

luca239955_st
Associate III
Posted on February 13, 2008 at 05:52

just to close this thread, this optimization problem (missing LD before JRPL) was fixed in Jan 2006.