mlton icon indicating copy to clipboard operation
mlton copied to clipboard

Improve elimination for locally known cases

Open jasoncarr0 opened this issue 4 years ago • 0 comments

From examination of the IR in many, there are frequent cases where the inputs to a simple testing block are known, and the test could be skipped. Known case will handle some cases, but only when the block has no statements, and it has no support for numbers.

So we want some of the following:

  • Handle known numbers, and associated primitives, e.g. arithmetic and overflow
  • Allow the inclusion of statements which will be sufficiently simple once reduced for this case.

I think it would suffice to do the following: perform abstract interpretation for partial constants (finite sets of constructors, numbers), at each Goto or Case, passing through each statement, simplifying them for this case, until blocked or hitting an unknown case, then replacing the jump with the longest prefix of trivial (constants, constructors, moves, arithmetic, etc) statements which were passed over.

Termination checking (https://github.com/MLton/mlton/issues/331) would benefit such a change

jasoncarr0 avatar Aug 15 '19 16:08 jasoncarr0