C `restrict` keyword in D

Dukc via Digitalmars-d digitalmars-d at puremagic.com
Wed Sep 6 10:30:44 PDT 2017


On Wednesday, 6 September 2017 at 09:21:59 UTC, Petar Kirov 
[ZombineDev] wrote:
> On Tuesday, 5 September 2017 at 15:46:13 UTC, Dukc wrote:
>> [..]
>>
>> Of course, if we want to support this we should construct a 
>> high-level library template that chooses the correct vector 
>> size for the platform, eliminates that outer for loop and 
>> handles uneven array lenghts.
>
> You mean like this: https://github.com/dlang/druntime/pull/1891?

No. I meant a function which, given an array, returns a range 
over that array which internally reads many elements at once from 
the array by copying them to a static array for handling. Then 
the compiler knows it can take advantage of optimizations like 
that pull request, because it knows static arrays can't overlap, 
even if the original arguments do.

Of course the user should not call that function if the arrays do 
overlap, or if the loop body mutates other elements.

See David Simcha's talk at DConf 13 at 37:30, that's the basic 
idea how I'm thinking the range would internally iterate.

https://www.youtube.com/watch?v=yMNMV9JlkcQ&list=PLpISZoFBH1xtyA6uBsNyQH8P3lx92U64V&index=16


More information about the Digitalmars-d mailing list