Skip to content

Commit

Permalink
fix integer outer reduct initialization on simd_integer_register_size…
Browse files Browse the repository at this point in the history
… < register_size arches
  • Loading branch information
chriselrod committed May 25, 2022
1 parent 4bdd887 commit 0d62954
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "LoopVectorization"
uuid = "bdcacae8-1622-11e9-2a5c-532679323890"
authors = ["Chris Elrod <[email protected]>"]
version = "0.12.111"
version = "0.12.112"

[deps]
ArrayInterface = "4fba245c-0d91-5ea0-9b3e-6abc04ee57a9"
Expand Down
14 changes: 11 additions & 3 deletions src/codegen/lowering.jl
Original file line number Diff line number Diff line change
Expand Up @@ -515,20 +515,28 @@ function pointerremcomparison(
end
end

@generated function of_same_size(::Type{T}, ::Type{S}) where {T,S}
@generated function of_same_size(::Type{T}, ::Type{S}, ::StaticInt{R}) where {T,S,R}
sizeof_S = sizeof(S)
if T <: Integer && sizeof(T) == 8
# sizeof(T) == 8 && max(..., 4) to maybe demote Int64 -> Int32
# but otherwise, we're giving up too much with the demotion.
sizeof_S *= max(8 ÷ R, 4)
end
sizeof(T) == sizeof_S && return T
# Tfloat = T <: Union{Float32,Float64}
if T <: Union{Float32,Float64}
sizeof_S 8 ? Float64 : Float32
elseif T <: Signed
Symbol(:Int, 8sizeof_S)
Symbol(:Int, sizeof_S)
elseif (T <: Unsigned) | (T === Bool)
Symbol(:UInt, 8sizeof_S)
Symbol(:UInt, sizeof_S)
else
S
end
end
@inline function of_same_size(::Type{T}, ::Type{S}) where {T,S}
of_same_size(T, S, VectorizationBase.register_size() ÷ VectorizationBase.simd_integer_register_size())
end
function outer_reduction_zero(
op::Operation,
u₁u::Bool,
Expand Down

0 comments on commit 0d62954

Please sign in to comment.