shithub: scc

Download patch

ref: 408069b686f5db03f2ede95ef7e703ce40b8d3ff
parent: ba0b2937f7725f03722c95bfb7772cba9e4ffb2f
author: Roberto E. Vargas Caballero <k0ga@shike2.com>
date: Mon Mar 14 15:31:12 EDT 2022

cc2-qbe: Call sethi() for subops

When nodes are created because there are abbreviations we must
set the sethi numbers that drive the code generation, otherwise
we can have unexpected results.

--- a/src/cmd/cc/cc2/target/qbe/cgen.c
+++ b/src/cmd/cc/cc2/target/qbe/cgen.c
@@ -534,7 +534,7 @@
 		aux.left = ret;
 		aux.right = r;
 		aux.type = np->type;
-		r = rhs(&aux);
+		r = rhs(sethi(&aux));
 		break;
 	default:
 		/* assign abbreviation */
@@ -542,7 +542,8 @@
 		aux.left = l;
 		aux.right = r;
 		aux.type = np->type;
-		r = complex(&aux);
+		aux.address = np->address;
+		r = sethi(&aux);
 	case 0:
 		if (l->complex >= r->complex) {
 			l = lhs(l);