Re: Array bound checks removal increasing importance

2014-10-26 Thread rst256 via Digitalmars-d
On Saturday, 31 May 2014 at 23:30:41 UTC, Walter Bright wrote: On 5/31/2014 4:06 PM, Nordlöw wrote: I've looked around in DMD for a suitable place to add checks for this but haven't found the spot where range-check is injected. Help anyone? There isn't a suitable place. To make it work, data

Re: Array bound checks removal increasing importance

2014-06-05 Thread Walter Bright via Digitalmars-d
On 5/31/2014 3:56 AM, bearophile wrote: Even adding logic to remove 20% of the bound checks in numeric code is going to help D https://github.com/D-Programming-Language/dmd/pull/3620

Re: Array bound checks removal increasing importance

2014-06-05 Thread bearophile via Digitalmars-d
Walter Bright: https://github.com/D-Programming-Language/dmd/pull/3620 Yes, it's a start point :-) Bye, bearophile

Re: Array bound checks removal increasing importance

2014-06-05 Thread bearophile via Digitalmars-d
Sorry for my slow answering, I'm trying to catch up. Kagamin: Shouldn't optimization go a different route? 1. Get annoying performance problem. 2. Diagnose it. 3. Optimize the hot spot. Do you have 1? That's a good strategy if you are optimizing user code. But even when you write library

Re: Array bound checks removal increasing importance

2014-06-05 Thread bearophile via Digitalmars-d
deadalnix: I think we should focus on solving problems that modern backend aren't capable to optimize. I agree. But those D snippets I have written are not able to show what the backends are or aren't able to do. Generally if you compile D code even with LDC2 you see a significant

Re: Array bound checks removal increasing importance

2014-06-05 Thread bearophile via Digitalmars-d
Dmitry Olshansky: It would be interesting if you could point to a precedent of expression-level attribute used for enforcing that compiler does elide bounds checking Perhaps that's a little invention of mine :-) In the last years I've seen that while optimizations are important, there are

Re: Array bound checks removal increasing importance

2014-06-05 Thread deadalnix via Digitalmars-d
On Thursday, 5 June 2014 at 09:36:53 UTC, bearophile wrote: deadalnix: I think we should focus on solving problems that modern backend aren't capable to optimize. I agree. But those D snippets I have written are not able to show what the backends are or aren't able to do. Generally if you

Re: Array bound checks removal increasing importance

2014-06-03 Thread Kagamin via Digitalmars-d
On Saturday, 31 May 2014 at 10:56:06 UTC, bearophile wrote: Even adding logic to remove 20% of the bound checks in numeric code is going to help D because I think more and more people will not disable bound checks in D. What speedup those 20% will give? 3%? Shouldn't optimization go a

Re: Array bound checks removal increasing importance

2014-06-03 Thread Kagamin via Digitalmars-d
On Monday, 2 June 2014 at 09:46:03 UTC, bearophile wrote: There are papers that show a 20-100% improvement in performance coming from disabling array bound checks in programs that use arrays a lot, like most scientific programs. And D language seems fit for some heavy numerical work.

Re: Array bound checks removal increasing importance

2014-06-03 Thread bearophile via Digitalmars-d
Kagamin: Scientific programs usually process trusted data (or easily validated), so they may need correctness checks, but don't need security checks. I agree. If you see the algorithm works with bound checks, you can turn them off. Algorithms go in different code paths, so different

Re: Array bound checks removal increasing importance

2014-06-02 Thread bearophile via Digitalmars-d
deadalnix: What do GDC or LDC generate for these sample code with optimizations on ? This is not an interesting question because those two programs are meant as parts of larger programs. ldc2 optimizes away both programs to xorl %eax, %eax. And I can't test on GDC because GDC compiler

Re: Array bound checks removal increasing importance

2014-06-02 Thread bearophile via Digitalmars-d
Dmitry Olshansky: An expression attribute? Why turn language into a mess over this tiny problem? It seems to me that you are considering solutions that add arbitrary amounts of complexity to solve relatively small problems. ... That just epithet is remarkable self-destruction. Please be

Re: Array bound checks removal increasing importance

2014-06-02 Thread Iain Buclaw via Digitalmars-d
On 2 June 2014 10:24, bearophile via Digitalmars-d digitalmars-d@puremagic.com wrote: deadalnix: What do GDC or LDC generate for these sample code with optimizations on ? This is not an interesting question because those two programs are meant as parts of larger programs. ldc2 optimizes

Re: Array bound checks removal increasing importance

2014-06-02 Thread bearophile via Digitalmars-d
Iain Buclaw: 1) Get a newer version of GDC 2) Raise bugs - you do this for DMD. Why not GDC? I don't know what to report, it just crashes, with no error messages. Bye, bearophile

