mirror of
https://github.com/dschmenk/PLASMA.git
synced 2024-11-02 13:08:13 +00:00
Snag a few more easy optimizations
This commit is contained in:
parent
ae5ea36e87
commit
b81e911857
@ -204,5 +204,9 @@ puti(array:0); puts(" > "); puti(array:0); puts (" is ")
|
||||
puts(array:0 > array:0 ?? "TRUE\n" :: "FALSE\n")
|
||||
puti(array:0); puts(" < "); puti(array:0); puts (" is ")
|
||||
puts(array:0 < array:0 ?? "TRUE\n" :: "FALSE\n")
|
||||
ptr = 0
|
||||
ptr = 5
|
||||
puts("5*0="); puti(ptr*0); putln
|
||||
puts("5*1="); puti(ptr*1); putln
|
||||
puts("5*2="); puti(ptr*2); putln
|
||||
puts("5/1="); puti(ptr/1); putln
|
||||
done
|
||||
|
@ -1230,6 +1230,17 @@ int crunch_seq(t_opseq **seq, int pass)
|
||||
freeops = 1;
|
||||
break;
|
||||
}
|
||||
if (opnext->code == BINARY_CODE(SHL_TOKEN))
|
||||
{
|
||||
op->code = DUP_CODE;
|
||||
opnext->code == BINARY_CODE(ADD_TOKEN);
|
||||
break;
|
||||
}
|
||||
if (opnext->code == BINARY_CODE(MUL_TOKEN) || opnext->code == BINARY_CODE(DIV_TOKEN))
|
||||
{
|
||||
freeops = -2;
|
||||
break;
|
||||
}
|
||||
}
|
||||
switch (opnext->code)
|
||||
{
|
||||
@ -1441,13 +1452,27 @@ int crunch_seq(t_opseq **seq, int pass)
|
||||
}
|
||||
break;
|
||||
case BINARY_CODE(MUL_TOKEN):
|
||||
for (shiftcnt = 0; shiftcnt < 16; shiftcnt++)
|
||||
if (op->val == 0)
|
||||
{
|
||||
if (op->val == (1 << shiftcnt))
|
||||
op->code = DROP_CODE;
|
||||
opnext->code = CONST_CODE;
|
||||
opnext->val = 0;
|
||||
}
|
||||
else if (op->val == 2)
|
||||
{
|
||||
op->code = DUP_CODE;
|
||||
opnext->code = BINARY_CODE(ADD_TOKEN);
|
||||
}
|
||||
else
|
||||
{
|
||||
for (shiftcnt = 0; shiftcnt < 16; shiftcnt++)
|
||||
{
|
||||
op->val = shiftcnt;
|
||||
opnext->code = BINARY_CODE(SHL_TOKEN);
|
||||
break;
|
||||
if (op->val == (1 << shiftcnt))
|
||||
{
|
||||
op->val = shiftcnt;
|
||||
opnext->code = BINARY_CODE(SHL_TOKEN);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
@ -79,6 +79,16 @@ def crunch_seq(seq, pass)
|
||||
freeops = 1
|
||||
break
|
||||
fin
|
||||
if nextop->opcode == SHL_CODE
|
||||
op->opcode = DUP_CODE
|
||||
nextop->opcode = ADD_CODE
|
||||
op->opgroup = STACK_GROUP
|
||||
break
|
||||
fin
|
||||
if nextop->opcode == MUL_CODE or nextop->opcode == DIV_CODE
|
||||
freeops = -2
|
||||
break
|
||||
fin
|
||||
fin
|
||||
when nextop->opcode
|
||||
is NEG_CODE
|
||||
@ -258,13 +268,24 @@ def crunch_seq(seq, pass)
|
||||
fin
|
||||
break
|
||||
is MUL_CODE
|
||||
for shiftcnt = 0 to 15
|
||||
if op=>opval == 1 << shiftcnt
|
||||
op=>opval = shiftcnt
|
||||
nextop->opcode = SHL_CODE
|
||||
break
|
||||
fin
|
||||
next
|
||||
if op=>opval == 0
|
||||
op->opcode = DROP_CODE
|
||||
nextop->opcode = CONST_CODE
|
||||
nextop->opval = 0
|
||||
nextop->opgroup = CONST_GROUP
|
||||
elsif op=>opval == 2
|
||||
op->opcode = DUP_CODE
|
||||
nextop->opcode = ADD_CODE
|
||||
op->opgroup = STACK_GROUP
|
||||
else
|
||||
for shiftcnt = 2 to 15
|
||||
if op=>opval == 1 << shiftcnt
|
||||
op=>opval = shiftcnt
|
||||
nextop->opcode = SHL_CODE
|
||||
break
|
||||
fin
|
||||
next
|
||||
fin
|
||||
break
|
||||
is DIV_CODE
|
||||
for shiftcnt = 0 to 15
|
||||
|
Loading…
Reference in New Issue
Block a user