I have found a couple of places that the compiler simply doesn't do
optimizations that are blatant.  I also can't figure out a way to force
the compiler into submission.  Please examine the two attached files
(compiled on win32).

There are three if statements.  The first two are checking if a long int
and an int are equal.  I'm doing this because there's no sense in
comparing the high word, since the compare comes much more often than
updates to the long that would cause the low word to overflow.
Basically, if the lower int doesn't match, then that's good enough.
However:
1) In the first example, the compiler is adding a bunch of extra loads.
Not to mention it is projecting the int to a long by clearing R13 and
including it in the comaprison (this is silly and actually incorrect).
I don't want the compiler to assume that high word is zero, if I wanted
that I would've asked for that.  Also, in the assignment (int16 =
int32;), it loads R15 for absolutely no reason.

2) In the second if, I was able to force it to ignore the upper byte in
the compare by including the explicit type cast.  However, it still
loads R15 unnecessarily (it's not even being used anywhere!).  It also
loads R15 again unneccessarily in the assignment.

3) In the third if, in an attempt to understand why a simple memory to
memory test is not being performed (which is possible).  I had the
compiler test two regular int's.  Amazingly, this resulted in the
compiler loading both values into registers and comparing registers.
This really doesn't make any sense to me.  However, the compiler is
vedicated with the final assignment (int16 = int16;) because it finally
does what I'm expecting, it does a memory to memory assignment.

This example was compiled w/ the -O2 option.  When I tried the -O3
option I received the following error:
"testif.c:29: Internal compiler error in verify_local_live_at_start, at
flow.c:583
Please submit a full bug report,
with preprocessed source if appropriate.
See <URL:http://www.gnu.org/software/gcc/bugs.html> for instructions."

The version of the msp430-gcc.exe compiler I have is:
Length: 84,992 bytes 
Date: 12/18/02

Thanks
-Mark Stokes



Attachment: testif.lst
Description: Binary data

Attachment: testif.c
Description: Binary data

Reply via email to