From cce64a788b3548cda48de81ca65dd01056241b36 Mon Sep 17 00:00:00 2001 From: Bruce Mitchener Date: Wed, 22 Apr 2015 15:26:05 +0700 Subject: [PATCH] Remove PRECISE_I32_MUL option. This is set to true and asm.js always does precise math, so no need to be able to turn it off. --- src/preamble.js | 6 ------ src/settings.js | 6 ------ tests/core/test_i32_mul_semiprecise.in | 26 ------------------------- tests/core/test_i32_mul_semiprecise.out | 10 ---------- tests/fuzz/creduce_tester.py | 3 +-- tests/test_core.py | 10 ---------- 6 files changed, 1 insertion(+), 60 deletions(-) delete mode 100644 tests/core/test_i32_mul_semiprecise.in delete mode 100644 tests/core/test_i32_mul_semiprecise.out diff --git a/src/preamble.js b/src/preamble.js index 030f99cc5..d001acf6c 100644 --- a/src/preamble.js +++ b/src/preamble.js @@ -1360,7 +1360,6 @@ Module['writeAsciiToMemory'] = writeAsciiToMemory; {{{ unSign }}} {{{ reSign }}} -#if PRECISE_I32_MUL // check for imul support, and also for correctness ( https://bugs.webkit.org/show_bug.cgi?id=126345 ) if (!Math['imul'] || Math['imul'](0xffffffff, 5) !== -5) Math['imul'] = function imul(a, b) { var ah = a >>> 16; @@ -1369,11 +1368,6 @@ if (!Math['imul'] || Math['imul'](0xffffffff, 5) !== -5) Math['imul'] = function var bl = b & 0xffff; return (al*bl + ((ah*bl + al*bh) << 16))|0; }; -#else -Math['imul'] = function imul(a, b) { - return (a*b)|0; // fast but imprecise -}; -#endif Math.imul = Math['imul']; #if PRECISE_F32 diff --git a/src/settings.js b/src/settings.js index 495a1f6c8..c93856437 100644 --- a/src/settings.js +++ b/src/settings.js @@ -100,16 +100,10 @@ var WARN_UNALIGNED = 0; // Warn at compile time about instructions that LLVM tel // alignment. (this option is fastcomp-only) var PRECISE_I64_MATH = 1; // If enabled, i64 addition etc. is emulated - which is slow but precise. If disabled, // we use the 'double trick' which is fast but incurs rounding at high values. - // Note that we do not catch 32-bit multiplication by default (which must be done in - // 64 bits for high values for full precision) - you must manually set PRECISE_I32_MUL - // for that. // If set to 2, we always include the i64 math code, which is necessary in the case // that we can't know at compile time that 64-bit math is needed. For example, if you // print 64-bit values with printf, but never add them, we can't know at compile time // and you need to set this to 2. -var PRECISE_I32_MUL = 1; // If enabled, i32 multiplication is done with full precision, which means it is - // correct even if the value exceeds the JS double-integer limit of ~52 bits (otherwise, - // rounding will occur above that range). var PRECISE_F32 = 0; // 0: Use JS numbers for floating-point values. These are 64-bit and do not model C++ // floats exactly, which are 32-bit. // 1: Model C++ floats precisely, using Math.fround, polyfilling when necessary. This diff --git a/tests/core/test_i32_mul_semiprecise.in b/tests/core/test_i32_mul_semiprecise.in deleted file mode 100644 index a93a69da3..000000000 --- a/tests/core/test_i32_mul_semiprecise.in +++ /dev/null @@ -1,26 +0,0 @@ -#include - -typedef unsigned int uint; - -// from cube2, zlib licensed - -#define N (624) -#define M (397) -#define K (0x9908B0DFU) - -static uint state[N]; -static int next = N; - -void seedMT(uint seed) { - state[0] = seed; - for (uint i = 1; i < N; i++) // if we do not do this precisely, at least we - // should coerce to int immediately, not wait - state[i] = seed = 1812433253U * (seed ^ (seed >> 30)) + i; - next = 0; -} - -int main() { - seedMT(5497); - for (int i = 0; i < 10; i++) printf("%d: %u\n", i, state[i]); - return 0; -} diff --git a/tests/core/test_i32_mul_semiprecise.out b/tests/core/test_i32_mul_semiprecise.out deleted file mode 100644 index 261bf9a9f..000000000 --- a/tests/core/test_i32_mul_semiprecise.out +++ /dev/null @@ -1,10 +0,0 @@ -0: 5497 -1: 2916432318 -2: 2502517762 -3: 3151524867 -4: 2323729668 -5: 2053478917 -6: 2409490438 -7: 848473607 -8: 691103752 -9: 3915535113 diff --git a/tests/fuzz/creduce_tester.py b/tests/fuzz/creduce_tester.py index 6bf9473f4..7fd307791 100755 --- a/tests/fuzz/creduce_tester.py +++ b/tests/fuzz/creduce_tester.py @@ -14,8 +14,7 @@ import shared, jsrun # configuration options will have to be hardcoded. CSMITH_CFLAGS = ['-I', os.path.join(os.environ['CSMITH_PATH'], 'runtime')] ENGINE = shared.JS_ENGINES[0] -EMCC_ARGS = ['-O2', '-s', 'ASM_JS=1', '-s', 'PRECISE_I64_MATH=1', '-s', - 'PRECISE_I32_MUL=1'] +EMCC_ARGS = ['-O2', '-s', 'ASM_JS=1', '-s', 'PRECISE_I64_MATH=1'] filename = sys.argv[1] obj_filename = os.path.splitext(filename)[0] diff --git a/tests/test_core.py b/tests/test_core.py index d6064a487..e25f2b93c 100644 --- a/tests/test_core.py +++ b/tests/test_core.py @@ -425,16 +425,6 @@ class T(RunnerCore): # Short name, to make it more fun to use manually on the co self.do_run_from_file(src, output) - def test_i32_mul_semiprecise(self): - if Settings.ASM_JS: return self.skip('asm is always fully precise') - - Settings.PRECISE_I32_MUL = 0 # we want semiprecise here - - test_path = path_from_root('tests', 'core', 'test_i32_mul_semiprecise') - src, output = (test_path + s for s in ('.in', '.out')) - - self.do_run_from_file(src, output) - def test_i16_emcc_intrinsic(self): Settings.CORRECT_SIGNS = 1 # Relevant to this test