4 ms·
I'd also be curious to discover how many distinct x86 instructions gcc can even emit? I expect the answer is "a lot less than all of them."
by dreamcompiler 6y ago
I'd also be curious to discover how many distinct x86 instructions gcc can even emit? I expect the answer is "a lot less than all of them."
- kingsuper20 6y agoI mostly just think of the test set they must make use of at Intel. It makes my head hurt. Maybe you end up with a wad of legacy code so large that no one knows how it really works. That ends up being the real definition of the part.
- Someone 6y agoIf you cheat: all of them. GCC supports in-line assembly. Of course, that’s not an interesting observation. It gets (somewhat) interesting when you realize that one may inadvertently include in-line assembly. Do you call including system headers that happen to contain inline assembly cheating? Including headers for a standard C library? Compiling with old-fashioned compiler flags (for example to generate FPU instructions for the x87)?
- saagarjha 6y agoProbably a couple hundred at most, and for common programs several dozen.
- kijiki 6y agoTried it out on Debian Bullseye x86_64: $ objdump -w -j .text --no-show-raw-insn -d /usr/bin/emacs-gtk | egrep '^ *[0-9]+:' | awk '{print $2}' | sort | uniq | wc -l 130 $ objdump -w -j .text --no-show-raw-insn -d /bin/ls | egrep '^ *[0-9]+:' | awk '{print $2}' | sort | uniq | wc -l 97 $ objdump -w -j .text --no-show-raw-insn -d firefox-bin | egrep '^ *[0-9]+:' | awk '{print $2}' | sort | uniq | wc -l 136
- deleted 6y ago[deleted]
- flukus 6y agoWow thanks, this is exactly the type of comment I come to HN for. I wonder if the numbers would change significantly for gentoo or anything compiled manually that had more knowledge of the CPU specifics?
- mjsir911 6y agoFrom my fairly riced gentoo system: $ objdump -w -j .text --no-show-raw-insn -d /usr/lib64/firefox/firefox-bin | egrep '^ \*[0-9]+:' | awk '{print $2}' | sort | uniq | wc -l 134 So actually, less!