On Friday, 1 August 2014 at 22:34:02 UTC, Walter Bright wrote:
On 8/1/2014 2:50 PM, Jonathan M Davis wrote:
Thinking about it, I'm actually wondering if I should use assertions _more_ so that the compiler might be able to do better optimizations in -release.

I think this will be a productive strategy once this gets implemented in optimizers.

Of course, using them effectively will not be easy unless one is willing to understand how data flow analysis works and is willing to examine the generated code.

True, but as long as the runtime cost isn't too great for your debug builds, having assertions for whatever conditions you think your code relies on and would ideally be checked is quite beneficial. Any optimizations by the compiler would then be a bonus, but the fact that they exist does offset the costs to debug builds somewhat (depending on what you're doing) by improving the release builds. I would think that any attempt to specifically craft assertions to aid the optimizer would be something that should generally be left to the cases where you really care about getting extra speed out of your program and are doing micro-optimizations based on profiling and the generated assembly and whatnot.

- Jonathan M Davis

Reply via email to