From d6c9669c3c83ce9f570a9c3528110b666aba88f2 Mon Sep 17 00:00:00 2001 From: Michael Forney Date: Fri, 25 Aug 2023 15:04:47 -0700 Subject: Fix conversion from float/double to unsigned int signed int can't represent all the values of unsigned int, so we need to do the conversion to signed long, and use the lower 32 bits as the result. --- amd64/isel.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'amd64') diff --git a/amd64/isel.c b/amd64/isel.c index 0d2affc..d1e4d3b 100644 --- a/amd64/isel.c +++ b/amd64/isel.c @@ -357,8 +357,13 @@ sel(Ins i, ANum *an, Fn *fn) kc = Kd; tmp[4] = getcon(0xc3e0000000000000, fn); Oftoui: - if (k == Kw) + if (k == Kw) { + r0 = newtmp("ftou", Kl, fn); + emit(Ocopy, Kw, i.to, r0, R); + i.cls = Kl; + i.to = r0; goto Emit; + } r0 = newtmp("ftou", kc, fn); for (j=0; j<4; j++) tmp[j] = newtmp("ftou", Kl, fn); -- cgit 1.4.1