Skip to content

Commit 7f982e0

Browse files
committed
Fix Bool to Vec for NaNStatistics
brenhinkeller/NaNStatistics.jl@7c21dba
1 parent 149ae18 commit 7f982e0

File tree

3 files changed

+13
-5
lines changed

3 files changed

+13
-5
lines changed

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "VectorizationBase"
22
uuid = "3d5dd08c-fd9d-11e8-17fa-ed2836048c2f"
33
authors = ["Chris Elrod <elrodc@gmail.com>"]
4-
version = "0.21.63"
4+
version = "0.21.64"
55

66
[deps]
77
ArrayInterface = "4fba245c-0d91-5ea0-9b3e-6abc04ee57a9"

src/llvm_intrin/conversion.jl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,8 @@ end
183183
@inline vconvert(::Type{Vec{W,T}}, v::Vec{W,T}) where {W,T} = v
184184
@inline vconvert(::Type{Vec{W,T}}, s::NativeTypes) where {W,T} =
185185
vbroadcast(Val{W}(), T(s))
186+
@inline vconvert(::Type{Vec{W,Bool}}, s::Bool) where {W} =
187+
vconvert(Vec{W,Bool}, vbroadcast(Val{W}(), s))
186188
@inline vconvert(
187189
::Type{Vec{W,T}},
188190
s::IntegerTypesHW

src/llvm_intrin/masks.jl

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,14 @@ function truncate_mask!(instrs, input, W, suffix, reverse_load::Bool = false)
3131
push!(instrs, str)
3232
decl
3333
end
34-
function zext_mask!(instrs, input, W, suffix)
34+
function zext_mask!(instrs, input, W, suffix, sext::Bool = false)
3535
mtyp_input = "i$(max(8,nextpow2(W)))"
3636
mtyp_trunc = "i$(W)"
3737
str = if mtyp_input == mtyp_trunc
3838
"%res.$(suffix) = bitcast <$W x i1> %$input to $mtyp_input"
3939
else
40-
"%restrunc.$(suffix) = bitcast <$W x i1> %$input to $mtyp_trunc\n%res.$(suffix) = zext $mtyp_trunc %restrunc.$(suffix) to $mtyp_input"
40+
ext = sext ? "sext" : "zext"
41+
"%restrunc.$(suffix) = bitcast <$W x i1> %$input to $mtyp_trunc\n%res.$(suffix) = $ext $mtyp_trunc %restrunc.$(suffix) to $mtyp_input"
4142
end
4243
push!(instrs, str)
4344
end
@@ -109,7 +110,7 @@ end
109110
@generated function vconvert(
110111
::Type{Vec{W,I}},
111112
m::AbstractMask{W,U}
112-
) where {W,I<:IntegerTypesHW,U<:Union{UInt8,UInt16,UInt32,UInt64}}
113+
) where {W,I<:Union{IntegerTypesHW,Bool},U<:Union{UInt8,UInt16,UInt32,UInt64}}
113114
bits = 8sizeof(I)
114115
instrs = String[]
115116
truncate_mask!(instrs, '0', W, 0)
@@ -818,8 +819,13 @@ end
818819

819820
@inline vifelse(m::Vec{W,Bool}, s1::T, s2::T) where {W,T<:NativeTypes} =
820821
vifelse(m, Vec{W,T}(s1), Vec{W,T}(s2))
821-
@inline vifelse(m::AbstractMask{W}, s1::T, s2::T) where {W,T<:NativeTypes} =
822+
@inline function vifelse(
823+
m::AbstractMask{W},
824+
s1::T,
825+
s2::T
826+
) where {W,T<:NativeTypes}
822827
vifelse(m, Vec{W,T}(s1), Vec{W,T}(s2))
828+
end
823829
@inline vifelse(m::AbstractMask{W,U}, s1, s2) where {W,U} =
824830
((x1, x2) = promote(s1, s2); vifelse(m, x1, x2))
825831
@inline vifelse(

0 commit comments

Comments
 (0)