shithub: scc

Download patch

ref: 1c90dd8f2c195e66a1ca9dadfd412a2ccc6dfb55
parent: 2b05b5d52482e818baf747bc8b0619fd0d26ca02
author: Roberto E. Vargas Caballero <[email protected]>
date: Thu Nov 4 04:16:30 EDT 2021

cc2/qbe: Simplify sethi()

The frontend is filtering all the cases where we can have a
cast in the lhs, so the only case where the cast can happen
is in an abbreviation. For this reason we don't have to check
the suboperation of the assignment.

--- a/src/cmd/cc/cc2/target/qbe/cgen.c
+++ b/src/cmd/cc/cc2/target/qbe/cgen.c
@@ -696,7 +696,6 @@
 Node *
 sethi(Node *np)
 {
-	int op;
 	Node *lp, *rp;
 
 	if (!np)
@@ -715,18 +714,15 @@
 		np->address = 11;
 		break;
 	case OASSIG:
-		op = np->u.subop;
-		if (op != OINC && op != ODEC) {
-			if (lp->op == OCAST) {
-				Node *tmp = node(OCAST);
-				tmp->type = lp->left->type;
-				tmp->left = rp;
-				tmp->right = NULL;
-				rp = tmp;
-				tmp = lp;
-				lp = lp->left;
-				delnode(tmp);
-			}
+		if (lp->op == OCAST) {
+			Node *tmp = node(OCAST);
+			tmp->type = lp->left->type;
+			tmp->left = rp;
+			tmp->right = NULL;
+			rp = tmp;
+			tmp = lp;
+			lp = lp->left;
+			delnode(tmp);
 		}
 		goto binary;
 	case OCPL: