[Issue 936] Optimization by compiler hints

d-bugmail at puremagic.com d-bugmail at puremagic.com
Sat Feb 10 03:11:19 PST 2007


http://d.puremagic.com/issues/show_bug.cgi?id=936





------- Comment #4 from fvbommel at wxs.nl  2007-02-10 05:11 -------
(In reply to comment #2)
> The reporter's point is that one of these ways in which compilers can become
> smarter is by using assert expressions as optimisation hints.  Why add a pragma
> as an extra way of doing the same thing?

An assert indicates "this is true".
A pragma could add a way to say "this is *probably* true".
The compiler could then perhaps emit code optimized to run the most likely path
as fast as possible, at the expense of less likely paths.

For instance, you could tell it that it's unlikely a function returned an error
code (let's assume this was a C function that doesn't know about exceptions) so
perhaps the code for when the error occurs should be the one performing a jump
instruction[1].


[1]: I read somewhere that conditional jumps are less expensive when the
condition does not hold. I have no idea if this is still the case for modern
processors, this is just an example.


-- 



More information about the Digitalmars-d-bugs mailing list