
27 Jan
2009
27 Jan
'09
5:44 p.m.
Anis Benyelloul wrote:
(such as if you are packing the X and Y coordinates in the same machine word, geom::point<>::operator==() will be able to compare both coordinates with the same operation, instead of the generic x1==x2 && y1==y2).
I have wondered about this particular optimisation before and your mention made me investigate. gcc for ARM seems to make the optimisation but surprisingly the x86 version doesn't. Test code: struct pair { short a; short b; }; int compare_pair(struct pair p1, struct pair p2) { return p1.a==p2.a && p1.b==p2.b; } int compare_int(int i1, int i2) { return i1==i2; } Is there anything in the language that makes this sort of thing difficult for the compiler? I don't think so. Phil.