LLVM Vulkan 1.1: Drop-in compiler passes (GVN, CSE, CFG, DCE) on Vulkan compute with benchmarks & Clang integration
Hey r/programming and r/Compilers, I've just released LLVM Vulkan 1.1 , an open-source project that moves beyond an experimental prototype into a drop-in pass plugin that accelerates LLVM middle-end passes using portable Vulkan compute shaders: Live Project Site : hecer.github.io/llvm-vulkan GitHub Repository : github.com/HECer/llvm-vulkan GitHub Release v1.1.0 : github.com/HECer/llvm-vulkan/releases/tag/v1.1.0 Interactive Benchmark Dashboard (109 rows) : hecer.github.io/llvm-vulkan/graphs/benchmarks.html 12-Slide Offline Project Presentation : hecer.github.io/llvm-vulkan/project-presentation.html What it actually does Rather than claiming to rewrite LLVM or port the entire backend to GPU, LLVM Vulkan provides a standalone C++17 bulk-compute library ( LLVMVulkan::compute ) and an LLVM pass plugin with strict host semantic authority : 1. GPU-Accelerated GVN ( gvn / lv-gvn ) : Computes dense dominator trees on GPU workgroups to eliminate redundant expressions across basic blocks dominated by the candidate. 2. Commutative CSE ( early-cse / lv-cse ) : Normalizes operand IDs for commutative operations ( add , mul , and , or , xor , eq , ne ) before GPU record hashing, deduplicating reversed expressions like a + b and b + a . 3. Control Flow Graph Simplification ( simplifycfg / lv-cfg ) : High-throughput reachability closure over module-wide control flow graphs. 4. Dead Code Elimination ( dce / adce / lv-dce ) : Backward def-use reachability closure, salvaging debug records and dropping dead SSA cycles. 5. Integer Constant Folding ( instcombine / lv-fold ) : Batched modular integer arithmetic and bitwise folding through 64 bits ( shaderInt64 ). Quick Drop-in Usage with Clang and opt `bash Direct opt pipeline using standard pass aliases: opt -load-pass-plugin=LLVMVulkan.so -passes='early-cse,gvn,simplifycfg,dce' input.ll -S -o output.ll Automatic Clang -O2 integration via extension points: export LV_AUTO_INSERT=1 clang -fpass-plugin=LLVMVulkan.so -O2 -c main.c -o main.o ` The Numbers: RTX 5090 vs Ryzen 9 5950X (1,048,576 elements) We measured complete host wall times including upload, GPU dispatch, convergence, synchronization, and host readback: Workload Ryzen 9 5950X RTX 5090 Speedup Sort keys (radix sort vs std::sort ) 55.96 ms 1.67 ms 33.59× Integer fold (32-bit scalar batches) 12.66 ms 4.17 ms 3.04× Integer fold (64-bit) 16.18 ms 7.10 ms 2.28× Hash records (instruction tuples) 3.33 ms 2.65 ms 1.26× Exclusive scan (prefix sums) 1.28 ms 1.47 ms 0.87× (CPU wins) Where the CPU Still Wins Transparency is our top priority: - Small Workloads : At 1,024 elements, the CPU wins every benchmark due to kernel launch and transfer latency. The plugin defaults to scalar CPU unless LV_BACKEND=vulkan or automatic threshold batching is enabled. - Sparse / Long-Chain Graphs : On long single-chain graphs, the CPU is up to 151× faster (0.064 ms vs 9.71 ms) because worklist algorithms beat GPU fixed convergence rounds. - Memory SSA / Pointer Aliasing : The plugin deliberately handles pure SSA values, leaving complex memory disambiguation and pointer aliasing to upstream LLVM. Testing & Packages Verified against LLVM 21 and pinned LLVM main: 19/19 fixtures pass, 8,192 constant oracle tests pass, and semantic fuzzing passes. Relocatable packages for Windows ( .zip ) and Linux ( .tar.gz ) available on the GitHub Release page. Self-contained offline HTML presentation and interactive benchmark explorer. Feedback, benchmark reproductions, and thoughts on GPU-accelerated compiler passes are very welcome!