Skip to content

Commit

Permalink
[ treeless ] erase unused let bindings
Browse files Browse the repository at this point in the history
  • Loading branch information
UlfNorell committed Oct 29, 2015
1 parent 03eb394 commit a904648
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/full/Agda/Compiler/Treeless/Erase.hs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import Agda.TypeChecking.Datatypes
import Agda.TypeChecking.Pretty

import Agda.Compiler.Treeless.Subst
import Agda.Compiler.Treeless.Pretty

import Agda.Utils.Maybe
import Agda.Utils.Impossible
Expand Down Expand Up @@ -74,7 +75,14 @@ eraseTerms = runE . erase
TCon{} -> pure t
TApp f es -> TApp <$> erase f <*> mapM erase es
TLam b -> TLam <$> erase b
TLet e b -> TLet <$> erase e <*> erase b
TLet e b -> do
b <- erase b
if freeIn 0 b then TLet <$> erase e <*> pure b
else do
lift $ reportSDoc "treeless.opt.erase.let" 50 $
vcat [ text "erasing:" <+> pretty (TLet e b)
, text "free vars:" <+> text (show $ freeVars b) ]
pure $ applySubst (compactS __IMPOSSIBLE__ [Nothing]) b
TCase x t d bs -> TCase x t <$> erase d <*> mapM eraseAlt bs

TUnit -> pure t
Expand Down

0 comments on commit a904648

Please sign in to comment.