Commit graph

405 commits

Author SHA1 Message Date
Leonardo de Moura
0684c95d35
fix: do not lift (<- ...) over pure if-then-else (#3820)
Now, only `(<- ...)`s occurring in the condition of a pure if-then-else
are lifted.
That is, `if (<- foo) then ... else ...` is ok, but `if ... then (<-
foo) else ...` is not. See #3713

closes #3713 

This PR also adjusts this repo. Note that some of the `(<- ...)` were
harmless since they were just accessing some
read-only state.
2024-04-01 21:33:59 +00:00
Mario Carneiro
49f66dc485
perf: rewrite UnusedVariables lint (#3186)
This is a rewrite of the `UnusedVariables` lint to inline and simplify
many of the dependent functions to try to improve the performance of
this lint, which quite often shows up in perf reports.

* The mvar assignment scanning is one of the most expensive parts of the
process, so we do two things to improve this:
  * Lazily perform the scan only if we need it
* Use an object-pointer hashmap to ensure that we don't have quadratic
behavior when there are many mvar assignments with slight differences.
* The dependency on `Lean.Server` is removed, meaning we don't need to
do the LSP conversion stuff anymore. The main logic of reference finding
is inlined.
* We take `fvarAliases` into account, and union together fvars which are
aliases of a base fvar. (It would be great if we had `UnionFind` here.)

More docs will be added once we confirm an actual perf improvement.

---------

Co-authored-by: Sebastian Ullrich <sebasti@nullri.ch>
2024-03-21 12:28:57 +00:00
Leonardo de Moura
855fbed024
fix: regression on match expressions with builtin literals (#3521) 2024-02-27 18:49:44 +00:00
Henrik Böving
23e49eb519 perf: add prelude to all Lean modules 2024-02-18 14:55:17 -08:00
Joachim Breitner
368ead54b2 refactor: termination_by changes in stdlib 2024-01-10 17:27:35 +01:00
Kyle Miller
a2226a43ac
feat: encode let_fun using a letFun function (#2973)
Switches from encoding `let_fun` using an annotated `(fun x : t => b) v`
expression to a function application `letFun v (fun x : t => b)`.

---------

Co-authored-by: Sebastian Ullrich <sebasti@nullri.ch>
2023-12-18 09:01:42 +00:00
Mauricio Collares
cfe5a5f188
chore: change simp default to decide := false (#2722) 2023-11-02 10:06:38 +11:00
int-y1
8d7520b36f chore: fix typos in comments 2023-10-08 10:46:05 +02:00
Leonardo de Moura
ebcab266c6 chore: remove empty line 2023-05-05 12:18:36 -07:00
Henrik Böving
0e042d8ef6 fix: LCNF simp forgot to mark normalized decls as simplified 2023-05-05 12:17:26 -07:00
Henrik Böving
36f0acfc51 feat: add timing profiling to the new compiler 2023-04-18 12:20:27 +02:00
Leonardo de Moura
0a031fc9bb chore: replace Expr.forEach with Expr.forEachWhere 2022-12-01 05:19:32 -08:00
Leonardo de Moura
7c5d91ebc3 fix: avoid hygienic ++ hygienic at Specialize.lean 2022-11-30 06:31:03 -08:00
Henrik Böving
5286c2b5aa feat: optimize mul/div into shift operations 2022-11-29 01:05:06 +01:00
Henrik Böving
6fe52cac41 doc: explain some decisions in ElimDeadBranches 2022-11-16 08:17:13 -08:00
Henrik Böving
66009a5cd3 feat: constant folding for decision procedures 2022-11-16 08:17:13 -08:00
Henrik Böving
5a397c8525 feat: ElimDeadBranches for LCNF 2022-11-16 08:17:13 -08:00
Leonardo de Moura
5654d8465d fix: fixes #1822 2022-11-13 18:13:29 -08:00
Leonardo de Moura
a87f0e25de feat: add compiler.checkTypes for sanity checking 2022-11-13 17:45:21 -08:00
Leonardo de Moura
854e655940 chore: document implementedBy := true use at phase 1 2022-11-13 15:47:13 -08:00
Leonardo de Moura
c147059fd7 fix: fixes #1812 2022-11-10 08:58:09 -08:00
Leonardo de Moura
9b02f982e2 chore: add ppCode' 2022-11-10 08:07:35 -08:00
Leonardo de Moura
b4d13a8946 refactor: LetExpr => LetValue
We use "let value" in many other places in the code base.
2022-11-07 18:51:07 -08:00
Leonardo de Moura
e8b4a8875c fix: type argument that is a fvar at FixedParams.lean 2022-11-07 18:18:07 -08:00
Leonardo de Moura
9399164201 fix: simpCasesOnCtor? 2022-11-07 18:18:06 -08:00
Leonardo de Moura
a5dadfdb7a feat: activate all passes 2022-11-07 16:18:36 -08:00
Leonardo de Moura
828a815821 fix: simpAppApp? 2022-11-07 16:18:36 -08:00
Leonardo de Moura
92faeec832 fix: add Simp.findFunDecl'?
It may look like a simple optimization but affects the inlining
heuristics. Example:
```
fun f ... := ...
let x_1 := f
let x_2 := x_1 a
let x_3 := x_1 b
...
```
Before this commit, `f` was not being marked as being used multiple times.
2022-11-07 16:18:36 -08:00
Leonardo de Moura
f342d0ea35 fix: avoid unnecessary whitespace at LCNF pretty printer 2022-11-07 16:18:36 -08:00
Leonardo de Moura
cf13b29760 fix: nasty bug due to #1804 2022-11-07 16:18:36 -08:00
Leonardo de Moura
c5584581ce fix: inferType for Code.jmp 2022-11-07 16:18:36 -08:00
Leonardo de Moura
0cfdf285e3 chore: remove unnecessary auxiliary declaration 2022-11-07 16:18:36 -08:00
Leonardo de Moura
46d83f2d80 fix: unnecessary paren at ppArg 2022-11-07 16:18:36 -08:00
Leonardo de Moura
3a818ed6ae fix: broken cache at toLCNF 2022-11-07 16:18:36 -08:00
Leonardo de Moura
390d4b28f2 chore: disable most LCNF passes to be able to use update-stage0
We cannot effectively test without an `update-stage0` since the LCNF
representation is different and incompatible with the one in the
.olean files.

One of the passes is not terminating (probably `simp`) when compiling
stage2.
2022-11-07 16:18:36 -08:00
Leonardo de Moura
623e8cddf6 fix: ReduceArity.lean 2022-11-07 16:18:36 -08:00
Leonardo de Moura
2e8150e50d chore: port Check.lean 2022-11-07 16:18:36 -08:00
Leonardo de Moura
ea8e7d5c99 chore: port ReduceArity.lean 2022-11-07 16:18:36 -08:00
Leonardo de Moura
a71c438838 chore: port ToMono.lean 2022-11-07 16:18:36 -08:00
Leonardo de Moura
9647f003c5 chore: port Specialize.lean 2022-11-07 16:18:36 -08:00
Leonardo de Moura
beb923c79f chore: anyFVar and allFVar 2022-11-07 16:18:36 -08:00
Leonardo de Moura
eaade5abde chore: port LambdaLifting.lean 2022-11-07 16:18:36 -08:00
Leonardo de Moura
0e85d9aa34 chore: re-activate Simp.lean 2022-11-07 16:18:36 -08:00
Leonardo de Moura
1e3c7d2b4e fix: Simp/Main.lean 2022-11-07 16:18:36 -08:00
Leonardo de Moura
db44a3a3f3 fix: JpCases.lean 2022-11-07 16:18:36 -08:00
Leonardo de Moura
2328cf2fb4 feat: add ppLetExpr 2022-11-07 16:18:36 -08:00
Leonardo de Moura
a19e8fc526 chore: port Simp/Main.lean 2022-11-07 16:18:36 -08:00
Henrik Böving
c5a99bda2b chore: port join point optimizations to LetExpr 2022-11-07 16:18:36 -08:00
Henrik Böving
695f972ff2 chore: migrate Compiler Probing to LetExpr 2022-11-07 16:18:36 -08:00
Henrik Böving
963cd8d175 chore: port FloatLetIn to LetExpr 2022-11-07 16:18:36 -08:00