Skip to content

perf(reduction): drop a dead let binding without reducing its value - #1216

Merged
strub merged 1 commit into
mainfrom
fix/dead-let-reduction
Oct 26, 2026
Merged

strub merged 1 commit into
mainfrom
fix/dead-let-reduction

Conversation

@strub

@strub strub commented Oct 26, 2026 •

Copy link
Copy Markdown
Member

First of a stack of three performance fixes found while checking safety proofs of Jasmin AVX2 implementations (ML-KEM, ML-DSA), where the goals produced by wp on unrolled vector code hold thousands of let bindings.

A let binding none of whose variables occurs in the body is dropped without its value being reduced. The let-tuple iota rule required the value to be a syntactic tuple and otherwise reduced it, even when the binding was dead (the flags of an x86 instruction bound by wp); the zeta and let-record rules substituted or reduced as well. The three head rules now return the body at once when the binding is dead; the sub-term reduction of a let is unchanged (value first, then body).

tests/reduction-dead-let.ec exercises the rules in simplify; it fails on main at its first lemma.

Stack: this PR, then #1217 (cbv), then #1218 (read/write sets).

@strub
strub force-pushed the fix/dead-let-reduction branch 2 times, most recently from 501e4ee to 022840b Compare October 26, 2026 08:21
@strub strub added the stacked Intermediate PR of a stack: CI skipped unless it targets main label Oct 26, 2026
@strub strub changed the title perf: drop dead let bindings in reduction and cbv, walk the call graph once in the read/write sets perf(reduction): drop a dead let binding without reducing its value Oct 26, 2026
@strub
strub added this pull request to stack #1219 October 26, 2026 08:29
@strub
strub force-pushed the fix/dead-let-reduction branch from 022840b to f89c677 Compare October 26, 2026 12:02
Comment thread src/ecReduction.ml Resolved
The iota rule for a let-tuple required the bound value to be a syntactic
tuple and otherwise asked for the reduction of the value, even when none
of the bound variables occurs in the body; a dead let introduced by wp
for a tuple assignment (the flags of an x86 instruction) was then fully
evaluated before being thrown away. The zeta, let-tuple and let-record
rules now return the body at once when the binding is dead.
@strub
strub force-pushed the fix/dead-let-reduction branch from f89c677 to 66394a1 Compare October 26, 2026 14:25

@bgregoir bgregoir left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank for the changes

@strub strub removed the stacked Intermediate PR of a stack: CI skipped unless it targets main label Oct 26, 2026
@strub
strub enabled stacked auto-merge October 26, 2026 14:38
@strub
strub added this pull request to the merge queue Oct 26, 2026
Merged via the queue into main with commit 655e26b Oct 26, 2026
37 checks passed
@strub
strub deleted the fix/dead-let-reduction branch October 26, 2026 16:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants