Skip to content

Commit d4e96fc

Browse files
committed
Check cpuflag for BMI2
Found out the hard way I shouldn't assume that having AVX doesn't imply having BMI2.
1 parent 90e35df commit d4e96fc

6 files changed

+292
-216
lines changed

detect_avx2_always.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,7 @@ func hasAVX() bool {
99
func hasAVX2() bool {
1010
return true
1111
}
12+
13+
func hasBMI2() bool {
14+
return true
15+
}

detect_avx2_never.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,7 @@ func hasAVX() bool {
99
func hasAVX2() bool {
1010
return false
1111
}
12+
13+
func hasBMI2() bool {
14+
return false
15+
}

detect_avx2_runtime.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,7 @@ func hasAVX() bool {
1111
func hasAVX2() bool {
1212
return cpu.X86.HasAVX2
1313
}
14+
15+
func hasBMI2() bool {
16+
return cpu.X86.HasBMI2
17+
}

detect_avx2_testing.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,7 @@ func hasAVX() bool {
99
func hasAVX2() bool {
1010
return false
1111
}
12+
13+
func hasBMI2() bool {
14+
return true
15+
}

0 commit comments

Comments
 (0)