aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlon Zakai <alonzakai@gmail.com>2013-04-25 13:59:25 -0700
committerAlon Zakai <alonzakai@gmail.com>2013-04-25 13:59:25 -0700
commit5db12d067ed104e26f77e31a02febb0e0b2d1667 (patch)
treefab6a1665e1b315f6dc69724afb4755e2df1b1c3
parentbf882bc76af2d005371f03e3f0911fff61cbf627 (diff)
fix llvm_uadd_with_overflow_i64 in the case of 0 higher bits
-rw-r--r--src/library.js6
-rwxr-xr-xtests/runner.py1
2 files changed, 5 insertions, 2 deletions
diff --git a/src/library.js b/src/library.js
index 957f69bd..9b63084f 100644
--- a/src/library.js
+++ b/src/library.js
@@ -7522,8 +7522,10 @@ LibraryManager.library = {
l = (a + c)>>>0;
h = (b + d)>>>0;
overflow = ((h>>>0) < (b>>>0))|0; // Return whether addition overflowed even the high word.
- h = (h + (((l>>>0) < (a>>>0))|0))>>>0; // Add carry from low word to high word on overflow.
- overflow = overflow | (!h); // Check again for overflow.
+ if ((l>>>0) < (a>>>0)) {
+ h = (h + 1)>>>0; // Add carry from low word to high word on overflow.
+ overflow = overflow | (!h); // Check again for overflow.
+ }
{{{ makeStructuralReturn(['l|0', 'h', 'overflow'], true) }}};
},
diff --git a/tests/runner.py b/tests/runner.py
index ba0c4aa0..4107d57e 100755
--- a/tests/runner.py
+++ b/tests/runner.py
@@ -1118,6 +1118,7 @@ m_divisor is 1091269979
{
a = argc;
b = argv[1][0];
+ printf("%d,%d\n", a, b);
if (a > a + b || a > a + b + 1) {
printf("one %lld, %lld", a, b);
return 0;