summary refs log tree commit diff
diff options
context:
space:
mode:
authorQuentin Carbonneaux <quentin.carbonneaux@yale.edu>2015-11-16 17:54:16 -0500
committerQuentin Carbonneaux <quentin.carbonneaux@yale.edu>2015-11-16 17:54:16 -0500
commitc744281317a0c7c011fc3c88a2336cdff6382935 (patch)
tree344b9df922b35d9f3a439def40916d8b04addf5c
parentb8c76457464714908bef43fd992a56ca94091eba (diff)
downloadroux-c744281317a0c7c011fc3c88a2336cdff6382935.tar.gz
uniformize looping on instructions
I am actually not sure if "i-b->ins < b->nins" is the best way,
maybe the comparison with the last instruction is a little more
efficient...  At least it is uniform now.
-rw-r--r--lisc/copy.c4
-rw-r--r--lisc/isel.c6
-rw-r--r--lisc/ssa.c6
3 files changed, 8 insertions, 8 deletions
diff --git a/lisc/copy.c b/lisc/copy.c
index 0e62ed7..1daca2b 100644
--- a/lisc/copy.c
+++ b/lisc/copy.c
@@ -85,7 +85,7 @@ copy(Fn *fn)
 	for (b=fn->start; b; b=b->link) {
 		for (p=b->phi; p; p=p->link)
 			visitphi(p, cp, &w);
-		for (i=b->ins; i!=&b->ins[b->nins]; i++)
+		for (i=b->ins; i-b->ins < b->nins; i++)
 			visitins(i, cp, &w);
 	}
 	while ((w1=w)) {
@@ -123,7 +123,7 @@ copy(Fn *fn)
 				}
 			pp=&p->link;
 		}
-		for (i=b->ins; i!=&b->ins[b->nins]; i++) {
+		for (i=b->ins; i-b->ins < b->nins; i++) {
 			r = cp[i->to.val];
 			if (!req(r, i->to)) {
 				*i = (Ins){.op = ONop};
diff --git a/lisc/isel.c b/lisc/isel.c
index 18b3e43..fbbef26 100644
--- a/lisc/isel.c
+++ b/lisc/isel.c
@@ -674,7 +674,7 @@ anumber(ANum *ai, Blk *b, Con *con)
 	int a, a1, a2, n1, n2, t1, t2;
 	Ins *i;
 
-	for (i=b->ins; i<&b->ins[b->nins]; i++) {
+	for (i=b->ins; i-b->ins < b->nins; i++) {
 		if (rtype(i->to) == RTmp)
 			ai[i->to.val].i = i;
 		if (i->op != OAdd && i->op != OMul)
@@ -804,7 +804,7 @@ isel(Fn *fn)
 	/* lower function calls */
 	for (b=fn->start; b; b=b->link) {
 		curi = &insb[NIns];
-		for (i=&b->ins[b->nins]; i>b->ins;) {
+		for (i=&b->ins[b->nins]; i!=b->ins;) {
 			if ((--i)->op == OCall) {
 				for (i0=i; i0>b->ins; i0--)
 					if ((i0-1)->op != OArg)
@@ -863,7 +863,7 @@ isel(Fn *fn)
 		anumber(ainfo, b, fn->con);
 		curi = &insb[NIns];
 		seljmp(b, fn);
-		for (i=&b->ins[b->nins]; i>b->ins;)
+		for (i=&b->ins[b->nins]; i!=b->ins;)
 			sel(*--i, ainfo, fn);
 		b->nins = &insb[NIns] - curi;
 		idup(&b->ins, curi, b->nins);
diff --git a/lisc/ssa.c b/lisc/ssa.c
index 7a7f55e..ac90b6e 100644
--- a/lisc/ssa.c
+++ b/lisc/ssa.c
@@ -63,7 +63,7 @@ filluse(Fn *fn)
 						tmp[t].phi = p->to.val;
 				}
 		}
-		for (i=b->ins; i!=&b->ins[b->nins]; i++) {
+		for (i=b->ins; i-b->ins < b->nins; i++) {
 			if (!req(i->to, R)) {
 				assert(rtype(i->to) == RTmp);
 				tmp[i->to.val].ndef++;
@@ -303,7 +303,7 @@ phiins(Fn *fn)
 		for (b=fn->start; b; b=b->link) {
 			b->visit = 0;
 			r = R;
-			for (i=b->ins; i!=&b->ins[b->nins]; i++) {
+			for (i=b->ins; i-b->ins < b->nins; i++) {
 				if (!req(r, R)) {
 					if (req(i->arg[0], TMP(t)))
 						i->arg[0] = r;
@@ -438,7 +438,7 @@ renblk(Blk *b, Name **stk, Fn *fn)
 
 	for (p=b->phi; p; p=p->link)
 		rendef(&p->to, b, stk, fn);
-	for (i=b->ins; i!=&b->ins[b->nins]; i++) {
+	for (i=b->ins; i-b->ins < b->nins; i++) {
 		for (m=0; m<2; m++) {
 			t = i->arg[m].val;
 			if (rtype(i->arg[m]) == RTmp)