compiler-optimizations-deep
/compiler-optimizations-deep
Deep compiler optimizations skill for RA, ISel, and PGO. Use when explaining register allocation, instruction selection, LICM, vectorization limits, or profile-guided optimization beyond -O3. Activates on queries about register allocation, instruction selection, LICM, auto-vectorization failure, PGO, or BOLT.
- Author
- mohitmishra786 ↗
- Repository
- low-level-dev-skills ↗
- Licence
- MIT
- Last repository change
- 27.06.2026
Assessment and security
- Files in this package
- 1
- Scripts
- 0
- HTML comments
- 0
- URLs in SKILL.md
- 0
No signals detected. Repository changed on 27.06.2026, without references to retired models or APIs.
MIT, open: use and modify while retaining author attribution.
What it does and when to use it
Deep compiler optimizations skill for RA, ISel, and PGO. Use when explaining register allocation, instruction selection, LICM, vectorization limits, or profile-guided optimization beyond -O3. Activates on queries about register allocation, instruction selection, LICM, auto-vectorization failure, PGO, or BOLT.
Original author description
Deep compiler optimizations skill for RA, ISel, and PGO. Use when explaining register allocation, instruction selection, LICM, vectorization limits, or profile-guided optimization beyond -O3. Activates on queries about register allocation, instruction selection, LICM, auto-vectorization failure, PGO, or BOLT.
How it works
- Purpose
- When to Use
- Workflow
- Common Problems
- Related Skills
SKILL.md preview
--- name: compiler-optimizations-deep description: Deep compiler optimizations skill for RA, ISel, and PGO. Use when explaining register allocation, instruction selection, LICM, vectorization limits, or profile-guided optimization beyond -O3. Activates on queries about register allocation, instruction selection, LICM, auto-vectorization failure, PGO, or BOLT. --- # Compiler Optimizations (Deep) ## Purpose Explain optimization phases beyond flags: mid-level IR opts, register allocation, instruction selection/scheduling, vectorization boundaries, PGO, and post-link BOLT — bridging `skills/compilers/pgo` and LLVM/GCC internals. ## When to Use - `-O3` did not vectorize a hot loop - Teaching why register pressure causes spills - Planning PGO or BOLT deployment - Understanding pass interaction (e.g., LICM before vectorize) ## Workflow ### 1. Compiler pipeline map ``` Frontend → LLVM IR / GCC GIMPLE ├── Mid-level: DCE, GVN, LICM, inlining ├── Loop opts: unroll, vectorize ├── Codegen prep: legalize types ├── Instruction selection (DAG → machine ops) ├── Register allocation (greedy, linear scan) └── Peephole / scheduling ``` ### 2. Vectorization failure triage ```bash clang -O3 -Rpass=loop-vectorize -Rpass-missed=loop-vectorize foo.c ``` | Miss reason | Typical fix | |-------------|-------------| | Unknown trip count | peel loop; assert count | | Dependence | reorder / separate accumulators | | Function call in loop | inline or outline | | Alignment unknown | `__builtin_assume_aligned` | ### 3. Register allocation intuition When live ranges exceed physical registers, the allocator **spills** to stack slots — costly loads/stores. Reducing live ranges (splitting variables, rematerialization) helps. GCC/LLVM both use graph coloring variants (LLVM "greedy regalloc"). ### 4. PGO workflow (Clang) ```bash clang -fprofile-instr-generate -O2 -o app foo.c ./app # training workload llvm-profdata merge default.profraw -o default.profdata clang -fprofile-instr-use=default.profdata -O2 -o app_pgo foo.c ``` Improves branch layout, inlining, and vectorization thresholds. See `skills/compilers/pgo` for GCC and BOLT. ### 5. BOLT (post-link) ```bash llvm-bolt -instrument app -o app.inst ./app.inst llvm-bolt -data=perf.fdata -reorder-blocks=+ -o app.bolt app ``` Optimizes layout after linker — needs relocations (`-Wl,--emit-relocs`). ### 6. LICM example Loop-invariant code motion hoists `x * scale` out of inner loop when legal — reduces work per iteration. ### 7. Agent usage ``` /compiler-optimizations-deep Why did LLVM fail to vectorize this reduction loop? ``` ## Common Problems | Symptom | Cause | Fix | |---------|-------|-----| | PGO no gain | Unrepresentative training | Match production input | | BOLT crash | Stripped binary | Keep symbols + relocs | | Spills in asm | Register pressure | Simplify live ranges | | `-O3` slower | Code bloat / cache | Try `-O2` or PGO | | Different GCC/Clang | Pass ordering differs | Compare IR + asm | ## Related Skills - `skills/compilers/pgo` — PGO and BOLT detail - `skills/compiler-internals/llvm-ir-and-passes` — IR-level opts - `skills/compiler-internals/code-generation-and-backends` — ISel and backends - `skills/computer-architecture/cpu-pipelines-and-hazards` — scheduling context - `skills/low-level-programming/simd-intrinsics` — manual vectorization
Versions
| Repository | Score | Licence |
|---|---|---|
| This page · mohitmishra786/low-level-dev-skills | 100 | MIT |
| OutlineDriven/outline-driven-development | 100 | Apache-2.0 |
Database snapshot: 13.11.2026 · package version 3d4aaee83de6 (SHA-256 digest of the entire package)
Downloads in the last 30 days: 0 · ranking
Report a problem with this skill: harmful content, incorrect descriptions or an author’s removal request.
Similar skills
- 100pgo
Profile-guided optimisation skill for C/C++ with GCC and Clang. Use when squeezing maximum runtime performance after standard optimisation plateaus, implementing two-stage PGO builds, collecting profile data, or applying BOLT for post-link optimisation. Activates on queries… - 100pgo
Use when a C or C++ binary needs profile-guided optimization with GCC or Clang: instrumented or sampled profiles, merging, the two-stage build, or BOLT. Not for base flags: use gcc or clang. - 100checking-go-pgo-profiles
Checks whether a Go PGO profile (default.pgo) still matches the code it is applied to, by building the main package with the profile and reading which hot call sites the compiler still matches. Explains each lost function or call site, such as a rename, a move to another… - 100simd-intrinsics
Use when reading auto-vectorization reports, writing SSE2, AVX2, or NEON intrinsics, or fixing vectorization failures. Not for reading the asm itself: use assembly-x86. - 100react
Expert React assistance covering React 19, Server Components (RSC), hooks, compiler optimizations, and concurrent features. Use when building modern web user interfaces and single-page apps. - 100simd-intrinsics
SIMD intrinsics skill for x86 (SSE/AVX) and ARM (NEON) vectorization. Use when reading auto-vectorization reports, writing SSE2/AVX2/NEON intrinsics, checking CPU feature flags at runtime, choosing between compiler builtins and raw intrinsics, or diagnosing why…