From eb46ec8d9cb8ab66c116170c90edbda3e3fb8907 Mon Sep 17 00:00:00 2001 From: dzaima Date: Wed, 19 Jul 2023 21:54:12 +0300 Subject: [PATCH] rename __mulhi & __mul32 --- src/singeli/src/avx2.singeli | 12 ++++++------ src/singeli/src/base.singeli | 2 +- src/singeli/src/dyarith.singeli | 6 +++--- src/singeli/src/sse2.singeli | 10 +++++----- 4 files changed, 15 insertions(+), 15 deletions(-) diff --git a/src/singeli/src/avx2.singeli b/src/singeli/src/avx2.singeli index 00c245a2..f9dbb3cd 100644 --- a/src/singeli/src/avx2.singeli +++ b/src/singeli/src/avx2.singeli @@ -69,12 +69,12 @@ def packQQ{{a, b}} = packQQ{a, b} # arith -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 __mulhi{a:T,b:T & [16]u16==T} = emit{T, '_mm256_mulhi_epu16', a, b} -def __mul {a:T,b:T & [ 8]i32==T} = emit{T, '_mm256_mullo_epi32', a, b} -def __mul32{a:T,b:T & [ 4]i64==T} = emit{T, '_mm256_mul_epi32', a, b} # reads only low 32 bits of arguments -def __mul32{a:T,b:T & [ 4]u64==T} = emit{T, '_mm256_mul_epu32', a, b} # reads only low 32 bits of arguments +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 mulHi{a:T,b:T & [16]u16==T} = emit{T, '_mm256_mulhi_epu16', a, b} +def __mul{a:T,b:T & [ 8]i32==T} = emit{T, '_mm256_mullo_epi32', a, b} +def mul32{a:T,b:T & [ 4]i64==T} = emit{T, '_mm256_mul_epi32', a, b} # reads only low 32 bits of arguments +def mul32{a:T,b:T & [ 4]u64==T} = emit{T, '_mm256_mul_epu32', a, b} # reads only low 32 bits of arguments def abs{a:T & w256i{T,8 }} = emit{[32]i8 , '_mm256_abs_epi8', a} def abs{a:T & w256i{T,16}} = emit{[16]i16, '_mm256_abs_epi16', a} diff --git a/src/singeli/src/base.singeli b/src/singeli/src/base.singeli index d3e2fcb4..7c2d2a7e 100644 --- a/src/singeli/src/base.singeli +++ b/src/singeli/src/base.singeli @@ -173,7 +173,7 @@ def unpackQ{...x} = assert{'unpackQ not supported', show{...x}} def packQ{...x} = assert{'packQ not supported', show{...x}} def shl{...x} = assert{'shl not supported', show{...x}} def shr{...x} = assert{'shr not supported', show{...x}} -def __mulhi{...x} = assert{'__mulhi not supported', show{...x}} +def mulHi{...x} = assert{'mulHi not supported', show{...x}} def fold_addw{...x} = assert{'fold_addw not supported', show{...x}} def vfold{...x} = assert{'vfold not supported', show{...x}} def narrowPair{...x} = assert{'narrowPair not supported', show{...x}} diff --git a/src/singeli/src/dyarith.singeli b/src/singeli/src/dyarith.singeli index 5d12da00..d6d47ddf 100644 --- a/src/singeli/src/dyarith.singeli +++ b/src/singeli/src/dyarith.singeli @@ -56,8 +56,8 @@ def arithChk2{F, M, w:T, x:T & same{F,__mul} & isvec{T} & i8==eltype{T} & hasarc } } def arithChk2{F, M, w:T, x:T & same{F,__mul} & isvec{T} & i16==eltype{T} & hasarch{'X86_64'}} = { - rl:= __mul {w,x} - rh:= __mulhi{w,x} + rl:= __mul{w,x} + rh:= mulHi{w,x} tup{rl, tup{'anyne', rh, rl>>15}} } def arithChk2{F, M, w:T, x:T & same{F,__mul} & isvec{T} & i32==eltype{T} & hasarch{'X86_64'}} = { @@ -69,7 +69,7 @@ def arithChk2{F, M, w:T, x:T & same{F,__mul} & isvec{T} & i32==eltype{T} & hasar # TODO don't do this, but instead shuffle one half, do math, unshuffle that half # def wp = unpackQ{w, T**0} # def xp = unpackQ{x, T**0} - # def rp = each{__mul32, wp, xp} + # def rp = each{mul32, wp, xp} # def T2 = to_el{i64, T} # def bad = each{{v} => { # ((T2~~v + T2**0x80000000) ^ T2**(cast{i64,1}<<63)) > T2**cast_i{i64, (cast{u64,1}<<63) | 0xFFFFFFFF} diff --git a/src/singeli/src/sse2.singeli b/src/singeli/src/sse2.singeli index b9c8e49d..e595dc0f 100644 --- a/src/singeli/src/sse2.singeli +++ b/src/singeli/src/sse2.singeli @@ -119,12 +119,12 @@ def __sub{a:T,b:T & w128i{T, 16}} = emit{T, '_mm_sub_epi16', a, b} def __sub{a:T,b:T & w128i{T, 32}} = emit{T, '_mm_sub_epi32', a, b} def __sub{a:T,b:T & w128i{T, 64}} = emit{T, '_mm_sub_epi64', a, b} -def __mul {a:T,b:T & [8]i16==T} = emit{T, '_mm_mullo_epi16', a, b} -def __mulhi{a:T,b:T & [8]i16==T} = emit{T, '_mm_mulhi_epi16', a, b} -def __mulhi{a:T,b:T & [8]u16==T} = emit{T, '_mm_mulhi_epu16', a, b} -def __mul32{a:T,b:T & [2]u64==T} = emit{T, '_mm_mul_epu32', a, b} # reads only low 32 bits of arguments +def __mul{a:T,b:T & [8]i16==T} = emit{T, '_mm_mullo_epi16', a, b} +def mulHi{a:T,b:T & [8]i16==T} = emit{T, '_mm_mulhi_epi16', a, b} +def mulHi{a:T,b:T & [8]u16==T} = emit{T, '_mm_mulhi_epu16', a, b} +def mul32{a:T,b:T & [2]u64==T} = emit{T, '_mm_mul_epu32', a, b} # reads only low 32 bits of arguments def __mul{a:T,b:T & [4]i32==T} = { - def mu{x, y} = [4]i32 ~~ __mul32{[2]u64~~x, [2]u64~~y} + def mu{x, y} = [4]i32 ~~ mul32{[2]u64~~x, [2]u64~~y} def sw{n, ...vs} = each{{c} => shuf{[4]i32, c, n}, vs} lo:= mu{a, b} hi:= mu{...sw{4b2301, a, b}}