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
Showing
Please
register
or
sign in
to comment