Skip to content

[RV64_DYNAREC] Fixed SBB16/SBB32 scratch register clobbering in flag calculation#3889

Merged
ptitSeb merged 1 commit into
ptitSeb:mainfrom
1362525207:fix-sbb-flags-clobber
May 24, 2026
Merged

[RV64_DYNAREC] Fixed SBB16/SBB32 scratch register clobbering in flag calculation#3889
ptitSeb merged 1 commit into
ptitSeb:mainfrom
1362525207:fix-sbb-flags-clobber

Conversation

@1362525207
Copy link
Copy Markdown
Contributor

Fixed SBB16/SBB32 SET_FLAGS_LTZ clobbering ~op1 in RV64 dynarec.

In emit_sbb16 and emit_sbb32, SET_FLAGS_LTZ used s5 as a scratch register, but s5 holds ~op1 which is needed later by CALC_SUB_FLAGS for borrow chain calculation. This caused CF and AF to be computed incorrectly.

Changed SET_FLAGS_LTZ scratch parameters from (s4, s5) to (s3, s4) to avoid clobbering ~op1.

Validation:

  • ctest: 34/34 passed on RV64 hardware.
  • Targeted SBB16/SBB32 test cases now produce correct CF and AF flags.

@ksco
Copy link
Copy Markdown
Collaborator

ksco commented May 24, 2026

LGTM, thanks. May I ask how did you find these?

@1362525207
Copy link
Copy Markdown
Contributor Author

LGTM, thanks. May I ask how did you find these?

I found these issues while running some benchmarks on an XThead-related chip.

@ptitSeb ptitSeb merged commit e7a0dc9 into ptitSeb:main May 24, 2026
28 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants