A Friendly Challenge for D

Jabari Zakiya jzakiya at gmail.com
Tue Oct 16 22:08:43 UTC 2018


On Tuesday, 16 October 2018 at 21:12:39 UTC, welkam wrote:
> On Tuesday, 16 October 2018 at 20:58:54 UTC, Jabari Zakiya 
> wrote:
>> And they could be modded to catch semantics like this and 
>> produce faster code.
>
> Its hard to prove that you will only write 1 or 0 in the array 
> and even if you write such pass it wont fire very often. So 
> slower compile times for no gain in common case.
>
>
>> My guess is the difference in code execution times based on 
>> the ALU operation pipeline.
>
>
> and my guess is that CPU knows that its going to write the same 
> value to memory so it ignores that write.

Exactly. It does the same instruction twice, and once it's set 
the first time it can ignore setting it the second time.

However with seg[k] = 1 , the mov instruction always moves, 
because it doesn't know|care what the previous value was. That's 
my guess.

> Life is too short for such things. Today compilers are good at 
> optimizing low level stuff. Those decades of improvements add 
> up.

Amen! :-)



More information about the Digitalmars-d mailing list