Descriptioncmd/6c: Improve peep hole optimization of rotate and shift instructions.
Update issue 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 ,!!
Patch Set 1 #Patch Set 2 : diff -r 8906cf341c9b https://code.google.com/p/go #Patch Set 3 : diff -r afa30db15b70 https://code.google.com/p/go #
Total comments: 3
Patch Set 4 : diff -r afa30db15b70 https://code.google.com/p/go #Patch Set 5 : diff -r fc9545bf5a1f https://code.google.com/p/go #MessagesTotal messages: 16
|