Skip to content
This repository has been archived by the owner on Oct 9, 2019. It is now read-only.

Intrinsic llvm.bswap not supported #210

Open
doe300 opened this issue Apr 30, 2017 · 2 comments
Open

Intrinsic llvm.bswap not supported #210

doe300 opened this issue Apr 30, 2017 · 2 comments

Comments

@doe300
Copy link
Contributor

doe300 commented Apr 30, 2017

Running code containing the llvm.bswap intrinsic through llvm-spirv crashes with

Fails to save LLVM as SPIRV: InvalidFunctionCall: Unexpected llvm intrinsic

According to the LLVM Language Reference, this intrinsic is used to swap the bytes in integers, e.g. to move from little-endian to big-endian and vice versa.

Since the SPIR-V specification offers no instruction to swap bytes, I guess this intrinsic should be implemented by manually shifting the single bytes in the integer numbers.

@bader
Copy link
Contributor

bader commented May 17, 2017

So far SPIR-V translation library was used by OpenCL front-end compiler only with disabled optimizations. I suppose clang doesn't produce llvm.bswap intrinsic in this mode.

What it the environment you are using SPIR-V library in?

@doe300
Copy link
Contributor Author

doe300 commented May 17, 2017

So far SPIR-V translation library was used by OpenCL front-end compiler only with disabled optimizations. I suppose clang doesn't produce llvm.bswap intrinsic in this mode.

This could very well be, since I explicitly run OpenCL -> (SPIR-V-LLVM clang) -> LLVM-IR -> (llvm-spriv) -> SPIR-V so I can use optimizations -O3 in clang.

I'll try to write a pull request to support this intrinsic once #209 is through.

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

No branches or pull requests

2 participants