Which optimisations are are easier or perhaps only possible in the frontend ?

deadalnix via Digitalmars-d digitalmars-d at puremagic.com
Thu Dec 11 16:20:29 PST 2014


On Thursday, 11 December 2014 at 11:02:31 UTC, Stefan Koch wrote:
> On Thursday, 11 December 2014 at 10:59:24 UTC, Daniel Murphy 
> wrote:
>
>> Why?  If the inliner is out because of DMD's merging process, 
>> then so is the rest of the frontend.
>
> It is not out!
>
> But my question was not about dmd specific things, I meant it 
> more generally.

More generally, you don't want to optimize anything in the 
frontend:
  - It is gonna create unscrutable code for debug.
  - You optimize before inlining, and so won't get the 
optimization allowed by inlining.

You want to add metadata to your IR int he front end to inform 
the middle and back end. You proceed to :
  - optimize callee
  - estimate cost of inlining optimized callee and possibly inline
  - optimize caller

Note that this is a recursive process. You may do a second dance 
in the backend to get all platform specific optimization going on.


More information about the Digitalmars-d mailing list