ref: bfd0cb0db474a2ace38443537aff86382ec10baf
parent: 9e3ef5c777971707ab4ba426bb55d3bb2553ddf9
author: cinap_lenrek <cinap_lenrek@felloff.net>
date: Sun Oct 4 16:02:58 EDT 2015
cc/6c: fix return type of mixed asop expressions, preserve type for moves so fixed<->float conversions work correctly
--- a/sys/src/cmd/6c/txt.c
+++ b/sys/src/cmd/6c/txt.c
@@ -677,14 +677,10 @@
return;
}
case TUVLONG:
- a = AMOVQ;
- goto ld;
case TIND:
a = AMOVQ;
-
ld:
regalloc(&nod, f, t);
- nod.type = t64? types[TVLONG]: types[TINT];
gins(a, f, &nod);
gmove(&nod, t);
regfree(&nod);
@@ -692,19 +688,10 @@
case TFLOAT:
a = AMOVSS;
- goto fld;
+ goto ld;
case TDOUBLE:
a = AMOVSD;
- fld:
- regalloc(&nod, f, t);
- if(tt != TDOUBLE && tt != TFLOAT){ /* TO DO: why is this here */
- prtree(f, "odd tree");
- nod.type = t64? types[TVLONG]: types[TINT];
- }
- gins(a, f, &nod);
- gmove(&nod, t);
- regfree(&nod);
- return;
+ goto ld;
}
/*
@@ -1077,7 +1064,7 @@
case CASE( TUSHORT,TFLOAT):
case CASE( TINT, TFLOAT):
case CASE( TLONG, TFLOAT):
- case CASE( TVLONG, TFLOAT):
+ case CASE( TVLONG, TFLOAT):
case CASE( TIND, TFLOAT):
case CASE( TCHAR, TDOUBLE):
--- a/sys/src/cmd/cc/com.c
+++ b/sys/src/cmd/cc/com.c
@@ -178,12 +178,15 @@
arith(n, 0);
while(n->left->op == OCAST)
n->left = n->left->left;
- if(!sametype(t, n->type) && !mixedasop(t, n->type)) {
- r = new1(OCAST, n->right, Z);
- r->type = t;
- n->right = r;
+ if(!mixedasop(t, n->type)) {
+ if(!sametype(t, n->type)) {
+ r = new1(OCAST, n->right, Z);
+ r->type = t;
+ n->right = r;
+ n->type = t;
+ }
+ } else
n->type = t;
- }
break;
case OASMUL:
@@ -205,11 +208,16 @@
arith(n, 0);
while(n->left->op == OCAST)
n->left = n->left->left;
- if(!sametype(t, n->type) && !mixedasop(t, n->type)) {
- r = new1(OCAST, n->right, Z);
- r->type = t;
- n->right = r;
+ if(!mixedasop(t, n->type)) {
+ if(!sametype(t, n->type)) {
+ r = new1(OCAST, n->right, Z);
+ r->type = t;
+ n->right = r;
+ n->type = t;
+ }
+ } else {
n->type = t;
+ break;
}
if(typeu[n->type->etype]) {
if(n->op == OASDIV)