Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions codegen/masm/src/codegen/emit/int32.rs
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,9 @@ impl<'a> OpEmitter<'a> {
/// See `is_signed` for semantics and stack effects of the signedness check.
#[inline]
pub fn assert_unsigned_int32(&mut self) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've looked into this issue, and the fix is to remove the call to assert_unsigned_int32 from cast when casting from i32 to u32, from u32 to i32, and from i32 to u64; and replace it with a call to a new helper called assert_i32, see the implementation of assert_i64 in emit/int64.rs for how to implement it.

The problem is that the assert_unsigned_int32 helper is intended to assert that the sign bit of a 32-bit value is unset, not to assert that the value is non-negative, which is how we are using it in cast.

All the other uses of assert_unsigned_int32 are correct

Copy link
Contributor Author

@greenhat greenhat Jul 18, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have not found assert_i32 in #242 so I made #250

self.is_signed_int32();
self.emit(Op::Assertz);
// TODO: temporarily disabled until https://github.com/0xPolygonMiden/compiler/issues/174 is fixed
// self.is_signed_int32();
// self.emit(Op::Assertz);
}

/// Emits code to assert that a 32-bit value on the operand stack is equal to the given constant
Expand Down
Loading