Skip to content

Commit

Permalink
asm: don't use imul3l instruction
Browse files Browse the repository at this point in the history
Not sure if it makes a difference in speed, but it breaks older Go
versions.

Fixes #17
  • Loading branch information
dgryski committed Apr 23, 2019
1 parent e1214b5 commit 8fbfb61
Show file tree
Hide file tree
Showing 2 changed files with 417 additions and 344 deletions.
23 changes: 20 additions & 3 deletions asm.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
package main

import (
"flag"

. "github.com/mmcloughlin/avo/build"
. "github.com/mmcloughlin/avo/operand"
. "github.com/mmcloughlin/avo/reg"
Expand Down Expand Up @@ -533,9 +535,9 @@ func fmix(h GPVirtual) GPVirtual {
}

func mur(a, h GPVirtual) GPVirtual {
IMUL3L(U32(c1), a, a)
imul3l(c1, a, a)
RORL(Imm(17), a)
IMUL3L(U32(c2), a, a)
imul3l(c2, a, a)
XORL(a, h)
RORL(Imm(19), h)

Expand Down Expand Up @@ -786,7 +788,7 @@ func fp32() {
g = mur(t, g)
ADDL(a, g)

IMUL3L(U32(c1), e, t)
imul3l(c1, e, t)
ADDL(b, t)
f = mur(t, f)
ADDL(d, f)
Expand Down Expand Up @@ -865,8 +867,23 @@ func fp32() {
RET()
}

var go111 = flag.Bool("go111", true, "use assembly instructions present in go1.11 and later")

func imul3l(m uint32, x, y Register) {
if *go111 {
IMUL3L(U32(m), x, y)
} else {
t := GP32()
MOVL(U32(m), t)
IMULL(t, x)
MOVL(x, y)
}
}

func main() {

flag.Parse()

ConstraintExpr("amd64,!purego")

fp64()
Expand Down
Loading

0 comments on commit 8fbfb61

Please sign in to comment.