Skip to content

Commit

Permalink
Optimize representation of sequences in Useless pass
Browse files Browse the repository at this point in the history
The `Useless` optimization pass may determine that the contents of a
sequence (array or vector) is useless; similarly, it may determine that the
length of a sequence is useless; finally, it may determine that the identity of
an array is useless.

However, the transformation performed by the `Useless` optimization pass would,
at most, change a `t array` or `t vector` to `unit array` or `unit vector`.

This commit allows the `Useless` optimization pass to change sequences with
useless contents to simpler types.  In particular:

 * a `t array` with useless contents, useless length, and useless identity
   becomes a `unit`
 * a `t array` with useless contents, useless length, and useful identity
   becomes a `unit ref`
 * a `t array` with useless contents, useful length, and useless identity
   becomes a `word64` (or a `word32` on 32-bit platforms)
 * a `t array` with useless contents, useful length, and useful identity
   becomes a `word64 ref` (or a `word32 ref` on 32-bit platforms)
 * a `t vector` with useless contents and useless length
   becomes a `unit`
 * a `t vector` with useless contents and useful length
   becomes a `word64` (or a `word32` on 32-bit platforms)

Such optimizations do not happen frequently, but there are a few instances in a
self-compile.
  • Loading branch information
MatthewFluet committed May 22, 2024
1 parent 7475813 commit 1aad5fe
Showing 1 changed file with 419 additions and 174 deletions.
Loading

0 comments on commit 1aad5fe

Please sign in to comment.