Skip to content

Commit c723b7a

Browse files
Tokazamachriselrod
andauthored
Integer -> Union{Integer,StaticInt} (#86)
* Integer -> Union{Integer,StaticInt} * Update src/cartesianvindex.jl Co-authored-by: Chris Elrod <elrodc@gmail.com> * Update src/cartesianvindex.jl Co-authored-by: Chris Elrod <elrodc@gmail.com> * Update src/cartesianvindex.jl Co-authored-by: Chris Elrod <elrodc@gmail.com> * Update src/cartesianvindex.jl Co-authored-by: Chris Elrod <elrodc@gmail.com> * Update src/llvm_intrin/masks.jl Co-authored-by: Chris Elrod <elrodc@gmail.com> * Update src/llvm_intrin/intrin_funcs.jl Co-authored-by: Chris Elrod <elrodc@gmail.com> * Update src/llvm_intrin/masks.jl Co-authored-by: Chris Elrod <elrodc@gmail.com> * Use :Integer * Update src/llvm_intrin/intrin_funcs.jl Co-authored-by: Chris Elrod <elrodc@gmail.com> * Use IntegerTypes more Co-authored-by: Chris Elrod <elrodc@gmail.com>
1 parent c9194d3 commit c723b7a

File tree

10 files changed

+63
-65
lines changed

10 files changed

+63
-65
lines changed

src/alignment.jl

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,23 +5,23 @@ Return aligned memory address with minimum increment. `align` assumes `n` is a
55
power of 2.
66
"""
77
function align end
8-
@inline align(x::Integer) = (x + Int(register_size() - One())) & Int(-register_size())
8+
@inline align(x::Union{Integer,StaticInt}) = (x + Int(register_size() - One())) & Int(-register_size())
99
@inline align(x::Ptr{T}, arg) where {T} =
1010
reinterpret(Ptr{T}, align(reinterpret(UInt, x), arg))
1111
@inline align(x::Ptr{T}) where {T} = reinterpret(Ptr{T}, align(reinterpret(UInt, x)))
12-
@inline align(x::Integer, n) = (nm1 = n - One(); (x + nm1) & -n)
13-
@inline align(x::Integer, ::StaticInt{N}) where {N} = (nm1 = N - 1; (x + nm1) & -N)
14-
@inline align(x::Integer, ::Type{T}) where {T} =
12+
@inline align(x::Union{Integer,StaticInt}, n) = (nm1 = n - One(); (x + nm1) & -n)
13+
@inline align(x::Union{Integer,StaticInt}, ::StaticInt{N}) where {N} = (nm1 = N - 1; (x + nm1) & -N)
14+
@inline align(x::Union{Integer,StaticInt}, ::Type{T}) where {T} =
1515
align(x, register_size() ÷ static_sizeof(T))
1616

1717
# @generated align(::Val{L}, ::Type{T}) where {L,T} = align(L, T)
18-
aligntrunc(x::Integer, n) = x & -n
19-
aligntrunc(x::Integer) = aligntrunc(x, register_size())
20-
aligntrunc(x::Integer, ::Type{T}) where {T} = aligntrunc(x, register_size() ÷ sizeof(T))
21-
alignment(x::Integer, N = 64) = reinterpret(Int, x) % N
18+
aligntrunc(x::Union{Integer,StaticInt}, n) = x & -n
19+
aligntrunc(x::Union{Integer,StaticInt}) = aligntrunc(x, register_size())
20+
aligntrunc(x::Union{Integer,StaticInt}, ::Type{T}) where {T} = aligntrunc(x, register_size() ÷ sizeof(T))
21+
alignment(x::Union{Integer,StaticInt}, N = 64) = reinterpret(Int, x) % N
2222

2323
function valloc(
24-
N::Integer,
24+
N::Union{Integer,StaticInt},
2525
::Type{T} = Float64,
2626
a = max(register_size(), cache_linesize()),
2727
) where {T}

src/cartesianvindex.jl

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11

22
struct NullStep end
3-
struct CartesianVIndex{N,T<:Tuple{Vararg{Union{Integer,NullStep},N}}} <:
3+
struct CartesianVIndex{N,T<:Tuple{Vararg{Union{Int,StaticInt,NullStep},N}}} <:
44
Base.AbstractCartesianIndex{N}
55
I::T
6-
@inline CartesianVIndex(I::T) where {N,T<:Tuple{Vararg{Union{Integer,NullStep},N}}} =
6+
@inline CartesianVIndex(I::T) where {N,T<:Tuple{Vararg{Union{Int,StaticInt,NullStep},N}}} =
77
new{N,T}(I)
88
end
99
Base.length(::CartesianVIndex{N}) where {N} = N
@@ -19,7 +19,7 @@ _ndim(::Type{<:Base.AbstractCartesianIndex{N}}) where {N} = N
1919
# _ndim(::Type{<:AbstractArray{N}}) where {N} = N
2020
@generated function CartesianVIndex(
2121
I::T,
22-
) where {T<:Tuple{Vararg{Union{Integer,CartesianIndex,CartesianVIndex,NullStep}}}}
22+
) where {T<:Tuple{Vararg{Union{Int,StaticInt,CartesianIndex,CartesianVIndex,NullStep}}}}
2323
iexpr = Expr(:tuple)
2424
Tp = T.parameters
2525
q = Expr(:block)
@@ -45,7 +45,6 @@ _ndim(::Type{<:Base.AbstractCartesianIndex{N}}) where {N} = N
4545
)
4646
end
4747

48-
# @inline Base.CartesianIndex(I::Tuple{Vararg{Union{Integer,CartesianIndex,CartesianVIndex,StaticInt}}}) = CartesianVIndex(I)
4948

5049
@generated function _maybestaticfirst(a::Tuple{Vararg{Any,N}}) where {N}
5150
quote

src/llvm_intrin/intrin_funcs.jl

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ end
8383
# %byte = zext i1 %actual to i8
8484
# ret i8 %byte""", :Bool, :(Tuple{Bool}), "i8", ["i8"], [:b]))
8585
# end
86-
# @generated function expect(i::I, ::Val{N}) where {I <: Integer, N}
86+
# @generated function expect(i::I, ::Val{N}) where {I <: Union{Integer,StaticInt}, N}
8787
# ityp = 'i' * string(8sizeof(I))
8888
# llvmcall_expr("declare i1 @llvm.expect.$ityp($ityp, i1)", """
8989
# %actual = call $ityp @llvm.expect.$ityp($ityp %0, $ityp $N)
@@ -115,13 +115,13 @@ if Base.libllvm_version ≥ v"12"
115115
@inline vmin(v1::Vec{W,<:Unsigned}, v2::Vec{W,<:Signed}) where {W} =
116116
vifelse(v1 < v2, v1, v2)
117117
else
118-
@inline vmax(v1::Vec{W,<:Integer}, v2::Vec{W,<:Integer}) where {W} =
118+
@inline vmax(v1::Vec{W,<:Union{Integer,StaticInt}}, v2::Vec{W,<:Union{Integer,StaticInt}}) where {W} =
119119
vifelse(v1 > v2, v1, v2)
120-
@inline vmin(v1::Vec{W,<:Integer}, v2::Vec{W,<:Integer}) where {W} =
120+
@inline vmin(v1::Vec{W,<:Union{Integer,StaticInt}}, v2::Vec{W,<:Union{Integer,StaticInt}}) where {W} =
121121
vifelse(v1 < v2, v1, v2)
122122
end
123-
@inline vmax_fast(v1::Vec{W,<:Integer}, v2::Vec{W,<:Integer}) where {W} = vmax(v1, v2)
124-
@inline vmin_fast(v1::Vec{W,<:Integer}, v2::Vec{W,<:Integer}) where {W} = vmin(v1, v2)
123+
@inline vmax_fast(v1::Vec{W,<:Union{Integer,StaticInt}}, v2::Vec{W,<:Union{Integer,StaticInt}}) where {W} = vmax(v1, v2)
124+
@inline vmin_fast(v1::Vec{W,<:Union{Integer,StaticInt}}, v2::Vec{W,<:Union{Integer,StaticInt}}) where {W} = vmin(v1, v2)
125125
@inline vmax(v1::Vec{W,Bool}, v2::Vec{W,Bool}) where {W} = vor(v1, v2)
126126
@inline vmin(v1::Vec{W,Bool}, v2::Vec{W,Bool}) where {W} = vand(v1, v2)
127127

