[OT] compiler optimisations

John Colvin via Digitalmars-d digitalmars-d at puremagic.com
Fri Apr 24 02:55:11 PDT 2015


On Friday, 24 April 2015 at 06:29:55 UTC, deadalnix wrote:
> On Thursday, 23 April 2015 at 10:23:57 UTC, Andrea Fontana 
> wrote:
>> On Thursday, 23 April 2015 at 10:08:24 UTC, John Colvin wrote:
>>>> asm.dlang.org
>>>
>>> and d.godbolt.org
>>>
>>> This isn't a D-specific question though, so gcc.godbolt.org 
>>> would allow you to test a wider range of backends.
>>
>> I was wondering if compilers can optimize this:
>>
>> uint foo3(uint a)
>> {
>>  return a*!(a/5);
>> }
>>
>> That actually gives the same results.
>
> That is cool ! However, careful, division can stall the 
> pipeline.

No optimiser worth it's salt is going to emit a idiv instruction 
there.


More information about the Digitalmars-d mailing list