Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(859)

Unified Diff: test/cctest/wasm/test-run-wasm.cc

Issue 2453343002: [asmjs] Do constant folding for I32Asmjs(Div|Rem)S to avoid checks of constant divisors (Closed)
Patch Set: Add tests Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/wasm/wasm-macro-gen.h ('k') | test/cctest/wasm/wasm-run-utils.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/cctest/wasm/test-run-wasm.cc
diff --git a/test/cctest/wasm/test-run-wasm.cc b/test/cctest/wasm/test-run-wasm.cc
index a87656f408d8ba980810870dd29afa5286fb5f27..3b491d8bf821d9cacadf5e90f9989681dbd9abf1 100644
--- a/test/cctest/wasm/test-run-wasm.cc
+++ b/test/cctest/wasm/test-run-wasm.cc
@@ -448,6 +448,42 @@ WASM_EXEC_TEST(Int32DivS_byzero_const) {
}
}
+WASM_EXEC_TEST(Int32AsmjsDivS_byzero_const) {
+ for (int8_t denom = -2; denom < 8; ++denom) {
+ TestingModule module(execution_mode);
+ module.ChangeOriginToAsmjs();
+ WasmRunner<int32_t> r(&module, MachineType::Int32());
+ BUILD(r, WASM_I32_ASMJS_DIVS(WASM_GET_LOCAL(0), WASM_I8(denom)));
+ FOR_INT32_INPUTS(i) {
+ if (denom == 0) {
+ CHECK_EQ(0, r.Call(*i));
+ } else if (denom == -1 && *i == std::numeric_limits<int32_t>::min()) {
+ CHECK_EQ(std::numeric_limits<int32_t>::min(), r.Call(*i));
+ } else {
+ CHECK_EQ(*i / denom, r.Call(*i));
+ }
+ }
+ }
+}
+
+WASM_EXEC_TEST(Int32AsmjsRemS_byzero_const) {
+ for (int8_t denom = -2; denom < 8; ++denom) {
+ TestingModule module(execution_mode);
+ module.ChangeOriginToAsmjs();
+ WasmRunner<int32_t> r(&module, MachineType::Int32());
+ BUILD(r, WASM_I32_ASMJS_REMS(WASM_GET_LOCAL(0), WASM_I8(denom)));
+ FOR_INT32_INPUTS(i) {
+ if (denom == 0) {
+ CHECK_EQ(0, r.Call(*i));
+ } else if (denom == -1 && *i == std::numeric_limits<int32_t>::min()) {
+ CHECK_EQ(0, r.Call(*i));
+ } else {
+ CHECK_EQ(*i % denom, r.Call(*i));
+ }
+ }
+ }
+}
+
WASM_EXEC_TEST(Int32DivU_byzero_const) {
for (uint32_t denom = 0xfffffffe; denom < 8; ++denom) {
WasmRunner<uint32_t> r(execution_mode, MachineType::Uint32());
« no previous file with comments | « src/wasm/wasm-macro-gen.h ('k') | test/cctest/wasm/wasm-run-utils.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698