I built a C++ optimizer that trusts neither me nor the LLM A developer built pgspec, an ahead-of-time C++ specialization pipeline that profiles a binary on recorded workloads, finds dominant runtime value tuples, and regenerates the build so those values become compile-time constants on hot paths, guarded with a generic fallback. The pipeline places an LLM (Claude) alongside rule-based heuristics as a proposer, but gates every proposal behind a bit-exact differential test and a benchmark gate — a check that rejected the developer's own code, benchmark methodology twice, and one of the LLM's ideas. Guards are branchless, and the specialized binary must produce bit-identical results to the generic one on any input. Tracing JITs have a trick that AOT-compiled C++ never gets to use: they watch the values flowing through hot code, specialize for them, and guard the assumption with a cheap check. V8 and LuaJIT do this at runtime. I wanted it for a C++ trading system, ahead of time. So I built pgspec https://github.com/nfedotenko/pgspec — a small pipeline that profiles a binary on recorded workload, finds the values that dominate at runtime, and regenerates the build so those values become compile-time constants on the hot path. Guarded, with a generic fallback, and with an LLM in the loop proposing specializations. The most important design decision turned out to be this: nothing in the pipeline is trusted — not the rule-based heuristics, not the LLM, not even my own benchmark. Every proposal has to survive a bit-exact differential test and beat the baseline on a benchmark before it ships. That gate ended up rejecting my code, my benchmark methodology twice , and one of the LLM's ideas. Here's the tour. profile value histograms → proposer rules | Claude → codegen specialized.hpp → bit-exact differential test → benchmark gate → miss-rate monitor The hot path is a policy template. The generic spec reads everything from the order at runtime: js struct GenericSpec { OrderType type const Order& o const { return o.type; } uint32 t lot size const Order& o const { return o.lot size; } double tick size const Order& o const { return o.tick size; } }; template