Re: Array bound checks removal increasing importance

2014-06-02 Thread Iain Buclaw via Digitalmars-d
On 2 June 2014 12:40, bearophile via Digitalmars-d digitalmars-d@puremagic.com wrote: Iain Buclaw: 1) Get a newer version of GDC 2) Raise bugs - you do this for DMD. Why not GDC? I don't know what to report, it just crashes, with no error messages. Bye, bearophile That doesn't sound

Re: Array bound checks removal increasing importance

2014-06-02 Thread Walter Bright via Digitalmars-d
On 6/2/2014 4:40 AM, bearophile wrote: I don't know what to report, it just crashes, with no error messages. Report the source code you fed to it that caused the crash.

Re: Array bound checks removal increasing importance

2014-06-02 Thread bearophile via Digitalmars-d
Walter Bright: Report the source code you fed to it that caused the crash. Even hello world crashes. Bye, bearophile

Re: Array bound checks removal increasing importance

2014-06-02 Thread Iain Buclaw via Digitalmars-d
On 2 June 2014 17:33, bearophile via Digitalmars-d digitalmars-d@puremagic.com wrote: Walter Bright: Report the source code you fed to it that caused the crash. Even hello world crashes. Bye, bearophile Then that is a start. Post a bug and report clearly what your environment is.

Re: Array bound checks removal increasing importance

2014-06-02 Thread Nordlöw
Please be more gentle toward others. Your attitude is poisonous for creativity, and while I have a thick hide and I can ignore Yes, please! Be good to your fellow D coders!

Re: Array bound checks removal increasing importance

2014-06-02 Thread Dmitry Olshansky via Digitalmars-d
02-Jun-2014 13:46, bearophile пишет: Dmitry Olshansky: An expression attribute? Why turn language into a mess over this tiny problem? It seems to me that you are considering solutions that add arbitrary amounts of complexity to solve relatively small problems. ... That just epithet is

Re: Array bound checks removal increasing importance

2014-06-02 Thread deadalnix via Digitalmars-d
On Monday, 2 June 2014 at 09:24:38 UTC, bearophile wrote: deadalnix: What do GDC or LDC generate for these sample code with optimizations on ? This is not an interesting question because those two programs are meant as parts of larger programs. ldc2 optimizes away both programs to xorl

Re: Array bound checks removal increasing importance

2014-06-02 Thread Iain Buclaw via Digitalmars-d
On 2 Jun 2014 17:49, Iain Buclaw ibuc...@gdcproject.org wrote: On 2 June 2014 17:33, bearophile via Digitalmars-d digitalmars-d@puremagic.com wrote: Walter Bright: Report the source code you fed to it that caused the crash. Even hello world crashes. Bye, bearophile Then

Re: Array bound checks removal increasing importance

2014-06-01 Thread bearophile via Digitalmars-d
Daniel Murphy: There are cases where it should be able to tell without data flow analysis but are currently not implemented. Such cases are not rare: https://issues.dlang.org/show_bug.cgi?id=10594 https://issues.dlang.org/show_bug.cgi?id=10615 https://issues.dlang.org/show_bug.cgi?id=10749

Re: Array bound checks removal increasing importance

2014-06-01 Thread bearophile via Digitalmars-d
Dmitry Olshansky: Who are those people that are not disabling bounds checks in system language ? :) If you show D code on Reddit and you show to compile with -noboundscheck you hear some people growl. I don't remember this happening much in past. So I think the attitude toward disabling

Re: Array bound checks removal increasing importance

2014-06-01 Thread Andrei Alexandrescu via Digitalmars-d
On 5/31/14, 6:47 PM, Meta wrote: On Saturday, 31 May 2014 at 23:30:41 UTC, Walter Bright wrote: There isn't a suitable place. To make it work, data flow analysis would have to be added to the front end. While doable, this is not a simple addition. Eventually, we'll have to do it as a lot of

Re: Array bound checks removal increasing importance

2014-06-01 Thread Dmitry Olshansky via Digitalmars-d
01-Jun-2014 14:21, bearophile пишет: Dmitry Olshansky: Who are those people that are not disabling bounds checks in system language ? :) If you show D code on Reddit and you show to compile with -noboundscheck you hear some people growl. I don't remember this happening much in past. So I

Re: Array bound checks removal increasing importance

2014-06-01 Thread deadalnix via Digitalmars-d
On Saturday, 31 May 2014 at 10:56:06 UTC, bearophile wrote: void main() { int[5] data; foreach (const i; 0 .. 10) data[i] = 0; foreach (immutable i; 0 .. 10) data[i] = 0; int[10] big; foreach (const i, x; big) data[i] = x; } But the compiler must

