<div class="gmail_quote">On 17 January 2012 03:56, Iain Buclaw <span dir="ltr"><<a href="mailto:ibuclaw@ubuntu.com">ibuclaw@ubuntu.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div class="HOEnZb"><div class="h5">On 16 January 2012 22:36, Iain Buclaw <<a href="mailto:ibuclaw@ubuntu.com">ibuclaw@ubuntu.com</a>> wrote:<br>
> On 16 January 2012 21:57, Peter Alexander <<a href="mailto:peter.alexander.au@gmail.com">peter.alexander.au@gmail.com</a>> wrote:<br>
>> On 16/01/12 8:56 PM, Iain Buclaw wrote:<br>
>>><br>
>>> On 16 January 2012 19:25, Walter Bright<<a href="mailto:newshound2@digitalmars.com">newshound2@digitalmars.com</a>><br>
>>> wrote:<br>
>>>><br>
>>>> On 1/16/2012 11:16 AM, Iain Buclaw wrote:<br>
>>>><br>
>>>>>><br>
>>>>>> But don't worry, I'm not planning on working on that at the moment :-)<br>
>>>>><br>
>>>>><br>
>>>>> Leave that sort of optimisation for the backend to handle please. ;-)<br>
>>>><br>
>>>><br>
>>>><br>
>>>> Of course.<br>
>>>><br>
>>>> I suspect Intel's compiler does that one, does gcc?<br>
>>>><br>
>>><br>
>>> There's auto-vectorisation for for(), foreach(), and foreach_reverse()<br>
>>> loops that I have written support for. I am not aware of GCC<br>
>>> vectorising anything else.<br>
>>><br>
>>> example:<br>
>>><br>
>>> int a[256], b[256], c[256];<br>
>>> void foo () {<br>
>>> for (int i=0; i<256; i++)<br>
>>> a[i] = b[i] + c[i];<br>
>>> }<br>
>>><br>
>><br>
>> Unfortunately, if the function was this:<br>
>><br>
>> void foo(int[] a, int[] b, int[] c) {<br>
>><br>
>> for (int i=0; i<256; i++)<br>
>> a[i] = b[i] + c[i];<br>
>> }<br>
>><br>
>> Then it can't vectorize due to aliasing.<br>
><br>
> Compile with -fstrict-aliasing then?<br>
><br>
> I could certainly play about with having this enabled by default, but<br>
> I forsee there may be issues (maybe have it on for @safe code?)<br>
<br>
</div></div>OK, have turned on strict aliasing by default for D2. You should now<br>
be able to vectorise loops that use locals and parameters. :-)<br></blockquote><div><br></div><div>What protects these ranges from being overlapping? What if they were sourced from pointers?</div><div>Are just we to say in D that aliasing is not allowed, and 'you shouldn't do it'? People almost never alias intentionally, it's usually the most insidious of bugs. :/</div>
</div>