clean up some singeli

This commit is contained in:
dzaima 2022-01-25 19:54:18 +02:00
parent 2e2dcb3134
commit 0d977b73cd
3 changed files with 8 additions and 6 deletions

View File

@ -18,10 +18,13 @@ def w256{T} = width{T}==256
def isintv{T,w} = isintv{T} & (width{eltype{T}}==w)
def cast_vp{T, x & w256{T}} = emit{*T, '(void*)', x}
def cast_v{R, x:S & w256{R} & w256{S} & isf64v{S} & isintv{R}} = r_d2i{R, x}
def cast_v{R, x:S & w256{R} & w256{S} & isintv{S} & isf64v{R}} = r_i2d{x}
def cast_v{R, x:S & w256{R} & w256{S} & isintv{S} & isintv{R}} = emit{R, '', x}
def cast_v{R, x:S & w256{R} & w256{S} & isf64v{S} & isf64v{R}} = emit{R, '', x}
def cast_v{R, x:S & w256{R} & w256{S} & isf64v{S} & isintv{R}} = r_d2i{R, x}
def cast_v{R, x:S & w256{R} & w256{S} & isf32v{S} & isintv{R}} = r_f2i{R, x}
def cast_v{R, x:S & w256{R} & w256{S} & isf64v{S} & isf32v{R}} = r_d2f{x}
def cast_v{R, x:S & w256{R} & w256{S} & isintv{S} & isf32v{R}} = r_i2f{x}
def cast_v{R, x:S & w256{R} & w256{S} & isf32v{S} & isf64v{R}} = r_f2d{x}
def cast_v{R, x:S & w256{R} & w256{S} & isintv{S} & isf64v{R}} = r_i2d{x}
def ty_vu{T & w256{T} & issignedv{T}} = [vcount{T}](ty_iu{eltype{T}})
def ty_vs{T & w256{T} & isunsignedv{T}} = [vcount{T}](ty_is{eltype{T}})
def forv{T & w256{T}} = forc{{v}=>cast_vp{T,v}}

View File

@ -68,7 +68,6 @@ def __sub{a:T,b:T & w256{T} & isintv{T} & 64==width{eltype{T}}} = emit{T, '_mm25
def __mul {a:T,b:T & [16]i16==T} = emit{T, '_mm256_mullo_epi16', a, b}
def __mulhi{a:T,b:T & [16]i16==T} = emit{T, '_mm256_mulhi_epi16', a, b}
def __mul {a:T,b:T & [ 8]i32==T} = emit{T, '_mm256_mullo_epi32', a, b}
def __mul {a:T,b:T & [ 8]u32==T} = emit{T, '_mm256_mullo_epu32', a, b}
def __mul32{a:T,b:T & [ 4]i64==T} = emit{T, '_mm256_mul_epi32', a, b} # reads only low 32 bits of the arguments
# saturating add/sub

View File

@ -47,8 +47,8 @@ def arithChk2{F, w:T, x:T, i & match{F,__mul} & isvec{T} & i8==eltype{T}} = {
}
def arithChk2{F, w:T, x:T, i & match{F,__mul} & isvec{T} & i32==eltype{T}} = {
max:= broadcast{[8]u32, 0x4efffffe}
def cf32{x} = emit{[8]u32, '_mm256_cvtepi32_ps', x}
f32mul:= emit{[8]f32, '_mm256_mul_ps', cf32{w}, cf32{x}}
def cf32{x} = emit{[8]f32, '_mm256_cvtepi32_ps', x}
f32mul:= cf32{w} * cf32{x}
tup{w*x, any{emit{[8]u32, '_mm256_cmp_ps', abs{f32mul}, max, 29}}}
# TODO fallback to the below if the above fails
# def wp = unpackQ{w, broadcast{T, 0}}