[OT] compiler optimisations
J via Digitalmars-d
digitalmars-d at puremagic.com
Thu Apr 23 05:02:05 PDT 2015
On Thursday, 23 April 2015 at 08:33:56 UTC, John Colvin wrote:
> Why can no compiler I try optimise this toy example as I would
> expect?
>
> // uncomment if using a C compiler
> // typedef unsigned int uint;
> uint foo(uint a)
> {
> if (a < 5)
> return (a * 3) / 3;
> else
> return 0;
> }
It is interesting to see how things do get optimized when e.g.
changing the multiply * into a plus +.
More information about the Digitalmars-d
mailing list