rt: keep MULU.W/DIVU.W operands in data registers - #123
Merged
Merged
Conversation
ami_umul16() and ami_divu32_16_step() gave a u32 to MULU.W and DIVU.W with the constraint "dmi". Those instructions read 16 bits, so when GCC chose the memory alternative they read the high word of the u32 on this big-endian machine: 0 for every operand these routines pass. Under -mregparm=3 it did: ami_divu64_32_soft() multiplied by "mulu.w 36(sp),d1", and every divide with a divisor of 65536 or more came out wrong (udivsi3(0x10000,0x10001) = 1, the rt_test and Emulator failures). Both operands are now "d". 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.
ami_umul16()andami_divu32_16_step()used the"dmi"constraint on a u32 operand ofmulu.w/divu.w. Under-mregparm=3GCC spills it, and a memory operand makes the word op read the high half of the big-endian u32. Constraint is now"d".Scope:
-m68000builds only (AMINETXDUO_CPU=any, which both emulator arms boot).-m68020emits no word ops.Proof (vamos,
rt_test, toolchain 16.2.2):Static: main emits
mulu.w 36(sp),d1twice inami_divu64_32_soft; this branch emits 0 memory operands (reproduced by zz9k-fpga, NO BLOCKER).🤖 Generated with Claude Code