cgen: f64 deref-load -> MOVSD/MOVSS into X0 (both stages, #96)

This commit is contained in:
2026-05-25 12:27:19 +09:00
parent 0d1ae17dd0
commit 2f2a73bd41
4 changed files with 52 additions and 4 deletions

View File

@@ -2284,7 +2284,16 @@ cgexpr(Cg *c, Node *n, Local *locals)
/* Handled in the pre-cgexpr early-exit above. */
break;
case TK_STAR: /* deref */
ins2(c, A_MOVQ, amem(D_AX, 0), areg(D_AX));
/* f64/f32 result rides X0 (SSE), not AX — an integer
* MOVQ strands the value off the float ABI and the
* caller's MOVSD X0 reads stale bits (#96). Mirrors the
* float field/ident load idiom at 1462/1838. */
if (node_isfloat(n)) {
ins2(c, node_isf32(n) ? A_MOVSS : A_MOVSD,
amem(D_AX, 0), areg(D_X0));
} else {
ins2(c, A_MOVQ, amem(D_AX, 0), areg(D_AX));
}
break;
default: break;
}