summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRichard Miller <miller.research@gmail.com>2020-12-08 18:56:25 +0000
committerRichard Miller <miller.research@gmail.com>2020-12-08 19:33:54 +0000
commitcc8e98237d965c7b4bf99bacf52859ebe1a64b14 (patch)
treef7efb1148f70a54fed2b2b3f1d9152181d37f507
parentbf0a1e77b53a523b00a1c61e8a1f1bd0d5b8e3a0 (diff)
jc: fix opcode for vlong shifts
-rw-r--r--utils/ic/cgen.c20
1 files changed, 15 insertions, 5 deletions
diff --git a/utils/ic/cgen.c b/utils/ic/cgen.c
index a8bf5ea1..7afe3290 100644
--- a/utils/ic/cgen.c
+++ b/utils/ic/cgen.c
@@ -179,11 +179,21 @@ cgen(Node *n, Node *nn)
cgen(r, &nod1);
gopcode(o, &nod1, Z, &nod);
} else {
- regalloc(&nod, r, nn);
- cgen(r, &nod);
- regalloc(&nod1, l, Z);
- cgen(l, &nod1);
- gopcode(o, &nod, &nod1, &nod);
+ if(typev[n->type->etype] &&
+ (o == OLSHR || o == OASHL || o == OASHR)){
+ /* vlong shifts: result has type of l, not type of r */
+ regalloc(&nod1, r, Z);
+ cgen(r, &nod1);
+ regalloc(&nod, l, nn);
+ cgen(l, &nod);
+ gopcode(o, &nod1, Z, &nod);
+ }else{
+ regalloc(&nod, r, nn);
+ cgen(r, &nod);
+ regalloc(&nod1, l, Z);
+ cgen(l, &nod1);
+ gopcode(o, &nod, &nod1, &nod);
+ }
}
gopcode(OAS, &nod, Z, nn);
regfree(&nod);