Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Backport from qemu : fix do_nonatomic_op_* vs signed operations #1922

Merged
merged 1 commit into from
Jan 25, 2024

Conversation

redoste
Copy link
Contributor

@redoste redoste commented Jan 24, 2024

This fix makes non-atomic versions of min/max operations aware of sign extension.

The following piece of RISC-V assembly was producing bogus results:

	la a0, .d
	li a2, 1

	amomin.w a5, a2, (a0)
	lw a6, 0(a0)
.d:
	.word -1

The expected result in a6 is -1 but without the fix the result is 1

tcg: Fix do_nonatomic_op_* vs signed operations

The smin/smax/umin/umax operations require the operands to be
properly sign extended.  Do not drop the MO_SIGN bit from the
load, and additionally extend the val input.
@wtdcode
Copy link
Member

wtdcode commented Jan 25, 2024

Looks okay, simply wait for CI.

@wtdcode wtdcode merged commit 5e901ba into unicorn-engine:dev Jan 25, 2024
29 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.

2 participants