

GCC Explorer - dazzawazza
http://xania.org/201205/gcc-explorer
Interactive tool to see what GCC is up to.
======
kevinburke
I remember one time during compilers class I tried to figure out the largest
prime number in the denominator that GCC would replace with multiplication and
bit shifts. I got up to a number in five digits and stopped counting. Just
goes to show the amount of work that goes into compilers and the importance of
speed for some program writers.

~~~
Someone
It likely has code that handles the generic case. See
[http://ridiculousfish.com/blog/posts/labor-of-division-
episo...](http://ridiculousfish.com/blog/posts/labor-of-division-
episode-i.html)

------
gioele
Handy tool. It would be nice if it could show side-by-side diffs of the output
coming from different GCC versions.

~~~
sanxiyn
Or GCC vs LLVM, for that matter. If such link is permanent it could be linked
from GCC or LLVM missed optimization bugs.

------
franzb
Yet more bonus points if you implement a way to correlate (roughly) the
assembly code with the corresponding C++ code. Like, when you select lines in
the C++ code, it highlights the corresponding assembly instructions. Not
trivial, especially at high optimization levels.

~~~
ethereal
Actually, it's not that difficult. Get GCC to generate DWARF [debugging]
information, and then use that to provide the back-references. (Reference:
DWARF 3.0 spec, available at <http://dwarfstd.org/doc/Dwarf3.pdf>. See page
92.) This is how GDB does the same.

The output is a little weird (I've had it execute line 56 before line 55, for
example) and you do have to be careful, as not all lines translate directly.
But it would be at least be a nice starting point. There are even some nice
libraries out there that parse this information!

EDIT: Hmm, I just noticed that the source is on Github. If I get some time
this weekend I'll try adding support for this.

------
BudVVeezer
As a cross-platform developer, I would love to see clang and MSVC as compiler
options so that I'm able to compare the various outputs when trying to track
down undefined/implementation defined behaviors.

As it stands though, this is a fantastic tool! It's right up there with ideone
for me.

------
nuje
What's happening in the signed case? Signed division and modulo have been
redefined in newer C/C++ standards. He talks about writing C but the syntax
looks like C++ 11? at least i don't think he means the C "auto" here.

------
jcromartie
This is great. I often compile with gcc -S but then get swamped by the massive
amount of included stdlib stuff and name manging, so it's hard to find my
code.

------
Andys
Great, but I was hoping for access to libc so I could see if the new
string/popcnt/rand instructions are being used with -march=corei7

------
nwmcsween
Please use vanilla GCC as ubuntu (and other distros) stupidly edit system wide
spec files to add things like fstack-protector.

------
Someone
<http://llvm.org/demo/index.cgi> is a similar tool for clang.

------
udp
For bonus points, get a compiler building with Emscripten and compile the code
locally in the browser.

------
pbrook
Very cool tool, I can easily see this becoming a standard tool for learning
assembly!

------
bigfoot
Nice. Please add more GCC versions (3.x and 4.0 through 4.3?) and the most
recent clang/clang++ releases! Direct pastebin-style links would also be
great.

------
franzb
Very cool. Thanks!

