Spin compiler oddity/bug/optimization?
mpark
Posts: 1,305
I've encountered something I don't understand in the prop tool (and propellent too).
I have three files, odd0.spin, odd1.spin, and odd2.spin:
When I compile odd0.spin and save the binary, odd0.binary is 60 bytes long. So far, so good.
If I change odd2's Start2 to return 1 instead of 2 and recompile, odd0.binary is 48 bytes long. Odd!
Comparing the bytes generated in the two cases, it appears to me that in the second case, the compiler has omitted odd2 entirely. OBJ variables o1 and o2 both point to the same object, odd1 (or maybe it's odd2, and odd1 has been omitted; there's no way to tell because they're identical). It's as if the compiler detected that odd1 and odd2 are identical and optimized one of them away. But this is totally unexpected, given the complete lack of optimization everywhere else in the compiler. I'm rather inclined to consider this a bug, but maybe there's another explanation. What do you folks·think?
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Michael Park
PS, BTW, and FYI:
To search the forum, use search.parallax.com (do not use the Search button).
Check out the Propeller Wiki: propeller.wikispaces.com/
I have three files, odd0.spin, odd1.spin, and odd2.spin:
' odd0 OBJ o1 : "odd1" o2 : "odd2" PUB Start0 return 0
' odd1 PUB Start1 return 1
' odd2 PUB Start2 return 2
When I compile odd0.spin and save the binary, odd0.binary is 60 bytes long. So far, so good.
If I change odd2's Start2 to return 1 instead of 2 and recompile, odd0.binary is 48 bytes long. Odd!
Comparing the bytes generated in the two cases, it appears to me that in the second case, the compiler has omitted odd2 entirely. OBJ variables o1 and o2 both point to the same object, odd1 (or maybe it's odd2, and odd1 has been omitted; there's no way to tell because they're identical). It's as if the compiler detected that odd1 and odd2 are identical and optimized one of them away. But this is totally unexpected, given the complete lack of optimization everywhere else in the compiler. I'm rather inclined to consider this a bug, but maybe there's another explanation. What do you folks·think?
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Michael Park
PS, BTW, and FYI:
To search the forum, use search.parallax.com (do not use the Search button).
Check out the Propeller Wiki: propeller.wikispaces.com/
Comments
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Michael Park
PS, BTW, and FYI:
To search the forum, use search.parallax.com (do not use the Search button).
Check out the Propeller Wiki: propeller.wikispaces.com/
-Phil
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
'Still some PropSTICK Kit bare PCBs left!