Skip to content

Commit

Permalink
Move AVX2 branch under amd64 build tag
Browse files Browse the repository at this point in the history
  • Loading branch information
bwesterb committed Jul 17, 2024
1 parent da1c3f7 commit 52c3193
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 27 deletions.
33 changes: 21 additions & 12 deletions and_amd64.go
Original file line number Diff line number Diff line change
@@ -1,28 +1,37 @@
package and

func and(dst, a, b []byte) {
l := uint64(len(a)) >> 8
if l != 0 {
andAVX2(&dst[0], &a[0], &b[0], l)
l := 0
if hasAVX2() {
l = uint64(len(a)) >> 8

Check failure on line 6 in and_amd64.go

View workflow job for this annotation

GitHub Actions / build

cannot use uint64(len(a)) >> 8 (value of type uint64) as int value in assignment
if l != 0 {
andAVX2(&dst[0], &a[0], &b[0], l)

Check failure on line 8 in and_amd64.go

View workflow job for this annotation

GitHub Actions / build

cannot use l (variable of type int) as uint64 value in argument to andAVX2
}
l <<= 8
}
l <<= 8
andGeneric(dst[l:], a[l:], b[l:])
}

func or(dst, a, b []byte) {
l := uint64(len(a)) >> 8
if l != 0 {
orAVX2(&dst[0], &a[0], &b[0], l)
l := 0
if hasAVX2() {
l = uint64(len(a)) >> 8

Check failure on line 18 in and_amd64.go

View workflow job for this annotation

GitHub Actions / build

cannot use uint64(len(a)) >> 8 (value of type uint64) as int value in assignment
if l != 0 {
orAVX2(&dst[0], &a[0], &b[0], l)

Check failure on line 20 in and_amd64.go

View workflow job for this annotation

GitHub Actions / build

cannot use l (variable of type int) as uint64 value in argument to orAVX2
}
l <<= 8
}
l <<= 8
orGeneric(dst[l:], a[l:], b[l:])
}

func andNot(dst, a, b []byte) {
l := uint64(len(a)) >> 8
if l != 0 {
andNotAVX2(&dst[0], &a[0], &b[0], l)
l := 0
if hasAVX2() {
l = uint64(len(a)) >> 8

Check failure on line 30 in and_amd64.go

View workflow job for this annotation

GitHub Actions / build

cannot use uint64(len(a)) >> 8 (value of type uint64) as int value in assignment
if l != 0 {
andNotAVX2(&dst[0], &a[0], &b[0], l)

Check failure on line 32 in and_amd64.go

View workflow job for this annotation

GitHub Actions / build

cannot use l (variable of type int) as uint64 value in argument to andNotAVX2
}
l <<= 8
}
l <<= 8
andNotGeneric(dst[l:], a[l:], b[l:])
}
18 changes: 3 additions & 15 deletions lib.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,7 @@ func And(dst, a, b []byte) {
panic("lengths of a, b and dst must be equal")
}

if hasAVX2() {
and(dst, a, b)
return
}
andGeneric(dst, a, b)
and(dst, a, b)
}

func andGeneric(dst, a, b []byte) {
Expand All @@ -43,11 +39,7 @@ func Or(dst, a, b []byte) {
panic("lengths of a, b and dst must be equal")
}

if hasAVX2() {
or(dst, a, b)
return
}
orGeneric(dst, a, b)
or(dst, a, b)
}

func orGeneric(dst, a, b []byte) {
Expand All @@ -73,11 +65,7 @@ func AndNot(dst, a, b []byte) {
panic("lengths of a, b and dst must be equal")
}

if hasAVX2() {
andNot(dst, a, b)
return
}
andNotGeneric(dst, a, b)
andNot(dst, a, b)
}

func andNotGeneric(dst, a, b []byte) {
Expand Down

0 comments on commit 52c3193

Please sign in to comment.