more BMI and NEON defs

This commit is contained in:
dzaima 2025-02-08 01:04:37 +02:00
parent bda9245ac3
commit 09f2980ebf
5 changed files with 15 additions and 6 deletions

View File

@ -0,0 +1,11 @@
def x86_tzcnt{x:T if (T==u16 or T==u32 or T==u64) and hasarch{'BMI' }} = emit{T, merge{'_tzcnt_u',fmtnat{width{T}}}, x}
def x86_lzcnt{x:T if ( T==u32 or T==u64) and hasarch{'LZCNT'}} = emit{T, merge{'_lzcnt_u',fmtnat{width{T}}}, x}
def pdep{x:T, m:T==u64 if hasarch{'BMI2'}} = emit{T, '_pdep_u64', x, m}
def pdep{x:T, m:T==u32 if hasarch{'BMI2'}} = emit{T, '_pdep_u32', x, m}
def pext{x:T, m:T==u64 if hasarch{'BMI2'}} = emit{T, '_pext_u64', x, m}
def pext{x:T, m:T==u32 if hasarch{'BMI2'}} = emit{T, '_pext_u32', x, m}
# only low 8 bits of n matter, so any int is fine
def bzhi{x:T==u64, n if any_int{n} and hasarch{'BMI2'}} = emit{T, '_bzhi_u64', x, n}
def bzhi{x:T==u32, n if any_int{n} and hasarch{'BMI2'}} = emit{T, '_bzhi_u32', x, n}

View File

@ -1,4 +0,0 @@
def pdep{x:T, m:T==u64} = emit{T, '_pdep_u64', x, m}
def pdep{x:T, m:T==u32} = emit{T, '_pdep_u32', x, m}
def pext{x:T, m:T==u64} = emit{T, '_pext_u64', x, m}
def pext{x:T, m:T==u32} = emit{T, '_pext_u32', x, m}

View File

@ -1,6 +1,6 @@
include './base'
include './mask'
if_inline (hasarch{'BMI2'}) include './bmi2'
if_inline (hasarch{'BMI2'}) include './bmi'
include './spaced'
include './scan_common'

View File

@ -42,6 +42,8 @@ def addhn{a:V, b:V if w128i{V}} = emit{el_h{V}, ntyp0{'vaddhn', V}, a, b}
def subhn{a:V, b:V if w128i{V}} = emit{el_h{V}, ntyp0{'vsubhn', V}, a, b}
def addhn_upper{lo:L=[k]RE, a:V=[k]XE, b:V if w128i{V} and w64i{L} and eqqi{RE,XE}} = emit{[k*2]RE, ntyp0{'vaddhn_high', V}, lo, a, b}
def subhn_upper{lo:L=[k]RE, a:V=[k]XE, b:V if w128i{V} and w64i{L} and eqqi{RE,XE}} = emit{[k*2]RE, ntyp0{'vsubhn_high', V}, lo, a, b}
def raddhn{a:V, b:V if w128i{V}} = emit{el_h{V}, ntyp0{'vraddhn', V}, a, b}
def rsubhn{a:V, b:V if w128i{V}} = emit{el_h{V}, ntyp0{'vrsubhn', V}, a, b}
# pairwise min/max
def minp{a:V, b:V if w128i{V}} = emit{V, ntyp{'vpmin', V}, a, b}

View File

@ -1,7 +1,7 @@
include './base'
if_inline (hasarch{'X86_64'}) {
if_inline (hasarch{'PCLMUL'}) include './clmul'
if_inline (hasarch{'BMI2'}) include './bmi2'
if_inline (hasarch{'BMI2'}) include './bmi'
}
include './mask'