Created
June 29, 2017 04:50
-
-
Save gtank/010a124028a6b1dfd9a6a30b5ce44019 to your computer and use it in GitHub Desktop.
SHLQ sketch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package test | |
import ( | |
"fmt" | |
"testing" | |
) | |
func TestThing(t *testing.T) { | |
// a := uint64(0x07FFFFFFFFFFFFFFF) | |
a := uint64(0x1FFF000000000000) | |
b := uint64(0xFFFFFFFFFFFFFFFF) | |
// 0000 0111 1111 1 | |
// 07F | |
fmt.Printf("a %016x\n", a) | |
fmt.Printf("b %016x\n", b) | |
c := shlqTest(a, b) | |
fmt.Printf("c %016x\n", c) | |
fmt.Printf("d %016x\n", b<<13) | |
c = (b << 13) | (a >> 51) | |
fmt.Printf("e %016x\n", c) | |
fmt.Printf("%x\n", ^uint32(1)) | |
} | |
// +build amd64 | |
// func shlqTest(lo, hi uint64) uint64 | |
TEXT ·shlqTest(SB),$0 | |
MOVQ lo+0(FP), AX | |
MOVQ hi+8(FP), BX | |
SHLQ $13, AX, BX | |
MOVQ BX, ret+16(FP) | |
RET | |
package test | |
// go:noescape | |
func shlqTest(lo, hi uint64) uint64 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment