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

Change to make bswap(::Vec{<:Any, <:Union{UInt8, Int8}}) a pass-through #122

Closed
kimikage opened this issue Jun 12, 2024 · 6 comments
Closed

Comments

@kimikage
Copy link

kimikage commented Jun 12, 2024

Currently, bswap(::Vec) calls Intrinsics.bswap, but LLVM does not support odd-byte bswap.
https://github.com/llvm/llvm-project/blob/6009708b4367171ccdbf4b5905cb6a803753fe18/llvm/lib/IR/Verifier.cpp#L5790-L5795

Normally, 1-byte (i.e., UInt8 and Int8) bswaps are eliminated somewhere in the code generation path, but they might remain for some reason. (cf. tlnagy/TiffImages.jl#166)

Perhaps this is an issue that should be addressed in LLVM or Julia compiler, but a workaround in SIMD.jl might not be a bad idea.

@maleadt
Copy link
Contributor

maleadt commented Jan 8, 2025

TestImages.jl also suffers from this, so I'd say this is something important to fix.

maleadt added a commit to JuliaCI/PkgEval.jl that referenced this issue Jan 8, 2025
@eschnett
Copy link
Owner

eschnett commented Jan 8, 2025

I have a potential fix but I cannot reproduce the problem. Can you give details? Which Julia/LLVM versions are you using etc.? Which CPU architecture is this? What is the error you see?

@eschnett
Copy link
Owner

eschnett commented Jan 8, 2025

See #137

@maleadt
Copy link
Contributor

maleadt commented Jan 8, 2025

I reproduced it on x86_64 (zen3) with:

import TiffImages, Downloads

_wrap(name) = "https://github.com/tlnagy/exampletiffs/blob/master/$name?raw=true"

using Downloads
get_example(x) = Downloads.download(_wrap(x))

filepath = get_example("capitol.tif")
img = TiffImages.load(filepath)

Requires an assertions builds, of course. On latest master:

julia> img = TiffImages.load(filepath)
bswap must be an even number of bytes
  %195 = call <32 x i8> @llvm.bswap.v32i8(<32 x i8> %194), !dbg !206
LLVM ERROR: Broken module found, compilation aborted!

@eschnett
Copy link
Owner

eschnett commented Jan 8, 2025

I did not manage to get an error message, but I did see CI failures when I added a test. #137 is ready for review.

@eschnett
Copy link
Owner

eschnett commented Jan 8, 2025

Fixed in SIMD 3.7.1.

@eschnett eschnett closed this as completed Jan 8, 2025
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

3 participants