Repository navigation
CG.Copy_n: build the sub-byte extraction mask at the target's word size - #1307
Merged
Merged
Conversation
The mask for copying arrays of 1-, 2- or 4-bit elements was the constant
TInt.Int {16_00, 16_FF, ..}. Target.Int is nine bytes, so ".." also set
the byte above the word: the value was the signed -256, not the Word
16_FF..FF00. The C backend checks Word literals against the word's range
and stopped with "TIntLiteral:type=UINT64 i=-256" (m3tests p277).
Compute the mask as Target.Word.max - 16_FF, which is also right for
32-bit words.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
hosking
pushed a commit
that referenced
this pull request
Nov 23, 2026
Brings in #1302 (report an unhandled ex_stack exception), the RTStack and RTMachine consolidation (#1312-#1319), #1307 (Copy_n's sub-byte mask), #1309, #1323/#1324, #1331, #1332, #1334 and #1335. Conflicts, all in favour of master's versions: - RTException, RTExStack, RTExStackC.c: #1302 is the upstreamed form of msir's unhandled-exception report; master installs the terminate handler by an explicit call from RTExStack's body rather than a C++ static initializer. - runtime/common/m3makefile: RTStackCommon.c moved to separate Has_walker files (#1316). - m3tests: keep master's p309 alongside msir's p303 and p304. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
m3tests p277 ("mixtures of nested constructors") stops the C backend with
CG.Copy_ncopies open arrays of 1-, 2- or 4-bit elements, and its sub-byte path pushes a mask as aWordliteral:Target.Intis nine bytes, so..sets the byte above the word as well. The value is therefore the signed −256, not the word16_FF..FF00. M3C checks aWordliteral against the word's range and rejects it. Back ends that don't check that range accept it.This PR computes the mask as
Target.Word.max - 16_FF, which is also correct for 32-bit words. The constant came from the packedVars work (9343e3f, 2018).Testing (ARM64_DARWIN, C backend). Two
concierge.py upgradepasses, the second self-hosted, then m3tests:The remaining failures were already failing on master. r001, r003, r004 and r005 are fixed by #1302, and p269 by #1306.
🤖 Generated with Claude Code