⚠ This page is served via a proxy. Original site: https://github.com
This service does not collect credentials or authentication data.
Skip to content

Fix overflowing add codegen, plus other fixes based on test output#32

Open
calc84maniac wants to merge 3 commits intoz80from
fix-overflowing-add-v17
Open

Fix overflowing add codegen, plus other fixes based on test output#32
calc84maniac wants to merge 3 commits intoz80from
fix-overflowing-add-v17

Conversation

@calc84maniac
Copy link

16-bit and 24-bit overflowing add now correctly generates ADC instead of ADD to obtain the overflow flag output. Additionally, the code generation for overflowing and extended add/sub has been updated to avoid performing the calculation twice when both the value and flag outputs are used.

In some cases, condition folding would generate fallback code even when the caller had its own fallback implementation, causing redundant instruction output. This has also been fixed by adding a parameter to indicate no fallback should be emitted when condition folding fails.

While looking at test output, I also identified and fixed the following issues:

  • Implementations of the G_EXTRACT and G_INSERT opcodes were emitting 16-bit memory operations in 24-bit mode, when it should have been using 24-bit operations or 8-bit pseudo operations. This has been fixed to use 24-bit operations on loads (which are from stack slots and safe to overrun by one byte), pseudo 8-bit operations on stores for inserted subregs, and 24-bit operations for stores of a full 16-bit register (increasing the stack slot size if needed). Though, in most cases, extract/insert for full 16-bit registers will use direct subregister operations rather than stack slots in the first place.
  • Fixed excessive code generation for G_MERGE_VALUES with s1 source operands, which was behavior introduced in v17. In many cases, the majority of the s1 source operands were constant or undef, intended for zero-ext or any-ext. So, to fix this issue, G_MERGE_VALUES has been optimized to account for constant or undef inputs, as well as minimize the total number of bits shifted.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant