Follow-up Comment #3, patch #1158 (project wesnoth):
You really don't need to use assembly. For instance, try the following
reduced code:
struct map_location {
short x, y;
map_location(int x, int y) : x(x), y(y) {}
map_location(): x(-1000), y(-1000) {}
};
bool operator<(map_location a, map_location b)
{
int c = ((unsigned short)a.x) | ((unsigned short)a.y << 16);
int d = ((unsigned short)b.x) | ((unsigned short)b.y << 16);
return c < d;
}
GCC, even at -O1, compiles it to the following assembly on x86-64 (and
similarly on x86-32, but it first loads the registers from the stack).
_Zlt12map_locationS_:
cmpl %esi, %edi
setl %al
ret
How do you expect to beat the compiler at this game?
_______________________________________________________
Reply to this item at:
<http://gna.org/patch/?1158>
_______________________________________________
Message posté via/par Gna!
http://gna.org/
_______________________________________________
Wesnoth-bugs mailing list
[email protected]
https://mail.gna.org/listinfo/wesnoth-bugs