compiler-optimizations-deep

compiler-optimizations-deep is a skill for Claude Code, Codex from mohitmishra786/low-level-dev-skills. It costs 74 tokens per session (872 once invoked), scanned A, original, MIT.

A guide to compiler optimizations beyond common optimization flags such as `-O3`. It explains how source code becomes machine instructions and why optimizations such as vectorization or register allocation may fail.

In plain words
What is it for?
Use it to investigate missed loop vectorization, register spills, instruction selection, loop-invariant code motion, profile-guided optimization, and post-link BOLT optimization.
Why use it?
It helps explain performance problems that a higher optimization setting alone does not solve.

Skill for Claude CodeCodex

Written for no agent in particular: nothing here depends on one.

Good fit Use it to investigate missed loop vectorization, register spills, instruction selection, loop-invariant code motion, profile-guided optimization, and post-link BOLT optimization.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/mohitmishra786/low-level-dev-skills/compiler-optimizations-deep
Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

Any agent
npx skills add mohitmishra786/low-level-dev-skills --skill compiler-optimizations-deep
Clone the repo
git clone --depth 1 https://github.com/mohitmishra786/low-level-dev-skills

Made for: Claude Code, Codex.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for compiler-optimizations-deep

README.md
[![agentmods](https://agentmods.dev/badge/skills/mohitmishra786/low-level-dev-skills/compiler-optimizations-deep.svg)](https://agentmods.dev/skills/mohitmishra786/low-level-dev-skills/compiler-optimizations-deep)
Your own site
<a href="https://agentmods.dev/skills/mohitmishra786/low-level-dev-skills/compiler-optimizations-deep"><img src="https://agentmods.dev/badge/skills/mohitmishra786/low-level-dev-skills/compiler-optimizations-deep.svg" alt="Measured on agentmods" height="20"></a>
Per session 74 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 872 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe. Third-party audits
  • NVIDIA SkillSpector pass 7 Sept 2026
How audits are shown
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.00074 $0.00872
Opus 5 $0.00037 $0.00436
Sonnet 5 $0.00015 $0.00174
Haiku 4.5 $0.00007 $0.00087

Measured 9d ago against content hash b2c8d0f07cb3, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-08, from the pricing page.

Security

Grade A, and why

compiler-optimizations-deep scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 9d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

skills/compiler-internals/compiler-optimizations-deep/SKILL.md · 101 lines

How it starts

The opening of the file, as written. The whole thing — 101 lines — stays where its author put it; the contents beside it link to each section on GitHub.

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

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)

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)

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).

Read the full file on GitHub · 101 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 9d ago First seen · 101 lines · 74 tokens per session scan A b2c8d0f07cb3

Subscribe to this mod's changes

compiler-optimizations-deep is a skill published in the GitHub repository mohitmishra786/low-level-dev-skills (196 stars, last pushed 2mo ago), licensed MIT. It adds 74 tokens to every session and 872 once invoked, about $0.0004 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.

Related

Other skills, from other repositories

header-only-c-cpp-ingestion

How autonomous agents inspect .h/.hpp header files first to understand class contracts and struct layouts before reading heavy .cpp implementation files, slashing C++ context token spend by 85%.

alivirgo/Major-AI-Skills · 45 tokens

zoom-meeting-sdk-unreal

Zoom Meeting SDK for Unreal Engine wrapper integrations. Use when building Unreal projects that embed Zoom meetings with C++ and Blueprint wrappers, including wrapper-to-SDK mapping concerns.

anthropics/knowledge-work-plugins · 41 tokens

embedded-stm32

Best practices for embedded C/C++ development on STM32 microcontrollers using the HAL, covering peripherals, DMA, interrupts, memory constraints, and hardware-focused testing. Use when writing STM32 HAL code, configuring peripherals generated by STM32CubeMX, working with interrupts or DMA, debugging with SWD/JTAG…

Mindrally/skills · 87 tokens

carbon-lang

Use when evaluating Carbon for a C++ code base, running the carbon toolchain from a nightly or Bazel build, or comparing Carbon with staying on C++. Not for C++ modules: use cpp-modules.

OutlineDriven/outline-driven-development · 46 tokens

abi-and-calling-conventions

Use when explaining System V AMD64, ARM AAPCS, RISC-V psABI, stack frames, variadic calls, or FFI register rules. Not for the Rust FFI binding layer: use rust-ffi.

OutlineDriven/outline-driven-development · 53 tokens

acad-arx-wizard

Agentic ObjectARX project scaffolding for AutoCAD 2027 / Visual Studio 2026. Replaces the broken .vsz VsWizardEngine wizard with a PowerShell script that generates identical C++ project files. Works for new ARX/DBX/CRX projects and add-on class wizards (Jig, Reactors, Custom Object, MFC, .NET Wrapper, COM Wrapper…

autodesk-platform-services/skills · 92 tokens