ref: 4be03d030c00960d2b27f319057d1a07603c0260
parent: cbf8e144771b88703180db26d74f1c65e45d84fe
author: Ori Bernstein <ori@eigenstate.org>
date: Sun Apr 28 17:36:09 EDT 2019
Fix float conversions in casts. We were dropping the intness, and didn't registerize the args to comisd.
--- a/6/isel.c
+++ b/6/isel.c
@@ -913,11 +913,13 @@
break;
case Oint2flt:
a = selexpr(s, args[0]);
+ a = inr(s ,a);
r = locreg(mode(n));
g(s, Icvttsi2sd, a, r, NULL);
break;
case Oflt2int:
a = selexpr(s, args[0]);
+ a = inr(s ,a);
r = locreg(mode(n));
g(s, Icvttsd2si, a, r, NULL);
break;
--- a/parse/infer.c
+++ b/parse/infer.c
@@ -2645,6 +2645,7 @@
{
char *name;
size_t i;
+ Node *l;
if (!n)
return;
@@ -2703,10 +2704,12 @@
if (n->expr.param)
n->expr.param = tyfix(n, n->expr.param, 0);
typesub(n->expr.idx, noerr);
- if (exprop(n) == Ocast && exprop(n->expr.args[0]) == Olit &&
- n->expr.args[0]->expr.args[0]->lit.littype == Lint) {
- settype(n->expr.args[0], exprtype(n));
- settype(n->expr.args[0]->expr.args[0], exprtype(n));
+ if (exprop(n) == Ocast && exprop(n->expr.args[0]) == Olit) {
+ l = n->expr.args[0]->expr.args[0];
+ if(l->lit.littype == Lint && istyint(exprtype(n))) {
+ settype(n->expr.args[0], exprtype(n));
+ settype(n->expr.args[0]->expr.args[0], exprtype(n));
+ }
}
if (exprop(n) == Oauto)
adddispspecialization(n, curstab());
--- a/parse/parse.h
+++ b/parse/parse.h
@@ -482,6 +482,7 @@
int isstacktype(Type *t);
int isenum(Type *t);
int istysigned(Type *t);
+int istyint(Type *t);
int istyunsigned(Type *t);
int istyfloat(Type *t);
int istyprimitive(Type *t);
--- a/parse/type.c
+++ b/parse/type.c
@@ -412,6 +412,13 @@
}
int
+istyint(Type *t)
+{
+ return istysigned(t) || istyunsigned(t);
+}
+
+
+int
istyfloat(Type *t)
{
t = tybase(t);