cairo_lang_lowering::optimizations::match_optimizer

Function optimize_matches

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

Optimizes Statement::EnumConstruct that is followed by a match to jump to the target of the relevant match arm.

For example, given:

blk0:
Statements:
(v1: core::option::Option::<core::integer::u32>) <- Option::Some(v0)
End:
Goto(blk1, {v1-> v2})

blk1:
Statements:
End:
Match(match_enum(v2) {
  Option::Some(v3) => blk4,
  Option::None(v4) => blk5,
})

Change blk0 to jump directly to blk4.