eirproject / eir

Erlang ecosystem common IR
Apache License 2.0
250 stars 8 forks source link

Deduplicate value vars when compiling pattern matching construct #3

Closed hansihe closed 5 years ago

hansihe commented 5 years ago

Since we don't do a check for duplicate value vars (value vars are currently only used when looking up map keys in a pattern), we can end up with a decision tree with some extra branches.

When constant propagation has propagated two statically known values to a pattern matching construct as value vars, we should check for and remove duplicates when expanding the map pattern node.

Selection_006

hansihe commented 5 years ago

Pattern provider: https://github.com/eirproject/eir/blob/master/compiler/src/ir/lir/pass/compile_pattern/erlang_pattern_provider.rs#L134-L175

Decision tree lowering: https://github.com/eirproject/eir/blob/master/compiler/src/ir/lir/pass/compile_pattern/mod.rs#L177-L214

hansihe commented 5 years ago

With the new constant interning infrastructure in https://github.com/eirproject/eir/pull/15, this is fairly trivial.