Re: Array bound checks removal increasing importance

2014-06-01 Thread Nordlöw
For $/n VRP can't be used because it's geared toward constants, not relative to variables. So VRP could inform of something like this number is between 0 and 5, not this number is between 0 and a.length. -- Andrei That's what I thought of aswell. Are there any plans to formalize the

Array bound checks removal increasing importance

2014-05-31 Thread bearophile via Digitalmars-d
My opinions about D array bound checks are slowly changing. I still think -boundscheck=off is useful and good to have. But now I am giving increasing importance to compiler logic that optimizes away bound checks safely. People more and more want a safe system language, more and more persons

Re: Array bound checks removal increasing importance

2014-05-31 Thread Rikki Cattermole via Digitalmars-d
On 31/05/2014 10:56 p.m., bearophile wrote: My opinions about D array bound checks are slowly changing. I still think -boundscheck=off is useful and good to have. But now I am giving increasing importance to compiler logic that optimizes away bound checks safely. People more and more want a safe

Re: Array bound checks removal increasing importance

2014-05-31 Thread Dmitry Olshansky via Digitalmars-d
31-May-2014 14:56, bearophile пишет: My opinions about D array bound checks are slowly changing. I still think -boundscheck=off is useful and good to have. But now I am giving increasing importance to compiler logic that optimizes away bound checks safely. Cool, I hope it means you are getting

Re: Array bound checks removal increasing importance

2014-05-31 Thread bearophile via Digitalmars-d
Rikki Cattermole: The first two foreach statements assignment statements should be compile errors. I'm actually a little bit surprised that we don't already test for this. But I spose that would actually be quite hard. I don't know how hard it is. One purpose of this post is to ask how

Re: Array bound checks removal increasing importance

2014-05-31 Thread Rikki Cattermole via Digitalmars-d
On 1/06/2014 12:04 a.m., bearophile wrote: Rikki Cattermole: The first two foreach statements assignment statements should be compile errors. I'm actually a little bit surprised that we don't already test for this. But I spose that would actually be quite hard. I don't know how hard it is.

Re: Array bound checks removal increasing importance

2014-05-31 Thread Wanderer via Digitalmars-d
void main() { int[5] data; foreach (const i; 0 .. 10) data[i] = 0; foreach (immutable i; 0 .. 10) data[i] = 0; int[10] big; foreach (const i, x; big) data[i] = x; } I'm not sure if bound checks should be removed here. Before removal, this code gives

Re: Array bound checks removal increasing importance

2014-05-31 Thread bearophile via Digitalmars-d
Wanderer: void main() { int[5] data; foreach (const i; 0 .. 10) data[i] = 0; foreach (immutable i; 0 .. 10) data[i] = 0; int[10] big; foreach (const i, x; big) data[i] = x; } I'm not sure if bound checks should be removed here. Before removal, this code

Re: Array bound checks removal increasing importance

2014-05-31 Thread Nordlöw
bound tests. This means that optimizing away bound checks is becoming more and more important in D. And D can't ignore this Expressions like x[0 .. $/n] and x[$/n .. $] are important in many divide and conquer (recursive) algorithms such as quick-sort and shall not need bounds check simply

Re: Array bound checks removal increasing importance

2014-05-31 Thread Walter Bright via Digitalmars-d
On 5/31/2014 4:06 PM, Nordlöw wrote: I've looked around in DMD for a suitable place to add checks for this but haven't found the spot where range-check is injected. Help anyone? There isn't a suitable place. To make it work, data flow analysis would have to be added to the front end. While

Re: Array bound checks removal increasing importance

2014-05-31 Thread Walter Bright via Digitalmars-d
On 5/31/2014 5:02 PM, Nordlöw wrote: Could you elaborate a bit on what data flow optimizations mean? http://en.wikipedia.org/wiki/Data-flow_analysis What other kinds of optimizations will become possible? Escape analysis, for one. http://en.wikipedia.org/wiki/Escape_analysis Is this

Re: Array bound checks removal increasing importance

2014-05-31 Thread Meta via Digitalmars-d
On Saturday, 31 May 2014 at 23:30:41 UTC, Walter Bright wrote: There isn't a suitable place. To make it work, data flow analysis would have to be added to the front end. While doable, this is not a simple addition. Eventually, we'll have to do it as a lot of things become possible better with

Re: Array bound checks removal increasing importance

2014-05-31 Thread Daniel Murphy via Digitalmars-d
Meta wrote in message news:pogogtdjyetukenny...@forum.dlang.org... I've always wondered if VRP can be leveraged in certain situations. I can't remember exactly how it's supposed to work, but very basically, isn't it just numeric variables (and expressions?) having an associated range that