in the following, += and *= are miscompiled because an optimisation is applied that only works if the left-hand side of the assignment is floating point. cat <<'!' >pt.c typedef struct Point {int x, y;} Point; #define PI 3.1415626535 double cos(double), sin(double); int print(char*, ...); Point circlept(Point c, int r, int degrees) { double rad; rad = (double) degrees * PI/180.0; c.x += cos(rad)*r; c.x *= cos(rad)*r; c.y -= sin(rad)*r; print("circlerad %d %d\n", c.x, c.y); return c; } ! Reference: /n/sources/patch/applied/6c-asadd-mul Date: Wed Jul 4 14:43:02 CES 2012 Signed-off-by: charles.forsyth@gmail.com --- /sys/src/cmd/6c/cgen.c Wed Jul 4 14:41:03 2012 +++ /sys/src/cmd/6c/cgen.c Wed Jul 4 14:41:00 2012 @@ -574,7 +574,7 @@ reglcgen(&nod, l, Z); else nod = *l; - if(o != OASMUL && o != OASADD) { + if(o != OASMUL && o != OASADD || !typefd[l->type->etype]) { regalloc(&nod2, r, Z); gmove(&nod, &nod2); gopcode(o, r->type, &nod1, &nod2);