shithub: riscv

Download patch

ref: 0037c93433cdda1dccd35d5fc57682fe1c86eb6d
parent: 8210f857f1a35ec285c972c2951e80ce8807f736
author: cinap_lenrek <cinap_lenrek@felloff.net>
date: Wed Feb 18 18:34:33 EST 2015

6c: eleminate more MOV instructions

convert:

x = B || W
MOVxLZX a, r; MOVxQZX r, b -> MOVxQZX a, r; MOVQ r, b
MOVxLSX a, r; MOVxQSX r, r -> MOVxQSX a, r; MOVQ r, r

the MOVQ can then be eleminated by copy propagation.

improve subprop() by accepting other mov and lea
instructions as the source op.

--- a/sys/src/cmd/6c/peep.c
+++ b/sys/src/cmd/6c/peep.c
@@ -121,7 +121,17 @@
 				r1 = rnops(uniqs(r));
 				if(r1 != R) {
 					p1 = r1->prog;
-					if(p->as == p1->as && p->to.type == p1->from.type){
+					if(p->to.type != p1->from.type)
+						break;
+					if((p->as == AMOVBLZX && p1->as == AMOVBQZX)
+					|| (p->as == AMOVWLZX && p1->as == AMOVWQZX)
+					|| (p->as == AMOVBLSX && p1->as == AMOVBQSX && p1->to.type == p->to.type)
+					|| (p->as == AMOVWLSX && p1->as == AMOVWQSX && p1->to.type == p->to.type)) {
+						p->as = p1->as;
+						p1->as = AMOVQ;
+						t++;
+					} else
+					if(p->as == p1->as) {
 						p1->as = AMOVL;
 						t++;
 					}
@@ -401,10 +411,6 @@
 		case ACWD:
 		case ACDQ:
 		case ACQO:
-
-		case AMOVSL:
-		case AMOVSQ:
-		case AMOVQL:
 			return 0;
 
 		case AORL:
@@ -432,7 +438,23 @@
 			break;
 
 		case AMOVL:
+		case ALEAL:
+		case AMOVSL:
+		case AMOVBLZX:
+		case AMOVBLSX:
+		case AMOVWLZX:
+		case AMOVWLSX:
+		case AMOVQL:
+
 		case AMOVQ:
+		case ALEAQ:
+		case AMOVSQ:
+		case AMOVBQZX:
+		case AMOVBQSX:
+		case AMOVWQZX:
+		case AMOVWQSX:
+		case AMOVLQZX:
+		case AMOVLQSX:
 			if(p->to.type == v1->type)
 				goto gotit;
 			break;