JuliaSIMD / LoopVectorization.jl

Macro(s) for vectorizing loops.
MIT License
741 stars 66 forks source link

Offset bitvectors fail to vectorise #465

Open joshniemela opened 1 year ago

joshniemela commented 1 year ago

LoopVectorization.check_args returns false for OffsetArray{Bool, BitVector}, but doesn't with the similar OffsetArray{Bool, Vector{Bool}} Code to reproduce the problem:

using OffsetArrays
using LoopVectorization

OffsetArray(zeros(Bool, 10)) |> LoopVectorization.check_args
OffsetArray(trues(10)) |> LoopVectorization.check_args

Both are expected to return true

chriselrod commented 1 year ago

It should check the offset, and then do a partial iteration to make it a multiple of 8.

joshniemela commented 1 year ago

It should check the offset, and then do a partial iteration to make it a multiple of 8.

Any ideas how I might be able to implement this?

chriselrod commented 1 year ago

I think it'd be a fair bit of work. You could look at https://github.com/JuliaSIMD/LoopVectorization.jl/blob/57c7ffaf56eb3552e5584d9703de9115b9ad65a0/src/codegen/lowering.jl#L288

I am slowly working on replacing this library, but admittedly BitArray support will initially be poor. My point in bringing that up is that further work on LoopVectorization.jl will have a limited lifespan.