summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOri Bernstein <ori@eigenstate.org>2019-04-28 21:36:09 -0700
committerOri Bernstein <ori@eigenstate.org>2019-04-28 21:36:09 -0700
commit4be03d030c00960d2b27f319057d1a07603c0260 (patch)
treebb416efe4aea300655ae09769ffb1ee7232c13e2
parentcbf8e144771b88703180db26d74f1c65e45d84fe (diff)
downloadmc-4be03d030c00960d2b27f319057d1a07603c0260.tar.gz
Fix float conversions in casts.
We were dropping the intness, and didn't registerize the args to comisd.
-rw-r--r--6/isel.c2
-rw-r--r--parse/infer.c11
-rw-r--r--parse/parse.h1
-rw-r--r--parse/type.c7
4 files changed, 17 insertions, 4 deletions
diff --git a/6/isel.c b/6/isel.c
index 99988a3..0361578 100644
--- a/6/isel.c
+++ b/6/isel.c
@@ -913,11 +913,13 @@ selexpr(Isel *s, Node *n)
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;
diff --git a/parse/infer.c b/parse/infer.c
index 725c4d3..6415cb3 100644
--- a/parse/infer.c
+++ b/parse/infer.c
@@ -2645,6 +2645,7 @@ typesub(Node *n, int noerr)
{
char *name;
size_t i;
+ Node *l;
if (!n)
return;
@@ -2703,10 +2704,12 @@ typesub(Node *n, int noerr)
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());
diff --git a/parse/parse.h b/parse/parse.h
index 5e5d7bc..619f9d6 100644
--- a/parse/parse.h
+++ b/parse/parse.h
@@ -482,6 +482,7 @@ Ucon *finducon(Type *t, Node *name);
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);
diff --git a/parse/type.c b/parse/type.c
index e932935..31a9d35 100644
--- a/parse/type.c
+++ b/parse/type.c
@@ -412,6 +412,13 @@ istysigned(Type *t)
}
int
+istyint(Type *t)
+{
+ return istysigned(t) || istyunsigned(t);
+}
+
+
+int
istyfloat(Type *t)
{
t = tybase(t);