aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorKen Thompson <ken@golang.org>2008-12-02 19:54:51 -0800
committerKen Thompson <ken@golang.org>2008-12-02 19:54:51 -0800
commitc8a66a98ffe74a2a9899dc05bdd169ad842df5e2 (patch)
tree7ea928af3562548c600d5a067dec24fbb6a15224 /src
parent89996e1fb1b3834746340570c2d1b48ef9fc1b9b (diff)
downloadgo-c8a66a98ffe74a2a9899dc05bdd169ad842df5e2.tar.xz
small code improvement to
used scaled indexing R=r OCL=20308 CL=20310
Diffstat (limited to 'src')
-rw-r--r--src/cmd/6g/cgen.c20
1 files changed, 13 insertions, 7 deletions
diff --git a/src/cmd/6g/cgen.c b/src/cmd/6g/cgen.c
index de54756de8..5e3d9ed189 100644
--- a/src/cmd/6g/cgen.c
+++ b/src/cmd/6g/cgen.c
@@ -476,11 +476,6 @@ agen(Node *n, Node *res)
patch(p1, pc);
}
- if(w != 1) {
- nodconst(&n1, t, w); // w
- gins(optoas(OMUL, t), &n1, &n2);
- }
-
if(isptrdarray(nl->type)) {
n1 = n3;
n1.op = OINDREG;
@@ -488,9 +483,20 @@ agen(Node *n, Node *res)
n1.xoffset = offsetof(Array, array);
gmove(&n1, &n3);
}
- gins(optoas(OADD, types[tptr]), &n2, &n3);
- gmove(&n3, res);
+ if(w == 1 || w == 2 || w == 4 || w == 8) {
+ p1 = gins(ALEAQ, &n2, &n3);
+ p1->from.scale = w;
+ p1->from.index = p1->from.type;
+ p1->from.type = p1->to.type + D_INDIR;
+ } else {
+ nodconst(&n1, t, w);
+ gins(optoas(OMUL, t), &n1, &n2);
+ gins(optoas(OADD, types[tptr]), &n2, &n3);
+ gmove(&n3, res);
+ }
+
+ gmove(&n3, res);
regfree(&n2);
regfree(&n3);
break;