LLVM for OpenCL

Dear all,

I’m newbie in LLVM. I would like to know if it is available an optimizer for OpenCL in LLVM, in the same way as the ‘opt’ command in LLVM.

Concretely, if it is possible to perform individual optimizations/transformations over OpenCL code (either at source or bitcode representation) as it can be done for C code using:

  • ‘clang’ to generate the .bc file(s)
  • ‘opt’ to perform optimizations/transformations over

Is it possible to use the same LLVM ‘opt’ as for C code, once OpenCL program is translated to bitcode/IR/SPIR?

Thanks in advance.


A OpenCL C/C++ code can be compiled to LLVM bitcode, so it can be processed by opt. But currently to my best knowledge, there is no OpenCL-specific Passes in upstream LLVM.


You can find some OpenCL-specific transformations in pocl 1 and in intel-graphics-compiler 2 LLVM-based projects outside of LLVM