[wasm] Fix expected function to match interpreter's function

b % 32 could produce negative results. Therefore, the result
of the shift could be undefined values.

Bug: 
Change-Id: I6c2f7201df424735695aa01891d46523e3c5bd12
Reviewed-on: https://chromium-review.googlesource.com/759079
Commit-Queue: Junliang Yan <jyan@ca.ibm.com>
Reviewed-by: Clemens Hammacher <clemensh@chromium.org>
Cr-Commit-Position: refs/heads/master@{#49240}
This commit is contained in:
Junliang Yan 2017-11-08 14:37:28 -05:00 committed by Commit Bot
parent 24b26a0cfc
commit a4d966121c

View File

@ -203,11 +203,11 @@ WASM_I32_BINOP_TEST(RemU, uint32_t, b == 0 ? 0xdeadbeef : a % b)
WASM_I32_BINOP_TEST(And, int32_t, a& b)
WASM_I32_BINOP_TEST(Ior, int32_t, a | b)
WASM_I32_BINOP_TEST(Xor, int32_t, a ^ b)
WASM_I32_BINOP_TEST(Shl, int32_t, a << (b % 32))
WASM_I32_BINOP_TEST(ShrU, uint32_t, a >> (b % 32))
WASM_I32_BINOP_TEST(ShrS, int32_t, a >> (b % 32))
WASM_I32_BINOP_TEST(Ror, uint32_t, (a >> (b % 32)) | (a << (32 - (b % 32))))
WASM_I32_BINOP_TEST(Rol, uint32_t, (a << (b % 32)) | (a >> (32 - (b % 32))))
WASM_I32_BINOP_TEST(Shl, int32_t, a << (b & 0x1f))
WASM_I32_BINOP_TEST(ShrU, uint32_t, a >> (b & 0x1f))
WASM_I32_BINOP_TEST(ShrS, int32_t, a >> (b & 0x1f))
WASM_I32_BINOP_TEST(Ror, uint32_t, (a >> (b & 0x1f)) | (a << (32 - (b & 0x1f))))
WASM_I32_BINOP_TEST(Rol, uint32_t, (a << (b & 0x1f)) | (a >> (32 - (b & 0x1f))))
WASM_I32_BINOP_TEST(Eq, int32_t, a == b)
WASM_I32_BINOP_TEST(Ne, int32_t, a != b)
WASM_I32_BINOP_TEST(LtS, int32_t, a < b)