Skip to content

Commit bf6857c

Browse files
authored
Fix ambiguity in vconvert (#110)
* Fix ambiguity in vconvert * don't limit inference on vconvert recursion
1 parent 6ff2f24 commit bf6857c

File tree

2 files changed

+15
-5
lines changed

2 files changed

+15
-5
lines changed

src/VectorizationBase.jl

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -550,6 +550,15 @@ end
550550
@inline reduce_to_onevec(f::F, vu::VecUnroll) where {F} =
551551
ArrayInterface.reduce_tup(f, data(vu))
552552

553+
if VERSION >= v"1.7.0" && hasfield(Method, :recursion_relation)
554+
dont_limit = Returns(true)
555+
for f in (vconvert, _vconvert)
556+
for m in methods(f)
557+
m.recursion_relation = dont_limit
558+
end
559+
end
560+
end
561+
553562
include("precompile.jl")
554563
_precompile_()
555564

src/llvm_intrin/conversion.jl

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ if (Sys.ARCH === :x86_64) || (Sys.ARCH === :i686)
7070
::Type{Vec{W,F}},
7171
v::Vec{W,T}
7272
)::Vec{W,F} where {W,F<:FloatingTypes,T<:IntegerTypesHW}
73-
_vconvert(Vec{W,F}, v, True())
73+
_vconvert(Vec{W,F}, v, True())::Vec{W,F}
7474
end
7575
@inline function vconvert(
7676
::Type{Vec{W,F}},
@@ -80,7 +80,7 @@ if (Sys.ARCH === :x86_64) || (Sys.ARCH === :i686)
8080
Vec{W,F},
8181
v,
8282
has_feature(Val(:x86_64_avx512dq)) | (!has_feature(Val(:x86_64_avx2)))
83-
)
83+
)::Vec{W,F}
8484
end
8585
@inline function vconvert(
8686
::Type{F},
@@ -90,7 +90,7 @@ if (Sys.ARCH === :x86_64) || (Sys.ARCH === :i686)
9090
Vec{W,F},
9191
v,
9292
has_feature(Val(:x86_64_avx512dq)) | (!has_feature(Val(:x86_64_avx2)))
93-
)
93+
)::VecUnroll{N,W,F,Vec{W,F}}
9494
end
9595
@inline function vconvert(
9696
::Type{Vec{W,F}},
@@ -100,7 +100,7 @@ if (Sys.ARCH === :x86_64) || (Sys.ARCH === :i686)
100100
Vec{W,F},
101101
v,
102102
has_feature(Val(:x86_64_avx512dq)) | (!has_feature(Val(:x86_64_avx2)))
103-
)
103+
)::VecUnroll{N,W,F,Vec{W,F}}
104104
end
105105
@inline function vconvert(
106106
::Type{VecUnroll{N,W,F,Vec{W,F}}},
@@ -110,7 +110,7 @@ if (Sys.ARCH === :x86_64) || (Sys.ARCH === :i686)
110110
Vec{W,F},
111111
v,
112112
has_feature(Val(:x86_64_avx512dq)) | (!has_feature(Val(:x86_64_avx2)))
113-
)
113+
)::VecUnroll{N,W,F,Vec{W,F}}
114114
end
115115
else
116116
@generated function vconvert(
@@ -232,6 +232,7 @@ end
232232
@inline vconvert(::Type{T}, s::Union{Float16,Float32,Float64}) where {T<:IntegerTypesHW} = Base.fptosi(T, Base.trunc_llvm(s))
233233
@inline vconvert(::Type{T}, s::IntegerTypesHW) where {T<:Union{Float16,Float32,Float64}} = convert(T, s)::T
234234
@inline vconvert(::Type{T}, s::Union{Float16,Float32,Float64}) where {T<:Union{Float16,Float32,Float64}} = convert(T, s)::T
235+
@inline vconvert(::Type{T}, s::T) where {T<:Union{Float16,Float32,Float64}} = s
235236
@inline vconvert(::Type{T}, s::IntegerTypesHW) where {T<:IntegerTypesHW} = s % T
236237
@inline vconvert(::Type{T}, v::AbstractSIMD{W,T}) where {T<:NativeTypes,W} = v
237238
@inline vconvert(::Type{T}, v::AbstractSIMD{W,S}) where {T<:NativeTypes,S,W} =

0 commit comments

Comments
 (0)