Skip to content

A local given its own value stores nothing: n = n under -mm=own - #676

Merged
ASDAlexander77 merged 1 commit into
mainfrom
own-self-assign-noop
Oct 23, 2026
Merged

ASDAlexander77 merged 1 commit into
mainfrom
own-self-assign-noop

Conversation

@ASDAlexander77

Copy link
Copy Markdown
Owner

What

An assignment of a local's own value back into it (n = n, or n = (n = mk(5), n)) now emits no store. This applies in every memory model; under rc, the retain and release it skips cancelled each other out. An atomic or volatile local keeps its store.

Why

Under -mm=own, the store read the value out of the local first, which counted as moving it. The release of what the local held came after that move, so the program was refused: "'this value' is used here after its value was moved" (follow-up 13 from own-raytrace).

isSelfStore (MLIRGenImpl.h) matches only a plain ts.Load of the same ts.Variable slot, made in the current block with nothing but loads after it, so the slot still holds what was read.

Tests

  • 00self_assign covers n = n followed by a move, and the comma form. It is in the corpus (gc, rc, none) and runs under own; without the fix, own rejects it.
  • Full suite: Windows 5464/5464, Linux 5443/5443.

🤖 Generated with Claude Code

`n = n`, or `n = (n = mk(5), n)`, read the local and stored the value back.
Under own the read counted as moving the value out, so the release of what
the local held came after the move and the program was refused ("used here
after its value was moved"). MLIRGen now emits no store when the value is a
plain read of the same local made in the current block with only reads after
it. This holds in every model - under rc the retain and release it skips were
a pair - and an atomic or volatile local keeps its store.

Test 00self_assign in the corpus (gc, rc, none) and under own.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@ASDAlexander77
ASDAlexander77 merged commit ea5abd1 into main Oct 23, 2026
2 checks passed
@ASDAlexander77
ASDAlexander77 deleted the own-self-assign-noop branch October 23, 2026 20:26
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.

1 participant