Skip to content

Instantly share code, notes, and snippets.

@gtank
Created June 29, 2017 04:50
Show Gist options
  • Save gtank/010a124028a6b1dfd9a6a30b5ce44019 to your computer and use it in GitHub Desktop.
Save gtank/010a124028a6b1dfd9a6a30b5ce44019 to your computer and use it in GitHub Desktop.
SHLQ sketch
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