Discussion
Loading...

Post

Log in
  • About
  • Code of conduct
  • Privacy
  • Users
  • Instances
  • About Bonfire
alcinnz
alcinnz
@alcinnz@floss.social  ·  activity timestamp 3 hours ago

When optimizing code it helps if QBE minimizes how much the code it compiles uses RAM. But to prevent these optimizations from messing anything up, it 1st needs to analyze which pointers "alias" others.

This analysis clears data for all temps, before iterating over the blocks & their instructions including phis & jumps.

For each phi it populates an "unknown" alias.

If normal instructions write to a temp a unknown-alias is recorded with a base sourced from the target & no offset or slot.

1/?

  • Copy link
  • Flag this post
  • Block
alcinnz
alcinnz
@alcinnz@floss.social replied  ·  activity timestamp 3 hours ago

For alloc instructions its changed to a "loc" alias with a self-referential slot & the giv size. For copy instructions the operand's alias is retrieved from the operand be it a temp or a constant & transfered to the target.

For additions it retrieves the alias of its operands & sums the non-pointer into the offset of the other's.

For blits it records escape aliases or updates a bitmask of mutations. Stores also updates the bitmask the same way.

Esc aliases are recorded for jumps & phi args.

  • Copy link
  • Flag this comment
  • Block
alcinnz
alcinnz
@alcinnz@floss.social replied  ·  activity timestamp 3 hours ago

To query the results of this analysis a function retrieves the aliases of the given references, & compares their offsets under different conditions to determine whether it does, doesn't or might alias.

After that we can get to work on the actual optimization!

An initial iteration over blocks & their instructions discarding non-loads records data on those memory-slices. After which it sorts the resulting array & appends a termintor, allocatser another array, iterates over the 1st, & cleans up.

  • Copy link
  • Flag this comment
  • Block
alcinnz
alcinnz
@alcinnz@floss.social replied  ·  activity timestamp 3 hours ago

For each of the sorted load instructions it skips any his updating a per-block linked-list of them, otherwise it repeatedly examines runs processing the same data in the same block to replace the following instructions with extend/copy opcodes.

I glossed over some details here, so I'll describe this in more detail tomorrow morning!

4/4 Fin for today!

  • Copy link
  • Flag this comment
  • Block

bonfire.cafe

A space for Bonfire maintainers and contributors to communicate

bonfire.cafe: About · Code of conduct · Privacy · Users · Instances
Bonfire social · 1.0.1-alpha.40 no JS en
Automatic federation enabled
Log in
  • Explore
  • About
  • Members
  • Code of Conduct