6c/8c: eleminate moves by swaping source and destination operands in peephole pass
This commit is contained in:
parent
4cb032442a
commit
decc7ec518
2 changed files with 43 additions and 0 deletions
|
@ -407,6 +407,30 @@ subprop(Reg *r0)
|
||||||
case AMOVQL:
|
case AMOVQL:
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
case AORL:
|
||||||
|
case AORQ:
|
||||||
|
case AANDL:
|
||||||
|
case AANDQ:
|
||||||
|
case AXORL:
|
||||||
|
case AXORQ:
|
||||||
|
case AADDL:
|
||||||
|
case AADDQ:
|
||||||
|
case AADCL:
|
||||||
|
case AADCQ:
|
||||||
|
/*
|
||||||
|
* can swap when:
|
||||||
|
* ADD R2, R1
|
||||||
|
* MOV R1, R2
|
||||||
|
* convert to:
|
||||||
|
* ADD R1, R2
|
||||||
|
* MOV R2, R1 / no use for R1
|
||||||
|
*/
|
||||||
|
if(p->to.type == v1->type && p->from.type == v2->type){
|
||||||
|
copysub(&p->from, v2, v1, 1);
|
||||||
|
goto gotit;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
case AMOVL:
|
case AMOVL:
|
||||||
case AMOVQ:
|
case AMOVQ:
|
||||||
if(p->to.type == v1->type)
|
if(p->to.type == v1->type)
|
||||||
|
|
|
@ -315,6 +315,25 @@ subprop(Reg *r0)
|
||||||
case AFSTSW:
|
case AFSTSW:
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
case AORL:
|
||||||
|
case AANDL:
|
||||||
|
case AXORL:
|
||||||
|
case AADDL:
|
||||||
|
case AADCL:
|
||||||
|
/*
|
||||||
|
* can swap when:
|
||||||
|
* ADD R2, R1
|
||||||
|
* MOV R1, R2
|
||||||
|
* convert to:
|
||||||
|
* ADD R1, R2
|
||||||
|
* MOV R2, R1 / no use for R1
|
||||||
|
*/
|
||||||
|
if(p->to.type == v1->type && p->from.type == v2->type){
|
||||||
|
copysub(&p->from, v2, v1, 1);
|
||||||
|
goto gotit;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
case AMOVL:
|
case AMOVL:
|
||||||
if(p->to.type == v1->type)
|
if(p->to.type == v1->type)
|
||||||
goto gotit;
|
goto gotit;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue