assume, assert, enforce, @safe
John Colvin via Digitalmars-d
digitalmars-d at puremagic.com
Thu Jul 31 09:36:26 PDT 2014
On Thursday, 31 July 2014 at 15:37:23 UTC, Daniel Gibson wrote:
> Am 31.07.2014 17:26, schrieb Artur Skawina via Digitalmars-d:
>> On 07/31/14 15:44, Daniel Gibson via Digitalmars-d wrote:
>>> And don't forget this (rather old) case:
>>> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=8537
>>> (I really don't get why anyone would want such an
>>> optimization: I want an optimizer to use clever inlining, use
>>> SSE etc where it makes sense and stuff like that - but not to
>>> remove code I wrote.)
>>
>> That is actually not a bug, but a perfectly valid
>> optimization. The
>> compiler isn't clairvoyant and can not know that some data
>> that you
>> wrote, but never read back, matters.
>
> I don't want the compiler to care about that. When I tell it to
> write something, I want it to do that, even if it might look
> like nonsense (if anything, it could create a warning).
>
> The thing is: I don't want a compiler to remove code I wrote
> just because it "thinks" it's superfluous.
The idea that the compiler simply lowers your code to
well-written assembly died decades ago. The job of an optimiser
is to *not* use your code but instead to compile a program that
is equivalent to yours but faster/smaller. What is equivalent is
defined by the language spec.
More information about the Digitalmars-d
mailing list