3 ms·
> It'd be interesting to know how Do you mean how this things are implemented in general or how come that this particular function was reduced to one instructi
by acqq 10y ago
> It'd be interesting to know how
Do you mean how this things are implemented in general or how come that this particular function was reduced to one instruction? The answer to later wrote
gjm11 here: https://news.ycombinator.com/item?id=11764800 https://news.ycombinator.com/item?id=11764800 (it was to make LLVM good at some benchmark!)
The answer to former is: once the sorce code ins transformed to some intermediary form, a lot of optimizations simply look for the "best match" for different patterns and then replace the matched intermediary form sequence with the replacement sequence. Once you have an infrastructure in your compilers, it's typically not so hard to add one more "replace this with that" to get this result to win the benchmark.