[RV64_DYNAREC] Reduce instruction count for 64-bit addition carry flag - #4079
Merged
Conversation
ksco
requested changes
Jul 21, 2026
ksco
left a comment
Collaborator
There was a problem hiding this comment.
You can move SET_FLAGS_NEZ(s5, F_CF, s4); to the else block and use OR(xFlags, xFlags, s5); in the if block to save 1 more instuction.
Contributor
Author
Done. |
Collaborator
|
The code is pretty obvious, so I think it's better to just remove those comments. |
…lag calculation Because CF flag reside in bit 0 of risc-v xFlags (x23), so we also can remove BEQZ inst for if block.
ksco
approved these changes
Jul 21, 2026
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.
For the risc-v instruction
add rd, rs1, rs2, if an overflow occurs, only the lower XLEN bits of the sum are retained, and the resulting value will be numerically smaller than bothrs1andrs2.The combination of risc-v
addandsltuinstructions is commonly used to compute the carry flag of a 64-bit addition.