mirror of
https://github.com/golang/go
synced 2024-11-27 03:11:19 -07:00
cmd/6c: Improve peep hole optimization of rotate and shift instructions.
Update #4629. $ cat shift2.c unsigned int shift(unsigned int x, unsigned int y) { x = (x << 3); y = (y << 5); x = (x << 7); y = (y << 9); return x ^ y; } ## BEFORE $ go tool 6c -S shift2.c (shift2.c:2) TEXT shift+0(SB),$0-8 (shift2.c:4) MOVL x+0(FP),!!AX (shift2.c:4) SALL $3,!!AX (shift2.c:4) MOVL AX,!!DX (shift2.c:5) MOVL y+4(FP),!!AX (shift2.c:5) SALL $5,!!AX (shift2.c:5) MOVL AX,!!CX (shift2.c:6) MOVL DX,!!AX (shift2.c:6) SALL $7,!!AX (shift2.c:6) MOVL AX,!!DX (shift2.c:7) MOVL CX,!!AX (shift2.c:7) SALL $9,!!AX (shift2.c:7) MOVL AX,!!CX (shift2.c:8) MOVL DX,!!AX (shift2.c:8) XORL CX,!!AX (shift2.c:8) RET ,!! (shift2.c:8) RET ,!! (shift2.c:8) END ,!! ## AFTER $ go tool 6c -S shift2.c (shift2.c:2) TEXT shift+0(SB),$0-8 (shift2.c:4) MOVL x+0(FP),!!AX (shift2.c:4) SALL $3,!!AX (shift2.c:5) MOVL y+4(FP),!!CX (shift2.c:5) SALL $5,!!CX (shift2.c:6) SALL $7,!!AX (shift2.c:7) SALL $9,!!CX (shift2.c:8) XORL CX,!!AX (shift2.c:8) RET ,!! (shift2.c:8) RET ,!! (shift2.c:8) END ,!! R=rsc, minux.ma, dave, nigeltao CC=golang-dev https://golang.org/cl/7066055
This commit is contained in:
parent
dfdfba14b9
commit
41ec481a53
@ -330,20 +330,7 @@ subprop(Reg *r0)
|
||||
case AIMULW:
|
||||
if(p->to.type != D_NONE)
|
||||
break;
|
||||
|
||||
case ADIVB:
|
||||
case ADIVL:
|
||||
case ADIVQ:
|
||||
case ADIVW:
|
||||
case AIDIVB:
|
||||
case AIDIVL:
|
||||
case AIDIVQ:
|
||||
case AIDIVW:
|
||||
case AIMULB:
|
||||
case AMULB:
|
||||
case AMULL:
|
||||
case AMULQ:
|
||||
case AMULW:
|
||||
goto giveup;
|
||||
|
||||
case AROLB:
|
||||
case AROLL:
|
||||
@ -369,6 +356,23 @@ subprop(Reg *r0)
|
||||
case ASHRL:
|
||||
case ASHRQ:
|
||||
case ASHRW:
|
||||
if(p->from.type == D_CONST)
|
||||
break;
|
||||
goto giveup;
|
||||
|
||||
case ADIVB:
|
||||
case ADIVL:
|
||||
case ADIVQ:
|
||||
case ADIVW:
|
||||
case AIDIVB:
|
||||
case AIDIVL:
|
||||
case AIDIVQ:
|
||||
case AIDIVW:
|
||||
case AIMULB:
|
||||
case AMULB:
|
||||
case AMULL:
|
||||
case AMULQ:
|
||||
case AMULW:
|
||||
|
||||
case AREP:
|
||||
case AREPN:
|
||||
@ -384,6 +388,7 @@ subprop(Reg *r0)
|
||||
case AMOVSL:
|
||||
case AMOVSQ:
|
||||
case AMOVQL:
|
||||
giveup:
|
||||
return 0;
|
||||
|
||||
case AMOVL:
|
||||
|
@ -664,6 +664,7 @@ subprop(Reg *r0)
|
||||
case AIMULW:
|
||||
if(p->to.type != D_NONE)
|
||||
break;
|
||||
goto giveup;
|
||||
|
||||
case ARCLB:
|
||||
case ARCLL:
|
||||
@ -699,6 +700,7 @@ subprop(Reg *r0)
|
||||
case ASHRW:
|
||||
if(p->from.type == D_CONST)
|
||||
break;
|
||||
goto giveup;
|
||||
|
||||
case ADIVB:
|
||||
case ADIVL:
|
||||
@ -727,6 +729,7 @@ subprop(Reg *r0)
|
||||
case AMOVSB:
|
||||
case AMOVSL:
|
||||
case AMOVSQ:
|
||||
giveup:
|
||||
if(debug['P'] && debug['v'])
|
||||
print("\tfound %P; return 0\n", p);
|
||||
return 0;
|
||||
|
Loading…
Reference in New Issue
Block a user