Stream: git-wasmtime

Topic: wasmtime / PR #5851 Branch folding


view this post on Zulip Wasmtime GitHub notifications bot (Feb 22 2023 at 16:37):

mmitton opened PR #5851 from branch_folding to main:

I have implemented branch folding for constant value conditionals inside the egraph midend. This covers BrIf and BrTable, converting them to Jump instructions and removing edges in the ControlFlowGraph and updating the DominatorTree, detecting unreachable code and removing them as well.

This necessitated having mutable access to the DominatorTree in egraph, so it had to be removed from AliasAnalysis and passed to AliasAnalysis for the functions that needed it. As a side benefit, this cleaned up some lifetimes sprinkled around to have a reference to DominatorTree in AliasAnalysis.

A block is determined to be unreachable if it no longer has any predecessors or has one predecessor and is the head of a loop.

After folding the branch and removing pred/succ to dead code, when a block is processed, a check is made to see if there are parameters to the block and there is one and only one pred to the block. If this is the case, the parameters are detached from the block and aliased to the passed arguments in the BlockCall.

I have chatted briefly with @cfallin while implementing this, and he suggested I create a PR to let people review the changes.

view this post on Zulip Wasmtime GitHub notifications bot (Feb 22 2023 at 17:44):

mmitton updated PR #5851 from branch_folding to main.

view this post on Zulip Wasmtime GitHub notifications bot (Feb 28 2023 at 12:53):

mmitton updated PR #5851 from branch_folding to main.


Last updated: Dec 23 2024 at 13:07 UTC