Agent skill
compiler-explorer
Optimize functions by generating and analyzing compiler assembly output. Use when asked to optimize a function, analyze generated assembly, or improve performance by examining what the compiler produces.
Install this agent skill to your Project
npx add-skill https://github.com/rockorager/skills/tree/main/compiler-explorer
SKILL.md
Compiler Explorer
Optimize functions by analyzing compiler-generated assembly. This replicates the workflow of godbolt.org locally.
Workflow
1. Isolate the Function
Create a standalone file with the function to optimize. Export it to prevent inlining:
export fn targetFunction(x: i64) i64 {
// function body
}
__attribute__((noinline)) int targetFunction(int x) {
// function body
}
2. Generate Assembly
# Zig
zig build-obj src/target.zig -femit-asm -fno-emit-bin -O ReleaseFast
# C/C++ (clang)
clang -S -O3 -fno-inline -o target.s target.c
# Rust
rustc --emit=asm -C opt-level=3 target.rs
3. Locate and Read the Function
# Find the assembly file
find . -name "*.s" -newer src/target.zig
# Find function boundaries
grep -n "_targetFunction" output.s
# Count instructions
sed -n 'START,ENDp' output.s | grep -E '^\s+\w' | wc -l
4. Analyze and Iterate
Read through the assembly looking for:
- Unexpected instructions (type conversions, bounds checks, function calls)
- Repeated patterns that could be simplified
- Instructions that don't map to obvious source operations
Make a targeted change, regenerate assembly, compare instruction counts.
5. Benchmark
Always benchmark—fewer instructions ≠ always faster:
zig build-exe bench.zig -O ReleaseFast -o bench_v1
time ./bench_v1
Keep assembly outputs for comparison: function_v1.s, function_v2.s, etc.
Recommended Agent Skills
Expand your agent's capabilities with these related and highly-rated skills.
commit-messages
Write clear commit messages. Use when asked to commit changes, write a commit message, prepare a commit, or describe changes for version control.
scaffold-exercises
Create exercise directory structures with sections, problems, solutions, and explainers that pass linting. Use when user wants to scaffold exercises, create exercise stubs, or set up a new course section.
git-guardrails-claude-code
Set up Claude Code hooks to block dangerous git commands (push, reset --hard, clean, branch -D, etc.) before they execute. Use when user wants to prevent destructive git operations, add git safety hooks, or block git push/reset in Claude Code.
edit-article
Edit and improve articles by restructuring sections, improving clarity, and tightening prose. Use when user wants to edit, revise, or improve an article draft.
handoff
Compact the current conversation into a handoff document for another agent to pick up.
setup-pre-commit
Set up Husky pre-commit hooks with lint-staged (Prettier), type checking, and tests in the current repo. Use when user wants to add pre-commit hooks, set up Husky, configure lint-staged, or add commit-time formatting/typechecking/testing.
Didn't find tool you were looking for?