Skip to content

Commit 2ae066f

Browse files
authored
fix: only mark a cases discriminant used if it has non-default alt (#8681)
This PR adds an optimization to the LCNF simp pass where the discriminant of a `cases` construct will only be mark used if it has a non-default alternative.
1 parent c9c794e commit 2ae066f

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/Lean/Compiler/LCNF/Simp/Main.lean

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -314,7 +314,6 @@ partial def simp (code : Code) : SimpM Code := withIncRecDepth do
314314
else
315315
withNormFVarResult (← normFVar c.discr) fun discr => do
316316
let resultType ← normExpr c.resultType
317-
markUsedFVar discr
318317
let alts ← c.alts.mapMonoM fun alt => do
319318
match alt with
320319
| .alt ctorName ps k =>
@@ -331,5 +330,6 @@ partial def simp (code : Code) : SimpM Code := withIncRecDepth do
331330
if alts.size == 1 && alts[0]! matches .default .. then
332331
return alts[0]!.getCode
333332
else
333+
markUsedFVar discr
334334
return code.updateCases! resultType discr alts
335335
end

0 commit comments

Comments
 (0)