Skip to content

Commit 7f68365

Browse files
committed
Fix VecUnroll promotion with shifts
1 parent 6a6567f commit 7f68365

File tree

3 files changed

+16
-7
lines changed

3 files changed

+16
-7
lines changed

Diff for: .gitignore

+3
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,7 @@ tests/#*#
99
*~
1010
*.mem
1111
*#*
12+
Manifest.toml
13+
test/Manifest.toml
14+
1215

Diff for: src/vecunroll/fmap.jl

+8-6
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
# unary # 2^2 - 2 = 2 definitions
32
@inline fmap(f::F, x::Tuple{X}) where {F,X} = (f(first(x)),)
43
@inline fmap(f::F, x::NTuple) where {F} = (f(first(x)), fmap(f, Base.tail(x))...)
@@ -90,9 +89,9 @@ for op ∈ [:vgt,:vge,:vlt,:vle,:veq,:vne,:vmax,:vmax_fast,:vmin,:vmin_fast]
9089
end
9190

9291
for op [:vrem, :vshl, :vashr, :vlshr, :vdiv, :vfdiv, :vrem_fast, :vfdiv_fast]
93-
@eval begin
94-
@inline $op(v1::VecUnroll, v2::VecUnroll) = VecUnroll(fmap($op, getfield(v1, :data), getfield(v2, :data)))
95-
end
92+
@eval begin
93+
@inline $op(v1::VecUnroll, v2::VecUnroll) = VecUnroll(fmap($op, getfield(v1, :data), getfield(v2, :data)))
94+
end
9695
end
9796
for op [:vrem, :vand, :vor, :vxor, :vshl, :vashr, :vlshr, :vlt, :vle,:vgt,:vge,:veq,:vne]
9897
@eval begin
@@ -101,7 +100,11 @@ for op ∈ [:vrem, :vand, :vor, :vxor, :vshl, :vashr, :vlshr, :vlt, :vle,:vgt,:v
101100
end
102101
end
103102
for op [:vshl, :vashr, :vlshr]
104-
@eval @inline $op(m::AbstractMask, vu::VecUnroll) = $op(Vec(m), vu)
103+
@eval begin
104+
@inline $op(m::AbstractMask, vu::VecUnroll) = $op(Vec(m), vu)
105+
@inline $op(v1::AbstractSIMDVector, v2::VecUnroll) = VecUnroll(fmap($op, v1, getfield(v2, :data)))
106+
@inline $op(v1::VecUnroll, v2::AbstractSIMDVector) = VecUnroll(fmap($op, getfield(v1, :data), v2))
107+
end
105108
end
106109
for op [:rotate_left,:rotate_right,:funnel_shift_left,:funnel_shift_right]
107110
@eval begin
@@ -238,4 +241,3 @@ end
238241
# @inline vminimum(vu::VecUnroll) = vminimum(collapse_min(vu))
239242
# @inline vall(vu::VecUnroll) = vall(collapse_and(vu))
240243
# @inline vany(vu::VecUnroll) = vany(collapse_or(vu))
241-

Diff for: test/runtests.jl

+5-1
Original file line numberDiff line numberDiff line change
@@ -531,7 +531,8 @@ include("testsetup.jl")
531531
At = ai ? A : (similar(A')');
532532
Bt = bi ? B : (similar(B')');
533533
Ct = ci ? C : (similar(C')');
534-
gsp, pres = @inferred(VectorizationBase.grouped_strided_pointer((At,Bt,Ct), Val{(((1,1),(3,1)),((1,2),(2,1)),((2,2),(3,2)))}()))
534+
spdw = VectorizationBase.DensePointerWrapper{(true,true)}(VectorizationBase.stridedpointer(At))
535+
gsp, pres = @inferred(VectorizationBase.grouped_strided_pointer((spdw,Bt,Ct), Val{(((1,1),(3,1)),((1,2),(2,1)),((2,2),(3,2)))}()))
535536
if ai === ci
536537
@test sizeof(gsp.strides) == 2sizeof(Int)
537538
end
@@ -821,6 +822,9 @@ include("testsetup.jl")
821822
@test gcd(Vec(42,64,0,-37), Vec(18,96,-38,0)) === Vec(6,32,38,37)
822823
@test lcm(Vec(24,16,42,0),Vec(18,12,18,17)) === Vec(72, 48, 126, 0)
823824
end
825+
if VectorizationBase.simd_integer_register_size() 16
826+
@test VecUnroll((Vec(ntuple(Int32,Val(4))...),Vec(ntuple(Int32 Base.Fix2(+,4), Val(4))...))) << Vec(0x01,0x02,0x03,0x04) === VecUnroll((Vec(map(Int32,(2,8,24,64))...), Vec(map(Int32,(10,24,56,128))...)))
827+
end
824828
end
825829
println("Ternary Functions")
826830
@time @testset "Ternary Functions" begin

0 commit comments

Comments
 (0)