shithub: riscv

Download patch

ref: af36a8b50ad95196fdc21deac251919cd7bbd18a
parent: 9b144a94e2e8cebf8082c8418ca3a7338c0677c1
author: cinap_lenrek <cinap_lenrek@felloff.net>
date: Sat Oct 14 23:28:29 EDT 2023

6c: fix wrong signed type conversion from char/short -> float/double

--- a/sys/src/cmd/6c/txt.c
+++ b/sys/src/cmd/6c/txt.c
@@ -1045,9 +1045,7 @@
 /*
  * fix to float
  */
-	case CASE(	TCHAR,	TFLOAT):
 	case CASE(	TUCHAR,	TFLOAT):
-	case CASE(	TSHORT,	TFLOAT):
 	case CASE(	TUSHORT,TFLOAT):
 	case CASE(	TINT,	TFLOAT):
 	case CASE(	TLONG,	TFLOAT):
@@ -1054,9 +1052,8 @@
 	case CASE(	TVLONG,	TFLOAT):
 	case CASE(	TIND,	TFLOAT):
 
-	case CASE(	TCHAR,	TDOUBLE):
+
 	case CASE(	TUCHAR,	TDOUBLE):
-	case CASE(	TSHORT,	TDOUBLE):
 	case CASE(	TUSHORT,TDOUBLE):
 	case CASE(	TINT,	TDOUBLE):
 	case CASE(	TLONG,	TDOUBLE):
@@ -1078,6 +1075,20 @@
 		gmove(&nod, t);
 		regfree(&nod);
 		return;
+
+	case CASE(	TCHAR,	TFLOAT):
+	case CASE(	TCHAR,	TDOUBLE):
+	case CASE(	TSHORT,	TFLOAT):
+	case CASE(	TSHORT,	TDOUBLE):
+		regalloc(&nod, f, f);
+		gins(ft == TCHAR? AMOVBLSX: AMOVWLSX, f, &nod);
+		regalloc(&nod1, t, t);
+		gins(tt == TDOUBLE? ACVTSL2SD: ACVTSL2SS, &nod, &nod1);
+		gmove(&nod1, t);
+		regfree(&nod);
+		regfree(&nod1);
+		return;
+
 
 /*
  * float to float