Compiler Explorer

@compiler-explorer.com

A website for exploring the output of compilers. aka godbolt.org Supports C, C++, Rust, Fortran, COBOL and many many more. Support us at https://patreon.com/mattgodbolt

LLM-explanation is now live in @compiler-explorer.com - An example: compiler-explorer.com/z/rvvx7MxKq * LLMs make mistakes and are overconfident * We'll never force LLMs or AI on you, it's opt in (like clang-tidy, PVS Studio or other tools) * It is *beta* quality Initial results are promising(1/3)

Compiler Explorer - C++ (x86-64 clang 21.1.0)

// setup constexpr auto valid_chars = "0123456789abcdef"; bool is_valid_id(std::string_view maybe_id) { if (maybe_id.size() != 16) { return false; } if (maybe_id.find_first_not_of(valid_ch...

explain.compiler-explorer.com

Hey folks! @compiler-explorer.com is free & open for everyone, but if you're planning to use our API for bulk executions though, please ping us! CE is a shared resource and heavy use can slow things down for the whole community. DM me to chat - happy to help figure out what works for everyone! :)

I've been getting more anecdotal reports that @compiler-explorer.com is slow. Seems to be folks' simple code taking a while, likely queued up behind a longer compile. We've done some digging and it seems to have gotten worse since December last year. Doesn't seem to be bot traffic. Have you noticed?

Huge news! AWS has approved Compiler Explorer for their Open Source Credits program, covering our infrastructure costs for the next year! Thank you AWS for supporting open source! This means faster compiles, better queuing & more improvements coming. Exciting times ahead!

Experimenting with something like this for @compiler-explorer.com - wondering what your thoughts are? AI is getting everywhere, and can be divisive. I'm hoping something like this - so long as I can get the output quality high enough - is a net benefit to help folks learn more about their code.

A screenshot of Compiler Explorer showing an "AI Explain this" view. The source code is: 

bool isspc(char c) { 
    return c == '\n' || c == '\r' || c == '\t' || c == ' ';
}

The asm is:
isspc(char):
        mov     ecx, edi
        cmp     cl, 33
        setb    dl
        movabs  rax, 4294977024
        shr     rax, cl
        and     al, dl
        ret

Below is a "Claude Explain" window with:

The function isspc(char) is compiled to an efficient bit manipulation technique to check for whitespace characters. Let's break down the assembly instructions:

mov ecx, edi

Copies the input character from the edi register (first function argument) to ecx
cl will contain the lowest 8 bits (the character)
cmp cl, 33

Compares the character against decimal 33
This is a preliminary check to quickly filter out non-whitespace characters
setb dl

Sets the dl register to 1 if the character is below 33 (space, tab, newline, etc.)
Uses a conditional set instruction
movabs rax, 4294977024

Loads a pre-computed 64-bit constant
This constant represents a bit mask for whitespace detection
shr rax, cl

Shifts the bit mask right by the character's value
This dynamically positions the mask based on the input character
and al, dl

Performs a bitwise AND between the shifted mask and the previous condition
Produces the final boolean result in al
ret

Returns the result (0 or 1) in al
This implementation is a highly optimized branchless method for checking whitespace characters, using bit manipulation instead of multiple comparisons. It avoids conditional jumps, which can be slower on modern CPUs.

The code checks for space (' '), newline ('\n'), carriage return ('\r'), and tab ('\t') in a single, efficient operation.

We just blocked a TW-based IPv6 address from making many many back-to-back requests, most of which seemed to hit our caches (and thus were duplicates). If this affected you, please DM us or reply and we can help diagnose what went wrong. -mg

So, after over 5 years at Aquatic, I made the tough call to leave and try something else. I had a wonderful time there, enjoyed the work and made some great friends. I'll be taking some time between jobs and will be working on @compiler-explorer.com and other OSS projects. I'm excited!

Investigating a DDoS attack (looks like script kiddies again). Getting a bunch of weird POSTs to our noscript API. Site is handling it but it's alerting me, so have temporarily blocked some things. Apologies if you're caught in the crossfire! -mg