Re: release mode optimization

2013-01-10 Thread monarch_dodra
On Thursday, 10 January 2013 at 20:24:02 UTC, Charles Hixson wrote: On 01/10/2013 08:41 AM, Ali Çehreli wrote: On 01/09/2013 04:14 PM, Charles Hixson wrote: Would the following code: for (int i = 1; i < di.count; i++) { assert (node.di.entry[i - 1].key < node.di.entry[i].key); } be optimized a

Re: release mode optimization

2013-01-10 Thread Charles Hixson
On 01/10/2013 08:41 AM, Ali Çehreli wrote: On 01/09/2013 04:14 PM, Charles Hixson wrote: Would the following code: for (int i = 1; i < di.count; i++) { assert (node.di.entry[i - 1].key < node.di.entry[i].key); } be optimized away if compiled under -release? It looks like you can use std.algor

Re: release mode optimization

2013-01-10 Thread Ali Çehreli
On 01/09/2013 04:14 PM, Charles Hixson wrote: Would the following code: for (int i = 1; i < di.count; i++) { assert (node.di.entry[i - 1].key < node.di.entry[i].key); } be optimized away if compiled under -release? It looks like you can use std.algorithm.isSorted instead: http://dlang.org/p

Re: release mode optimization

2013-01-10 Thread Charles Hixson
di is a struct containing *NO* functions. count, however, is a @property, it just returns a counter variable, but that's not a local property. I *LIKE* the version(assert) { ... } choice. I'd been thinking about debug. I didn't know that version (or possibly assert) could be used that way.

Re: release mode optimization

2013-01-10 Thread monarch_dodra
On Thursday, 10 January 2013 at 00:21:48 UTC, Charles Hixson wrote: Would the following code: for (int i = 1; i < di.count; i++) { assert (node.di.entry[i - 1].key < node.di.entry[i].key); } be optimized away if compiled under -release? If you write it as: // version(assert) { for (i

Re: release mode optimization

2013-01-09 Thread Charles Hixson
On 01/09/2013 04:40 PM, Jonathan M Davis wrote: On Wednesday, January 09, 2013 16:14:47 Charles Hixson wrote: Would the following code: for (int i = 1; i< di.count; i++) { assert (node.di.entry[i - 1].key< node.di.entry[i].key); } be optimized away if compiled under -release? If you compile

Re: release mode optimization

2013-01-09 Thread David Nadlinger
On Thursday, 10 January 2013 at 01:14:42 UTC, H. S. Teoh wrote: I tested DMD on a loop containing assert(true);, and apparently that *is* optimized out with -O. I tested it with the program from Jonathan's post – still has an empty inc/cmp/jl loop in there with -O -release (x86_64). David

Re: release mode optimization

2013-01-09 Thread H. S. Teoh
On Thu, Jan 10, 2013 at 02:03:47AM +0100, David Nadlinger wrote: > On Thursday, 10 January 2013 at 00:40:21 UTC, Jonathan M Davis > wrote: > >So clearly, dmd does _not_ optimize out the loop. I have no idea what > >gdc and ldc do though. > > Wow, DMD doesn't optimize it away indeed, just confirmed

Re: release mode optimization

2013-01-09 Thread David Nadlinger
On Thursday, 10 January 2013 at 00:40:21 UTC, Jonathan M Davis wrote: So clearly, dmd does _not_ optimize out the loop. I have no idea what gdc and ldc do though. Wow, DMD doesn't optimize it away indeed, just confirmed that by a look at the assembly. LDC does delete the loop though, starti

Re: release mode optimization

2013-01-09 Thread Jonathan M Davis
On Wednesday, January 09, 2013 16:14:47 Charles Hixson wrote: > Would the following code: > for (int i = 1; i < di.count; i++) > { assert (node.di.entry[i - 1].key < node.di.entry[i].key); } > > be optimized away if compiled under -release? If you compile with -release, assertions will be compile

release mode optimization

2013-01-09 Thread Charles Hixson
Would the following code: for (int i = 1; i < di.count; i++) { assert (node.di.entry[i - 1].key < node.di.entry[i].key); } be optimized away if compiled under -release?