Repository navigation
Code generation fixes found by differential testing - #383
Merged
davidgiven merged 3 commits intoOct 31, 2026
Merged
Conversation
maarten-boot
commented
Oct 31, 2026
Contributor
~ of an unsigned constant was masked to the type's size, unary - was not, so the folded value kept the bits above it (the compiler's arithmetic is 64-bit): -(unsigned long)1371337135 / 193754694 folded to 717414569 instead of 15. Mask the result of both. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- peephole.c, repl_mul (-ml): the multiplier is held in a 64-bit unsigned long, so "ldc -1 mlu 4" had 64 one bits and became a shift by 64: x * 0xFFFFFFFFUL was 0 on linux68k. Mask it to the operand size. - patterns: loc loc adu/sbu/mlu/sli/slu and ldc loc sli/slu folded to a constant that does not fit the word; later folds (a shift right, a division) then used the bits above it. Fold only when the result fits. - patterns: loc loc loc cii with a source smaller than the word folded to the constant without sign-extending it ((int8_t)16384 stayed 16384), and the word to double-word cii/ciu folds took constants in unsigned form (loc 45219) as positive. Fold only when the constant fits the source. The fold bugs show at -O3, when ego propagates constants into these sequences. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- from memory1 (clr, then move.b into the register): move.b sets the condition codes for the byte, but they were taken for the register, so a following signed test used the byte's sign: (uint8_t)l / 16 with l = -300 gave 14 instead of 13. killcc after the move. - txxand, txxand_ouch, cmxtxxand (tXX and, cmX tXX and): x & (a op b) was done as "clear bit 0 of x if false", which is only right when x is 0 or 1: (x >> s) & (a < b) with x = -8017 gave -8017. Now and #1 first and clr if false. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
maarten-boot
added a commit
to maarten-boot/ack
that referenced
this pull request
Oct 31, 2026
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Owner
|
Merging; thanks. |
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.