GDC review process.

Manu turkeyman at gmail.com
Wed Jun 20 04:38:42 PDT 2012


On 20 June 2012 14:19, Tobias Pankrath <tobias at pankrath.net> wrote:

> It's because the compiler doesn't understand assembly code. It has no
>> knowledge of what it actually does, and as a result, just treats it as a
>> black box.
>>
>
> But this is not set in stone. If I teach a compiler how to optimize
> intrinsics, can't I teach him to understand and optimize a (maybe small)
> subset of assembler, too? This must happen in the backend anyway, since
> intrinsics are platform-dependent, no?
>

It's MUCH easier with intrinsics. Teaching it to understand assembly
involves learning a foreign language, and also for the _compiler_ to
understand and predict the product of the codegen step. The compiler is
usually completely separated from the codegen, it doesn't understand the
architecture it targets. But using the knowledge supplied by the intrinsic
API, it can do the optimisations it needs to in the usual way.

Declare the intrinsic as pure/nothrow, declare its arguments as
in/scope/const/etc, it now knows a lot more about what to expect from the
magic code beneath the intrinsic, and it can safely perform regular
optimisation around it. Also, the codegen can use standard register
assignment, which is important, and integrate nicely with regular program
control structure.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.puremagic.com/pipermail/digitalmars-d/attachments/20120620/d97040bf/attachment.html>


More information about the Digitalmars-d mailing list