HigherOrderCO / Bend

A massively parallel, high-level programming language
https://higherorderco.com
Apache License 2.0
17.48k stars 428 forks source link

HVM inline pass not inlining definitions that have hvm variable indirections. #703

Open developedby opened 2 months ago

developedby commented 2 months ago

Reproducing the behavior

HVM nets that are simple indirections were changed in hvm2 to be compiled as a LINK redex like this

@indirect = a
  & @target ~ a

However, the inline pass we use in Bend just looks directly for nets that are a single atom.

fn should_inline(net: &Net) -> bool {
  net.rbag.is_empty() && tree_children(&net.root).next().is_none()
}

The inline pass should be updated to also inline functions that are essentially just atoms behind var indirections like the example above. Ideally it should work with more than one indirection and even if the atom is not in the left side of the redex.

For example, this should also be inlined

@should_inline = a
  & b ~ a
  & b ~ 9

System Settings

Bend commit 0945efc

Additional context

No response