Show HN: Autotune – Genetic LLVM phase-ordering CLI that beats Clang -O3 A developer released Autotune, an open-source CLI that uses genetic search over LLVM New Pass Manager phase orderings to build workload-specific pass pipelines, reporting a 13.56× speedup on a 2D convolution kernel (68.90 ms at -O0 down to 5.08 ms) and a 12.58× gain on PolyBench GEMM (227.26 ms to 18.07 ms). Autotune benchmarks against configurable baselines from -O0 to -Os, validates candidates with bitwise, numerical-delta and checksum guards, and re-tests winners with Welch's t-test, Mann-Whitney U, Cohen's d and coefficient-of-variation noise gates before emitting optimized IR, assembly, binaries, CMake snippets and Makefiles. The tool targets compute-intensive kernels on Apple Silicon NEON, AMD Zen and Intel AVX-512, where fixed general-purpose pipelines such as Clang's -O3 are suboptimal because optimization passes are interdependent and non-commutative. A production-grade, AI-guided compiler optimization and diagnostics system that systematically searches, validates, and mathematically proves workload-specific LLVM pass pipelines to outperform standard -O3 . Quick Start -quick-start • Empirical Benchmarks -empirical-proof-benchmarks • Why Autotune? -why-autotune-vs-status-quo • Architecture -system-workflow-architecture • CLI Reference -cli-command-reference • CI/CD Integration -continuous-integration-guard-gate • Documentation https://github.com/youknowme19/Autotune-The-Phase-Ordering-CLI-Doctor/blob/main/docs Compilers like Clang and GCC use fixed, general-purpose pass pipelines such as -O3 or -O2 . While these standard pipelines perform acceptably across millions of disparate software projects, they are fundamentally suboptimal for any specific compute-intensive workload . Because compiler optimizations are interdependent and non-commutative—a phenomenon known in computer science as the Phase-Ordering Problem —applying Pass A before Pass B can either unlock massive SIMD vectorization or permanently destroy vectorization opportunities. Autotune transforms compiler optimization from manual guesswork into a reproducible, developer-usable science: 1. Analyzes Workload AST : Extracts loop nesting, memory-to-compute ratios, branch density, and floating-point intensity without modifying source code. 2. Flexible Baseline Benchmarking : Benchmarks against configurable baselines -O0 , -O1 , -O2 , -O3 , or -Os using nanosecond-precision monotonic hardware timers. 3. Genetic Phase-Ordering Search : Evolves custom sequences of LLVM New Pass Manager NPM transformations tailored to your exact silicon microarchitecture Apple Silicon NEON, AMD Zen, Intel AVX-512 . 4. Strict Pluggable Validation : Bitwise, numerical delta, and checksum execution guards guarantee that optimized binaries produce 100% correct outputs. 5. Rigorous Statistical Proof : Re-evaluates winners with Welch’s t-test, Mann-Whitney U rank-sum tests, Cohen's$d$ effect sizes, and Coefficient of Variation CV% noise gates. 6. Production Artifact Generation : Emits transformed IR .optimized.ll , assembly .s , native binaries .bin , CMake snippets, Makefiles, and standalone Shell compilation scripts. Important Zero Data Fabrication Policy : All speedups and benchmarks reported by Autotune are derived from real empirical execution on physical silicon. The language model is never the final authority—hypotheses must survive execution verification, multi-sample confirmation, and statistical significance testing The following table presents real, un-fabricated benchmark results measured across curated workloads on Apple Silicon ARM64 and Linux x86 64 using LLVM New Pass Manager. Every result is backed by independent multi-sample re-benchmarking, bitwise correctness checks, and Welch's t-test statistical validation: | Workload Kernel | Problem Domain | Baseline Config | Baseline Time | Autotune Time | Confirmed Speedup | Evidence Grade | Primary Compiler Mechanics | |---|---|---|---|---|---|---|---| | 2D Convolution conv2d | Computer Vision / Image Filtering | -O0 | 68.90 ms | 5.08 ms | 13.56× Gain | Grade A | SROA + Loop Rotate + LICM + Vectorize + Unroll | | PolyBench GEMM gemm | Linear Algebra Matrix Multiplication | -O0 | 227.26 ms | 18.07 ms | 12.58× Gain | Grade A | SLP Vectorizer + Early-CSE + GVN + Loop Vectorize | | PolyBench BiCG bicg | BiConjugate Gradient Linear Solver | -O0 | 15.32 ms | 3.21 ms | 4.77× Gain | Grade A | Kernel Loop Pipelining + Interleaved Vectorization | | N-Body Gravity nbody | Astrophysics Particle Simulation | -O0 | 41.91 ms | 10.33 ms | 4.06× Gain | Grade A | SROA + Pairwise Force SIMD + Reassociation | | Dense Matrix Mult matrix mult | Scientific Computing / HPC | -O0 | 46.70 ms | 12.60 ms | 3.71× Gain | Grade A | Loop Flattening + LICM + Invariant Hoisting | | Matrix Transpose matrix transpose | Cache Locality / Strided Memory | -O3 | 38.48 ms | 28.64 ms | 1.34× Gain +30.2% | Grade A | Stride Restructuring over -O3 + Memory SSA LICM | All runs evaluated with $N=10$ confirmation repetitions, 3 warmup iterations, CV noise $< 5.0%$, and $p < 0.0001$. | Feature | Standard clang -O3 | OpenTuner / GCC Plugins | CompilerGym | Autotune Doctor | |---|---|---|---|---| | Workload-Tailored Passes | ❌ Fixed Pipeline | | | ✅ Fully Automated GA + AI | | LLVM NPM Support | ✅ Built-in | ❌ Legacy Pass Manager | ❌ Deprecated Pass Mgr | ✅ Full Modern NPM LLVM 14-22 | | Configurable Baselines | ❌ None | ❌ Ad-hoc | ❌ -O3 Only | ✅ -O0 , -O1 , -O2 , -O3 , -Os | | Statistical Proof Engine | ❌ None | ❌ Mean/Median Only | ❌ Reward Score Only | ✅ Welch | | Bitwise Output Verification | ❌ None | | ❌ Emulated | ✅ Exact, Numeric, Checksum, Script | | Production Build Export | ❌ CLI Flags Only | ❌ Manual Shell Script | ❌ Python Object Only | ✅ CMake, Makefile, Shell, C Header | | Zero-Knowledge Security | N/A | ❌ Plaintext configs | ❌ N/A | ✅ Native OS Keyring Isolation | | CI Regression Gate | ❌ None | ❌ Custom Scripting | ❌ N/A | ✅ Native autotune guard with exit codes | php flowchart TD A C/C++ Workload Source -- B AST Feature Extraction & Profiling B -- C Empirical Baseline Benchmarking: -O0 / -O1 / -O2 / -O3 C -- D{Pipeline Seeding} D -- |Offline Heuristics| E Microarchitecture-Biased Hardware Seeds D -- |LLM Guidance| F AI Pass Candidate Synthesis E -- G Genetic Algorithm Phase-Order Evolution Engine F -- G G -- H LLVM Pipeline Compilation: clang - opt NPM - native binary H -- I Pluggable Correctness Validation Gate I -- |Failed / Miscompiled| J Automatic Discard & Crash Analysis I -- |Verified Correct| K Fresh Multi-Sample Confirmation Benchmarking K -- L Statistical Verification: Welch t-test, Mann-Whitney U, Cohen's d L -- M Evidence Grading: Grade A / B / C / D / F M -- N Structured JSON & Interactive Standalone HTML Reports N -- O autotune apply / export / guard / reproduce Recommended isolated CLI install via pipx : pipx install autotune-doctor Or via pip: pip install autotune-doctor Or zero-setup Docker includes LLVM/Clang toolchain : docker run --rm -v "$PWD:/work" ghcr.io/youknowme19/autotune doctor /work/kernel.c Or Homebrew macOS / Linux : brew install --HEAD packaging/homebrew/autotune.rb Or install latest developer build from source: git clone https://github.com/youknowme19/Autotune-The-Phase-Ordering-CLI-Doctor.git cd Autotune-The-Phase-Ordering-CLI-Doctor pip install -e ". dev " autotune doctor Autotune v0.5.0 Phase-Ordering CLI Doctor System & Toolchain Diagnostics ┏━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓ ┃ Check Component ┃ Status ┃ Details ┃ ┡━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┩ │ Python Version │ OK │ 3.11.15 │ │ OS & Architecture │ OK │ Darwin arm64 - Apple Silicon │ │ Clang Compiler │ OK │ /opt/homebrew/opt/llvm/bin/clang v22.1.8 │ │ LLVM Opt Binary │ OK │ /opt/homebrew/opt/llvm/bin/opt v22.1.8 │ │ Measurement Backend │ OK │ macOS high-precision monotonic timing │ └─────────────────────┴────────┴───────────────────────────────────────────────┘ autotune doctor examples/conv2d/kernel.c --preset quick --baseline -O0 ╭──────────────────────────────────────────────────────────╮ │ AUTOTUNE DOCTOR │ │ AI-Guided LLVM Phase-Ordering Optimization & Diagnostics │ ╰──────────────────────────────────────────────────────────╯ Analyzing kernel.c Preset: quick ... Gen 01/04 ━━━━━╸────────────── | Best: 48.494 ms | Gain: 1.47x | Diversity: 1.00 | Valid: 8 Gen 02/04 ━━━━━━━━━━╸───────── | Best: 48.494 ms | Gain: 1.47x | Diversity: 0.62 | Valid: 7 Gen 03/04 ━━━━━━━━━━━━━━━╸──── | Best: 48.037 ms | Gain: 1.48x | Diversity: 0.88 | Valid: 7 Gen 04/04 ━━━━━━━━━━━━━━━━━━━━╸ | Best: 45.998 ms | Gain: 1.55x | Diversity: 0.88 | Valid: 8 🏆 OPTIMIZATION FOUND - Baseline -O0 : 71.217 ms - Autotune Winner: 45.998 ms - Confirmed Gain: 1.55× Grade A — IMPROVED - Correctness: ✓ PASS - Statistical p: 0.0000 Cohen's d: 56.27 Winning pass pipeline: sroa → loop-rotate → licm → instcombine → loop-unroll Artifacts: - JSON Report: .autotune/runs/run 20260905 195221 f6b2f20b/report.json - HTML Report: .autotune/runs/run 20260905 195221 f6b2f20b/report.html Reproduce: autotune reproduce .autotune/runs/run 20260905 195221 f6b2f20b/report.json Flagship end-to-end workload optimization, evidence grading, and diagnostics. autotune doctor