|
![](/i/fill.gif) |
On 19/08/2013 08:01 PM, Warp wrote:
> If we "disassemble" that back to C++, it's basically equivalent to:
>
> //-----------------------------------------
> int a(int input)
> {
> return input == 0 ? 0 : -input;
> }
> //-----------------------------------------
>
> For some reason gcc produces a needless test against zero, but
> otherwise it's rather impressive that it got rid of the loop completely.
That *is* pretty impressive, actually... I wonder how on Earth it
figures that out. I doubt anybody would have put a special case into the
compiler just for this, so I wonder how it figures it out...
Post a reply to this message
|
![](/i/fill.gif) |