@@ -141,7 +141,7 @@ for (op, f) ∈ [
141141
end
142142
@inline vsqrt(v::AbstractSIMD{W,T}) where {W,T<:IntegerTypes} = vsqrt(float(v))
143143
@inline vsqrt(v::FloatingTypes) = Base.sqrt_llvm_fast(v)
144-
@inline vsqrt(v::Integer) = Base.sqrt_llvm_fast(float(v))
144+
@inline vsqrt(v::Union{Integer,StaticInt}) = Base.sqrt_llvm_fast(float(v))
145145
# @inline roundeven(v::VecUnroll) = VecUnroll(fmap(roundeven, getfield(v,:data)))
146146
# @generated function Base.round(::Type{Int64}, v1::Vec{W,T}) where {W, T <: Union{Float32,Float64}}
147147
# llvmcall_expr("lrint", W, Int64, (W,), (T,), "")
@@ -366,7 +366,7 @@ for (f, fl) ∈
366366
@inline $f(s::IntegerTypesHW, v::Vec{W,<:IntegerTypesHW}) where {W} =
367367
$f(vbroadcast(Val{W}(), s), v)
368368
@inline $f(a::FloatingTypes, b::FloatingTypes) = Base.FastMath.$fl(a, b)
369-
@inline $f(a::Integer, b::Integer) = Base.FastMath.$fl(a, b)
369+
@inline $f(a::Union{Integer,StaticInt}, b::Union{Integer,StaticInt}) = Base.FastMath.$fl(a, b)
370370
end
371371
end
372372

@@ -580,7 +580,7 @@ end
580580
# @inline ifelse_collapse_mirror(f::F, a, ::Tuple{}, x, ::Tuple{}) where {F} = a, x
581581
# @inline function ifelse_collapse_mirror(f::F, a, c::Tuple{T}, x, z::Tuple{T}) where {F,T}
582582
# b = first(c); y = first(z)
583-
# fxy = f(x,y)
583+
# fxy = f(x,y)
584584
# ifelse(fxy, a, b), ifelse(fxy, x, y)
585585
# end
586586
# @inline function ifelse_collapse_mirror(f::F, a, c::Tuple, x, z::Tuple) where {F}
@@ -727,9 +727,9 @@ function count_zeros_func(W, I, op, tf = 1)
727727
rettypexpr = :(_Vec{$W,$I})
728728
llvmcall_expr(decl, instrs, rettypexpr, :(Tuple{$rettypexpr}), vtyp, [vtyp], [:(data(v))])
729729
end
730-
# @generated Base.abs(v::Vec{W,I}) where {W, I <: Integer} = count_zeros_func(W, I, "abs", 0)
731-
@generated vleading_zeros(v::Vec{W,I}) where {W,I<:Integer} = count_zeros_func(W, I, "ctlz")
732-
@generated vtrailing_zeros(v::Vec{W,I}) where {W,I<:Integer} =
730+
# @generated Base.abs(v::Vec{W,I}) where {W, I <: Union{Integer,StaticInt}} = count_zeros_func(W, I, "abs", 0)
731+
@generated vleading_zeros(v::Vec{W,I}) where {W,I<:IntegerTypesHW} = count_zeros_func(W, I, "ctlz")
732+
@generated vtrailing_zeros(v::Vec{W,I}) where {W,I<:IntegerTypesHW} =
733733
count_zeros_func(W, I, "cttz")
734734

735735

@@ -1128,7 +1128,7 @@ end
11281128
@inline inv_approx(v::VecUnroll) = VecUnroll(fmap(inv_approx, getfield(v, :data)))
11291129

11301130
@inline vinv_fast(v) = vinv(v)
1131-
@inline vinv_fast(v::AbstractSIMD{<:Any,<:Integer}) = vinv_fast(float(v))
1131+
@inline vinv_fast(v::AbstractSIMD{<:Any,<:Union{Integer,StaticInt}}) = vinv_fast(float(v))
11321132

11331133
@static if (Sys.ARCH === :x86_64) || (Sys.ARCH === :i686)
11341134

@@ -1258,7 +1258,7 @@ end
12581258
yₙ₊₁ = yₙ - f(yₙ)/f′(yₙ)
12591259
f(yₙ) = 1/yₙ - x
12601260
f′(yₙ) = -1/yₙ²
1261-
yₙ₊₁ = yₙ + (1/yₙ - x) * yₙ² = yₙ + yₙ - x * yₙ² = 2yₙ - x * yₙ² = yₙ * ( 2 - x * yₙ )
1261+
yₙ₊₁ = yₙ + (1/yₙ - x) * yₙ² = yₙ + yₙ - x * yₙ² = 2yₙ - x * yₙ² = yₙ * ( 2 - x * yₙ )
12621262
yₙ₊₁ = yₙ * ( 2 - x * yₙ )
12631263
"""
12641264
@inline function vinv_fast(v::AbstractSIMD{W,Float32}) where {W}

src/llvm_intrin/masks.jl

Lines changed: 17 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -322,7 +322,7 @@ end
322322
@generated max_mask(::Type{Mask{W,U}}) where {W,U} =
323323
EVLMask{W,U}(one(U) << W - one(U), W % UInt32)
324324

325-
@generated function valrem(::Union{Val{W},StaticInt{W}}, l::T) where {W,T<:Integer}
325+
@generated function valrem(::Union{Val{W},StaticInt{W}}, l::T) where {W,T<:Union{Integer,StaticInt}}
326326
ex = ispow2(W) ? :(l & $(T(W - 1))) : Expr(:call, Base.urem_int, :l, T(W))
327327
Expr(:block, Expr(:meta, :inline), ex)
328328
end
@@ -338,7 +338,7 @@ end
338338
@generated bzhi(a::UInt32, b::UInt32) = bzhi_quote(32)
339339
@generated bzhi(a::UInt64, b::UInt64) = bzhi_quote(64)
340340

341-
# @generated function _mask(::Union{Val{W},StaticInt{W}}, l::I, ::True) where {W,I<:Integer}
341+
# @generated function _mask(::Union{Val{W},StaticInt{W}}, l::I, ::True) where {W,I<:Union{Integer,StaticInt}}
342342
# # if `has_opmask_registers()` then we can use bitmasks directly, so we create them via bittwiddling
343343
# M = mask_type(W)
344344
# quote # If the arch has opmask registers, we can generate a bitmask and then move it into the opmask register
@@ -347,7 +347,7 @@ end
347347
# EVLMask{$W,$M}($(typemax(M)) >>> ($(M(8sizeof(M))-1) - evl), evl + one(evl))
348348
# end
349349
# end
350-
@generated function _mask_bzhi(::Union{Val{W},StaticInt{W}}, l::I) where {W,I<:Integer}
350+
@generated function _mask_bzhi(::Union{Val{W},StaticInt{W}}, l::I) where {W,I<:Union{Integer,StaticInt}}
351351
U = mask_type_symbol(W)
352352
T = W > 32 ? :UInt64 : :UInt32
353353
quote
@@ -357,21 +357,21 @@ end
357357
EVLMask{$W,$U}(bzhi(-1 % $T, m) % $U, m)
358358
end
359359
end
360-
# @inline function _mask_bzhi(::Union{Val{W},StaticInt{W}}, l::I) where {W,I<:Integer}
360+
# @inline function _mask_bzhi(::Union{Val{W},StaticInt{W}}, l::I) where {W,I<:Union{Integer,StaticInt}}
361361
# U = mask_type(StaticInt(W))
362362
# # m = ((l) % UInt32) & ((W-1) % UInt32)
363363
# m = valrem(StaticInt{W}(), l % UInt32)
364364
# m = Core.ifelse((m % UInt8) == 0x00, W % UInt32, m)
365365
# # m = Core.ifelse(zero(m) == m, -1 % UInt32, m)
366366
# EVLMask{W,U}(bzhi(-1 % UInt32, m) % U, m)
367367
# end
368-
# @inline function _mask(::Union{Val{W},StaticInt{W}}, l::I, ::True) where {W,I<:Integer}
368+
# @inline function _mask(::Union{Val{W},StaticInt{W}}, l::I, ::True) where {W,I<:Union{Integer,StaticInt}}
369369
# U = mask_type(StaticInt(W))
370370
# m = ((l-one(l)) % UInt32) & ((W-1) % UInt32)
371371
# m += one(m)
372372
# EVLMask{W,U}(bzhi(-1 % UInt32, m) % U, m)
373373
# end
374-
# @generated function _mask(::Union{Val{W},StaticInt{W}}, l::I, ::True) where {W,I<:Integer}
374+
# @generated function _mask(::Union{Val{W},StaticInt{W}}, l::I, ::True) where {W,I<:Union{Integer,StaticInt}}
375375
# M = mask_type_symbol(W)
376376
# quote
377377
# $(Expr(:meta,:inline))
@@ -426,16 +426,16 @@ end
426426
l::I,
427427
::StaticInt{RS},
428428
::True,
429-
) where {W,RS,I<:Integer} = mask_cmp_quote(W, RS, true)
429+
) where {W,RS,I<:Union{Integer,StaticInt}} = mask_cmp_quote(W, RS, true)
430430
@generated _mask_cmp(
431431
::Union{Val{W},StaticInt{W}},
432432
l::I,
433433
::StaticInt{RS},
434434
::False,
435-
) where {W,RS,I<:Integer} = mask_cmp_quote(W, RS, false)
436-
@generated _mask(::Union{Val{W},StaticInt{W}}, l::I, ::True) where {W,I<:Integer} =
435+
) where {W,RS,I<:Union{Integer,StaticInt}} = mask_cmp_quote(W, RS, false)
436+
@generated _mask(::Union{Val{W},StaticInt{W}}, l::I, ::True) where {W,I<:Union{Integer,StaticInt}} =
437437
mask_shift_quote(W, true)
438-
@generated function _mask(::Union{Val{W},StaticInt{W}}, l::I, ::False) where {W,I<:Integer}
438+
@generated function _mask(::Union{Val{W},StaticInt{W}}, l::I, ::False) where {W,I<:Union{Integer,StaticInt}}
439439
# Otherwise, it's probably more efficient to use a comparison, as this will probably create some type that can be used directly for masked moves/blends/etc
440440
if W > 16
441441
Expr(
@@ -468,10 +468,10 @@ end
468468
_mask(StaticInt(W), L, has_feature(Val(:x86_64_avx512f)) & ge_one_fma(cpu_name()))
469469
@inline mask(::Union{Val{W},StaticInt{W}}, ::StaticInt{L}) where {W,L} =
470470
_mask(StaticInt(W), L, has_feature(Val(:x86_64_avx512f)) & ge_one_fma(cpu_name()))
471-
@inline mask(::Type{T}, l::Integer) where {T} =
471+
@inline mask(::Type{T}, l::Union{Integer,StaticInt}) where {T} =
472472
_mask(pick_vector_width(T), l, has_feature(Val(:x86_64_avx512f)) & ge_one_fma(cpu_name()))
473473

474-
# @generated function masktable(::Union{Val{W},StaticInt{W}}, rem::Integer) where {W}
474+
# @generated function masktable(::Union{Val{W},StaticInt{W}}, rem::Union{Integer,StaticInt}) where {W}
475475
# masks = Expr(:tuple)
476476
# for w ∈ 0:W-1
477477
# push!(masks.args, data(mask(Val(W), w == 0 ? W : w)))
@@ -507,7 +507,7 @@ end
507507
# @inline tounsigned(m::Vec{W,Bool}) where {W} = getfield(tomask(m), :u)
508508
@inline tounsigned(v) = getfield(tomask(v), :u)
509509

510-
@generated function vrem(m::Mask{W,U}, ::Type{I}) where {W,U,I<:Integer}
510+
@generated function vrem(m::Mask{W,U}, ::Type{I}) where {W,U,I<:IntegerTypesHW}
511511
bits = 8sizeof(I)
512512
instrs = String[]
513513
truncate_mask!(instrs, '0', W, 0)
@@ -523,7 +523,7 @@ end
523523
Vec(m::Mask{W}) where {W} = m % int_type(Val{W}())
524524

525525
# @inline getindexzerobased(m::Mask, i) = (getfield(m, :u) >>> i) % Bool
526-
# @inline function extractelement(m::Mask{W}, i::Integer) where {W}
526+
# @inline function extractelement(m::Mask{W}, i::Union{Integer,StaticInt}) where {W}
527527
# @boundscheck i > W && throw(BoundsError(m, i))
528528
# getindexzerobased(m, i)
529529
# end
@@ -607,7 +607,7 @@ for (f, cond) ∈ [(:veq, "eq"), (:vne, "ne")]
607607
@eval @generated function $f(
608608
v1::Vec{W,T1},
609609
v2::Vec{W,T2},
610-
) where {W,T1<:Integer,T2<:Integer}
610+
) where {W,T1<:IntegerTypesHW,T2<:IntegerTypesHW}
611611
if sizeof(T1) != sizeof(T2)
612612
return Expr(
613613
:block,
@@ -782,8 +782,8 @@ end
782782
@inline Base.flipsign(x::AbstractSIMD, y::Real) = ifelse(y > zero(y), x, -x)
783783
@inline Base.flipsign(x::Real, y::AbstractSIMD) = ifelse(y > zero(y), x, -x)
784784
@inline Base.flipsign(x::Signed, y::AbstractSIMD) = ifelse(y > zero(y), x, -x)
785-
@inline Base.isodd(x::AbstractSIMD{W,T}) where {W,T<:Integer} = (x & one(T)) != zero(T)
786-
@inline Base.iseven(x::AbstractSIMD{W,T}) where {W,T<:Integer} = (x & one(T)) == zero(T)
785+
@inline Base.isodd(x::AbstractSIMD{W,T}) where {W,T<:Union{Integer,StaticInt}} = (x & one(T)) != zero(T)
786+
@inline Base.iseven(x::AbstractSIMD{W,T}) where {W,T<:Union{Integer,StaticInt}} = (x & one(T)) == zero(T)
787787

788788
@generated function vifelse(m::Vec{W,Bool}, v1::Vec{W,T}, v2::Vec{W,T}) where {W,T}
789789
typ = LLVM_TYPES[T]
@@ -1024,4 +1024,3 @@ end
10241024
@inline Base.min(x::AbstractMask, y::AbstractMask) = x & y
10251025
@inline Base.FastMath.max_fast(x::AbstractMask, y::AbstractMask) = x | y
10261026
@inline Base.FastMath.min_fast(x::AbstractMask, y::AbstractMask) = x & y
1027-

src/llvm_intrin/memory_addr.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -953,7 +953,7 @@ end
953953

954954
@inline function _vload_scalar(
955955
ptr::Ptr{Bit},
956-
i::Integer,
956+
i::Union{Integer,StaticInt},
957957
::A,
958958
::StaticInt{RS},
959959
) where {RS,A<:StaticBool}

src/llvm_intrin/unary_ops.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@ end
3131
@inline vabs(v::AbstractSIMD{W,<:Signed}) where {W} = ifelse(v > 0, v, -v)
3232

3333
@inline vround(v) = round(v)
34-
@inline vround(v::AbstractSIMD{W,<:Integer}) where {W} = v
35-
@inline vround(v::AbstractSIMD{W,<:Integer}, ::RoundingMode) where {W} = v
34+
@inline vround(v::AbstractSIMD{W,<:Union{Integer,StaticInt}}) where {W} = v
35+
@inline vround(v::AbstractSIMD{W,<:Union{Integer,StaticInt}}, ::RoundingMode) where {W} = v
3636

3737

3838
function bswap_quote(W::Int, T::Symbol, st::Int)::Expr

src/promotion.jl

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ function _ff_promote_rule(
2929
::Type{T1},
3030
::Type{T2},
3131
::Val{W},
32-
) where {T1<:Integer,T2<:Integer,W}
32+
) where {T1<:Union{Integer,StaticInt},T2<:Union{Integer,StaticInt},W}
3333
T_canon = promote_type(T1, T2)
3434
__ff_maybe_promote_int(
3535
lt(pick_vector_width(T_canon), StaticInt{W}()),
@@ -38,7 +38,7 @@ function _ff_promote_rule(
3838
Val{W}(),
3939
)
4040
end
41-
ff_promote_rule(::Type{T1}, ::Type{T2}, ::Val{W}) where {T1<:Integer,T2<:Integer,W} =
41+
ff_promote_rule(::Type{T1}, ::Type{T2}, ::Val{W}) where {T1<:Union{Integer,StaticInt},T2<:Union{Integer,StaticInt},W} =
4242
_ff_promote_rule(T1, T2, Val{W}())
4343
ff_promote_rule(
4444
::Type{T1},
@@ -107,11 +107,11 @@ issigned(::Type{T}) where {T} = nothing
107107
Promote, favoring <:Signed or <:Unsigned of first arg.
108108
"""
109109
@inline promote_div(
110-
x::Union{Integer,AbstractSIMD{<:Any,<:Integer}},
111-
y::Union{Integer,AbstractSIMD{<:Any,<:Integer}},
110+
x::Union{Integer,StaticInt,AbstractSIMD{<:Any,<:Union{Integer,StaticInt}}},
111+
y::Union{Integer,StaticInt,AbstractSIMD{<:Any,<:Union{Integer,StaticInt}}},
112112
) = promote_div(x, y, issigned(x))
113113
@inline promote_div(x, y) = promote(x, y)
114-
@inline promote_div(x, y, ::Nothing) = promote(x, y) # for Integers that are neither Signed or Unsigned, e.g. Bool
114+
@inline promote_div(x, y, ::Nothing) = promote(x, y) # for Union{Integer,StaticInt}s that are neither Signed or Unsigned, e.g. Bool
115115
@inline function promote_div(x::T1, y::T2, ::True) where {T1,T2}
116116
T = promote_type(T1, T2)
117117
signed(x % T), signed(y % T)

src/ranges.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ F - static multiplicative factor
3535
::Val{O},
3636
::Val{F},
3737
::StaticInt{SIRS},
38-
) where {W,I<:Integer,O,F,SIRS}
38+
) where {W,I<:Union{Integer,StaticInt},O,F,SIRS}
3939
isone(W) && return Expr(:block, Expr(:meta, :inline), :(Base.add_int(i, $(O % I))))
4040
bytes = pick_integer_bytes(W, sizeof(I), SIRS)
4141
bits = 8bytes
@@ -55,7 +55,7 @@ F - static multiplicative factor
5555
Vec($LLVMCALL($instrs, _Vec{$W,$jtypesym}, Tuple{$jtypesym}, $iexpr))
5656
end
5757
end
58-
@inline function vrangeincr(::Val{W}, i::I, ::Val{O}, ::Val{F}) where {W,I<:Integer,O,F}
58+
@inline function vrangeincr(::Val{W}, i::I, ::Val{O}, ::Val{F}) where {W,I<:Union{Integer,StaticInt},O,F}
5959
_vrangeincr(Val{W}(), i, Val{O}(), Val{F}(), simd_integer_register_size())
6060
end
6161
@generated function vrangeincr(

src/special/misc.jl

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ end
8282
exp2(Base.FastMath.log2_fast(v) * x)
8383
@inline Base.literal_pow(::typeof(^), x::AbstractSIMD, ::Val{N}) where {N} =
8484
pow_by_square(x, StaticInt(N))
85-
# @inline relu(x) = (y = zero(x); ifelse(x > y, x, y))
85+
# @inline relu(x) = (y = zero(x); ifelse(x > y, x, y))
8686
@inline relu(x) = (y = zero(x); ifelse(x < y, y, x))
8787

8888
Base.sign(v::AbstractSIMD) = ifelse(v > 0, one(v), -one(v))
@@ -95,12 +95,12 @@ Base.sign(v::AbstractSIMD) = ifelse(v > 0, one(v), -one(v))
9595
x::AbstractSIMD{W,T},
9696
y::AbstractSIMD{W,T},
9797
::RoundingMode{:Down},
98-
) where {W,T<:Integer}
98+
) where {W,T<:IntegerTypes}
9999
d = div(x, y)
100100
d - (signbit(x y) & (d * y != x))
101101
end
102102

