Skip to content

Commit 4dbdd1a

Browse files
committed
Fix StaticStridedPointer reshuffling pointer offset.
1 parent 4c06218 commit 4dbdd1a

File tree

1 file changed

+18
-4
lines changed

1 file changed

+18
-4
lines changed

src/reconstruct_loopset.jl

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -164,12 +164,26 @@ end
164164
function add_mref!(
165165
ls::LoopSet, ar::ArrayReferenceMeta, i::Int, ::Type{S}, name
166166
) where {T, X <: Tuple, S <: AbstractStaticStridedPointer{T,X}}
167-
if last(X.parameters)::Int == 1
168-
pushvarg′!(ls, ar, i, name)
167+
li = ar.loopedindex; lic = copy(li);
168+
inds = getindices(ar); indsc = copy(inds);
169+
Xv = Int[]; foreach(x -> push!(Xv, x), X.parameters)
170+
sp = sortperm(Xv)
171+
Xperm = Expr(:curly, :Tuple)
172+
for (i,p) enumerate(sp)
173+
li[i] = lic[p]
174+
inds[i] = indsc[p]
175+
push!(Xperm.args, Xv[p])
176+
end
177+
isone(Xv[first(sp)]) || makediscontiguous!(getindices(ar))
178+
ginds = Expr(:tuple); foreach(_ -> push!(ginds.args, Expr(:call, lv(:Zero))), eachindex(li))
179+
sptr = if S <: VectorizationBase.StaticStridedPointer
180+
Expr(:call, Expr(:curly, lv(:StaticStridedPointer), T, Xperm), Expr(:call, lv(:gep), extract_varg(i), ginds))
181+
elseif S <: VectorizationBase.StaticStridedBitPointer
182+
Expr(:call, Expr(:curly, lv(:StaticStridedBitPointer), Xperm), Expr(:call, lv(:gep), extract_varg(i), ginds))
169183
else
170-
pushvarg!(ls, ar, i, name)
171-
first(X.parameters)::Int == 1 || makediscontiguous!(getindices(ar))
184+
throw("AbstractStaticStridedPointer type $S not recognized.")
172185
end
186+
pushpreamble!(ls, Expr(:(=), name, sptr))
173187
end
174188
function add_mref!(
175189
ls::LoopSet, ar::ArrayReferenceMeta, i::Int, ::Type{S}, name

0 commit comments

Comments
 (0)