October 25, 2019 Re: Eliding of slice range checking | ||||
---|---|---|---|---|
| ||||
Posted in reply to Per Nordlöw | On Thursday, 24 October 2019 at 21:02:03 UTC, Per Nordlöw wrote:
> On Thursday, 24 October 2019 at 18:37:05 UTC, welkam wrote:
>> I remember in some video Chandler Carruth said that value range propagation across function boundary was implemented in llvm but later removed because it produced no performance improvement for C and C++ code. I wonder how it fare when used on D code.
>
> Interesting. What uses of VRP do you see in D?
Now that you asked I realized that it wont be that much useful because in D all arrays go together with their size so cross function VRP would do little.
|
October 25, 2019 Re: Eliding of slice range checking | ||||
---|---|---|---|---|
| ||||
Posted in reply to Stefan Koch | On 10/25/2019 05:37 AM, Stefan Koch wrote:
> just replace x = a[i] with x = a.ptr[i];
That's a neat trick!
Ali
|
October 25, 2019 Re: Eliding of slice range checking | ||||
---|---|---|---|---|
| ||||
Posted in reply to Ali Çehreli | On Friday, 25 October 2019 at 15:22:12 UTC, Ali Çehreli wrote:
> On 10/25/2019 05:37 AM, Stefan Koch wrote:
>
>> just replace x = a[i] with x = a.ptr[i];
>
> That's a neat trick!
>
> Ali
But it requires the function to be qualified as @trusted which might hide a @system == operator. How common is it for a == operator to be unsafe?
|
October 29, 2019 Re: Eliding of slice range checking | ||||
---|---|---|---|---|
| ||||
Posted in reply to Per Nordlöw | On Wednesday, 23 October 2019 at 11:20:59 UTC, Per Nordlöw wrote: > Does DMD/LDC avoid range-checking in slice-expressions such as the one in my array-overload of `startsWith` defined as > > bool startsWith(T)(scope const(T)[] haystack, > scope const(T)[] needle) > { > if (haystack.length >= needle.length) > { > return haystack[0 .. needle.length] == needle; // is slice range checking avoid here? > } > return false; > } LDC is good at optimizing simple patterns, the only pitfall I know is https://forum.dlang.org/post/eoftnwkannqmubhjotat@forum.dlang.org |
October 29, 2019 Re: Eliding of slice range checking | ||||
---|---|---|---|---|
| ||||
Posted in reply to kinke | On Wednesday, 23 October 2019 at 13:51:19 UTC, kinke wrote:
> You call this messy?!
>
> cmpq %rdi, %rdx
> jae .LBB0_2
> xorl %eax, %eax
> retq
> .LBB0_2:
> movq %rdi, %rax
> testq %rdi, %rdi
> je .LBB0_3
> pushq %rax
> .cfi_def_cfa_offset 16
> movq %rcx, %rdi
> movq %rax, %rdx
> callq memcmp@PLT
> testl %eax, %eax
> sete %al
> addq $8, %rsp
> .cfi_def_cfa_offset 8
> retq
> .LBB0_3:
> movb $1, %al
> retq
No, this is fine. Thanks.
|
October 29, 2019 Re: Eliding of slice range checking | ||||
---|---|---|---|---|
| ||||
Posted in reply to Per Nordlöw | On Friday, 25 October 2019 at 21:33:26 UTC, Per Nordlöw wrote:
> But it requires the function to be qualified as @trusted which might hide a @system == operator. How common is it for a == operator to be unsafe?
Ping.
|
October 31, 2019 Re: Eliding of slice range checking | ||||
---|---|---|---|---|
| ||||
Posted in reply to Per Nordlöw | On Wednesday, 23 October 2019 at 11:20:59 UTC, Per Nordlöw wrote: > Does DMD/LDC avoid range-checking in slice-expressions such as the one in my array-overload of `startsWith` defined as > > bool startsWith(T)(scope const(T)[] haystack, > scope const(T)[] needle) > { > if (haystack.length >= needle.length) > { > return haystack[0 .. needle.length] == needle; // is slice range checking avoid here? > } > return false; > } LDC is good at optimizing simple patterns, the only pitfall I know is https://forum.dlang.org/post/eoftnwkannqmubhjotat@forum.dlang.org |
Copyright © 1999-2021 by the D Language Foundation