essential-contributions / pint

Pint, the constraint-based programming language for declarative blockchains
Apache License 2.0
17 stars 3 forks source link

Remove dead constraints #834

Closed mohammadfawaz closed 1 month ago

mohammadfawaz commented 1 month ago

For example, remove constraints like this:

constraint true;
constraint !false;
constraint 1 == 1;
constraint x == x;

and so on...

We can start with some simple stuff and evolve the pass to support more complex structures in the future.

mohammadfawaz commented 1 month ago

The function evaluate should be quite useful here.

otrho commented 1 month ago

I think the E2E tests should have another phase which includes these type of transforms separately.

Where 'flattened' is anything which is desugared but still pretty much resembles the parsed tree. The 'optimised' stage will have items removed or combined and is the final output.

mohammadfawaz commented 1 month ago

Yes that makes sense. I had a chat with @lethalgem yesterday about the differences between "flattening" (we may need a better name for this now) and "optimization" and how one is required while the other is not. We should certainly split the two into separate phases where flattening happens first and produces valid code that asm gen can understand, while the optimizers runs after (and is optional in principle). Things like dead code elimination and const folding should go into the optimizer.