Stream: cranelift

Topic: DataValue eq


view this post on Zulip T0b1 (Dec 08 2022 at 02:24):

Another one, sorry.
I don't quite understand why the eq implementation for DataValue (and by extension the bitwise_equal method) does not consider signed and unsigned types to ever be able to equal each other. Is there a reason for this?
I'm asking because I'm now getting test results such as
Failed test: run: %usubof_i64(0, 0) == 0, actual: 0
and in my case, where i do an unsigned operation on values, I'm confused whether I should check the data values are signed before I do my operation and then cast the result back to being signed after finishing or not since that seems to affect the test cases.
The IR does not seem to differentiate between signed and unsigned values so I'm unsure why the interpreter seems to be doing that.
Thanks for any help

A fast and secure runtime for WebAssembly. Contribute to bytecodealliance/wasmtime development by creating an account on GitHub.
A fast and secure runtime for WebAssembly. Contribute to bytecodealliance/wasmtime development by creating an account on GitHub.

view this post on Zulip Afonso Bordado (Dec 08 2022 at 11:14):

:wave: Hey,

why the eq implementation for DataValue (and by extension the bitwise_equal method) does not consider signed and unsigned types to ever be able to equal each other. Is there a reason for this?

That seems to be by accident, at least for the bitwise_eq. More recently I've been trying to ensure that we always return signed values from all interpreter operations, and only cast to unsigned on intermediate operations. However it is possible that some other operations do not follow this rule.

The IR does not seem to differentiate between signed and unsigned values so I'm unsure why the interpreter seems to be doing that.

Yeah, having the split between unsigned and signed in the interpreter is something that I'm not really happy with. I've been thinking about changing it so that It's closer to the IR representation of a value.

view this post on Zulip Jamey Sharp (Dec 08 2022 at 16:21):

This sounds like a "good first issue" to me; want to write up a quick issue and label it that way? I know at least one person is looking for more of these to work on in Cranelift.

view this post on Zulip Afonso Bordado (Dec 08 2022 at 16:34):

Sure! I'll open an issue for that

view this post on Zulip Afonso Bordado (Dec 08 2022 at 16:53):

Here it is: https://github.com/bytecodealliance/wasmtime/issues/5398

👋 Hey, Feature We should remove the unsigned variants of the DataValue structure. Benefit This brings this structure closer to CLIF's idea of a DataValue, which does not distinguish between sig...

view this post on Zulip bwmf (Jan 21 2023 at 21:37):

I'm looking at this issue, I'm wondering whether ToUnsigned and ToSigned should also be removed?


Last updated: Dec 23 2024 at 13:07 UTC