Descriptioncmd/6c: Optimize rotate expressions to use rotate instructions.
For simplicity, only recognizes expressions of the exact form
"(x << a) | (x >> b)" where x is a variable and a and b are
integer constant expressions that add to x's bit width.
Fixes issue 4629.
$ cat rotate.c
unsigned int
rotate(unsigned int x)
{
x = (x << 3) | (x >> (sizeof(x) * 8 - 3));
return x;
}
## BEFORE
$ go tool 6c -S rotate.c
(rotate.c:2) TEXT rotate+0(SB),$0-8
(rotate.c:2) MOVL x+0(FP),!!DX
(rotate.c:4) MOVL DX,!!AX
(rotate.c:4) SALL $3,!!AX
(rotate.c:4) MOVL DX,!!CX
(rotate.c:4) SHRL $29,!!CX
(rotate.c:4) ORL CX,!!AX
(rotate.c:5) RET ,!!
(rotate.c:5) RET ,!!
(rotate.c:5) END ,!!
## AFTER
$ go tool 6c -S rotate.c
(rotate.c:2) TEXT rotate+0(SB),$0-8
(rotate.c:4) MOVL x+0(FP),!!AX
(rotate.c:4) ROLL $3,!!AX
(rotate.c:5) RET ,!!
(rotate.c:5) RET ,!!
(rotate.c:5) END ,!!
Patch Set 1 #Patch Set 2 : diff -r 8906cf341c9b https://code.google.com/p/go #Patch Set 3 : diff -r 8906cf341c9b https://code.google.com/p/go #Patch Set 4 : diff -r afa30db15b70 https://code.google.com/p/go #Patch Set 5 : diff -r afa30db15b70 https://code.google.com/p/go #Patch Set 6 : diff -r fe640aeda5f2 https://code.google.com/p/go #Patch Set 7 : diff -r fe640aeda5f2 https://code.google.com/p/go #Patch Set 8 : diff -r fe640aeda5f2 https://code.google.com/p/go #Patch Set 9 : diff -r fc9545bf5a1f https://code.google.com/p/go #Patch Set 10 : diff -r 8d1bf4554310 https://code.google.com/p/go #
Total comments: 1
MessagesTotal messages: 7
|