mirror of
https://github.com/shadps4-emu/shadPS4.git
synced 2026-04-26 16:25:58 +03:00
[PR #3200] [MERGED] Fix V_ADDC_U32 carry-out edge cases #3301
Labels
No labels
Bloodborne
bug
contributor wanted
documentation
enhancement
frontend
good first issue
help wanted
linux
pull-request
question
release
verification progress
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/shadPS4#3301
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/shadps4-emu/shadPS4/pull/3200
Author: @OFFTKP
Created: 7/6/2025
Status: ✅ Merged
Merged: 7/7/2025
Merged by: @georgemoralis
Base:
main← Head:cf📝 Commits (2)
0845fe2Fix V_ADDC_U32 carry-out edge casesf90ff77Use IAddCarry instead📊 Changes
1 file changed (+9 additions, -6 deletions)
View changed files
📝
src/shader_recompiler/frontend/translate/vector_alu.cpp(+9 -6)📄 Description
Carry calculations in unsigned numbers work like this:
It doesn't matter which of the two sources you check, because in unsigned addition when there's an overflow the result will be smaller than both sources, never just one.
In the case of add with carry, you need to check whether src1 + src2 overflows and whether (src1+src) + cf overflows separately.
The current implementation does
result < src1 || result < src2. This doesn't check separately for the intermediate result of src1+src2 and only checks if the final result overflowed. This fails in cases where the intermediate result overflows but the final result doesn't.Example where old implementation can fail:
src0 = 0xFFFF'FFFF
src1 = 0xFFFF'FFFF
carry_in = 1
result = 0xFFFF'FFFF + 0xFFFF'FFFF + 1 = 0xFFFF'FFFF
This previous implementation would check
result < src0 (false)||result < src1 (false)and carry_out would be false🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.