Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Indexing Vectors with Vec{N,Int32} generates invalid LLVM assembly #133

Open
favba opened this issue Nov 6, 2024 · 0 comments
Open

Indexing Vectors with Vec{N,Int32} generates invalid LLVM assembly #133

favba opened this issue Nov 6, 2024 · 0 comments

Comments

@favba
Copy link
Contributor

favba commented Nov 6, 2024

MWE:

julia> i = Vec(map(Int32,(1,2,3,4))...)
<4 x Int32>[1, 2, 3, 4]

julia> a = rand(4)
4-element Vector{Float64}:
 0.5626535341100131
 0.7054219085896695
 0.6418954581789188
 0.693063317804356

julia> a[i]
ERROR: Failed to parse LLVM assembly: 
<string>:3:14: error: invalid cast opcode for cast from '<4 x i32>' to '<4 x i64>'
%2 = bitcast <4 x i32> %0 to <4 x i64>
             ^

Stacktrace:
 [1] macro expansion
   @ ~/.julia/packages/SIMD/0q83J/src/LLVM_intrinsics.jl:770 [inlined]
 [2] inttoptr
   @ ~/.julia/packages/SIMD/0q83J/src/LLVM_intrinsics.jl:762 [inlined]
 [3] convert
   @ ~/.julia/packages/SIMD/0q83J/src/simdvec.jl:27 [inlined]
 [4] +
   @ ~/.julia/packages/SIMD/0q83J/src/simdvec.jl:315 [inlined]
 [5] getindex(::Vector{Float64}, ::Vec{4, Int32})
   @ SIMD ~/.julia/packages/SIMD/0q83J/src/arrayops.jl:317
 [6] top-level scope
   @ REPL[21]:1

Explicitly converting to Int64 works as expected:

julia> a[convert(Vec{4,Int64}, i)]
<4 x Float64>[0.5626535341100131, 0.7054219085896695, 0.6418954581789188, 0.693063317804356]

I expected this conversion to be done automatically by the Base.getindex method defined in SIMD.jl

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant