Skip to content

Commit 4f150c1

Browse files
Fix a bug in the shr_s instruction implementation
1 parent 25f599e commit 4f150c1

File tree

3 files changed

+10
-2
lines changed

3 files changed

+10
-2
lines changed
124 Bytes
Binary file not shown.

Sources/WasmKit/Execution/Value.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -130,8 +130,8 @@ extension RawUnsignedInteger {
130130
return self << shift
131131
}
132132
func shrS(_ other: Self) -> Self {
133-
let shift = other.signed % Self.Signed(Self.bitWidth)
134-
return (self.signed >> shift.unsigned).unsigned
133+
let shift = other % Self(Self.bitWidth)
134+
return (self.signed >> shift).unsigned
135135
}
136136
func shrU(_ other: Self) -> Self {
137137
let shift = other % Self(Self.bitWidth)
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
(module
2+
(func (export "i64.shr_s") (param i64) (param i64) (result i64)
3+
(i64.shr_s (local.get 0) (local.get 1))
4+
)
5+
)
6+
7+
(assert_return (invoke "i64.shr_s" (i64.const -1309934030728401938) (i64.const -1309934030728401938)) (i64.const -18616))
8+

0 commit comments

Comments
 (0)