]> Cypherpunks repositories - gostls13.git/commit
cmd/6c: Improve peep hole optimization of rotate and shift instructions.
authorMatthew Dempsky <mdempsky@google.com>
Fri, 18 Jan 2013 21:33:25 +0000 (16:33 -0500)
committerRuss Cox <rsc@golang.org>
Fri, 18 Jan 2013 21:33:25 +0000 (16:33 -0500)
commit41ec481a53b2592111e1278670b3361ef98c352d
tree70bfa49c8c725abc517d300879306c96501e0752
parentdfdfba14b98591a45186a9e9182b71e7df816e2c
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
src/cmd/6c/peep.c
src/cmd/6g/peep.c