103-
@inline Base.mod(x::AbstractSIMD{W,T}, y::AbstractSIMD{W,T}) where {W,T<:Integer} =
103+
@inline Base.mod(x::AbstractSIMD{W,T}, y::AbstractSIMD{W,T}) where {W,T<:IntegerTypes} =
104104
ifelse(y == -1, zero(x), x - fld(x, y) * y)
105105

106106
@inline Base.mod(x::AbstractSIMD{W,T}, y::AbstractSIMD{W,T}) where {W,T<:Unsigned} =
@@ -135,7 +135,7 @@ end
135135
signed(mod(_x, _y))
136136
end
137137

138-
@inline Base.mod(i::AbstractSIMD{<:Any,<:Integer}, r::AbstractUnitRange{<:Integer}) =
138+
@inline Base.mod(i::AbstractSIMD{<:Any,<:IntegerTypes}, r::AbstractUnitRange{<:IntegerTypes}) =
139139
mod(i - first(r), length(r)) + first(r)
140140

141141
@inline Base.mod(x::AbstractSIMD, y::NativeTypes) = mod(promote_div(x, y)...)
@@ -154,7 +154,7 @@ end
154154
@inline Base.FastMath.hypot_fast(x::AbstractSIMD, y::AbstractSIMD) =
155155
sqrt(Base.FastMath.add_fast(Base.FastMath.mul_fast(x, x), Base.FastMath.mul_fast(y, y)))
156156

157-
@inline Base.clamp(x::AbstractSIMD{<:Any,<:Integer}, r::AbstractUnitRange{<:Integer}) =
157+
@inline Base.clamp(x::AbstractSIMD{<:Any,<:IntegerTypes}, r::AbstractUnitRange{<:IntegerTypes}) =
158158
clamp(x, first(r), last(r))
159159

160160
@inline function Base.gcd(

0 commit comments

Comments
 (0)