cairo_lang_lowering::optimizations::cancel_ops

Function cancel_ops

source
pub fn cancel_ops(lowered: &mut FlatLowered)
Expand description

Cancels out a (StructConstruct, StructDestructure) and (Snap, Desnap) pair.

The algorithm is as follows: Run backwards analysis with demand to find all the use sites. When we reach the first item in the pair, check which statement can be removed and construct the relevant renamed_vars mapping.

See CancelOpsContext::handle_stmt for more detail on when it is safe to remove a statement.