diff options
-rw-r--r-- | src/jsifier.js | 9 | ||||
-rw-r--r-- | tests/runner.py | 17 |
2 files changed, 19 insertions, 7 deletions
diff --git a/src/jsifier.js b/src/jsifier.js index 44f2ffe0..b1b8797b 100644 --- a/src/jsifier.js +++ b/src/jsifier.js @@ -874,8 +874,13 @@ function JSify(data, functionsOnly, givenFunctions, givenGlobalVariables) { case 'ugt': case 'sgt': return ident1 + ' > ' + ident2; case 'ult': case 'slt': return ident1 + ' < ' + ident2; // We use loose comparisons, which allows false == 0 to be true, etc. Ditto in fcmp - case 'ne': case 'une': return ident1 + ' != ' + ident2; - case 'eq': return ident1 + ' == ' + ident2; + case 'ne': case 'eq': { + // We must sign them, so we do not compare -1 to 255 (could have unsigned them both too) + // since LLVM tells us if <=, >= etc. comparisons are signed, but not == and !=. + ident1 = makeSignOp(ident1, type, 're'); + ident2 = makeSignOp(ident2, type, 're'); + return ident1 + (variant === 'eq' ? '==' : '!=') + ident2; + } default: throw 'Unknown icmp variant: ' + variant; } } diff --git a/tests/runner.py b/tests/runner.py index ebd4e8ba..662360a3 100644 --- a/tests/runner.py +++ b/tests/runner.py @@ -381,10 +381,15 @@ if 'benchmark' not in sys.argv: int y32 = hold+50; printf("*%u,%u*\\n", hold, y32); + // Comparisons + x8 = 0; + for (int i = 0; i < 254; i++) x8++; // make it an actual 254 in JS - not a -2 + printf("*%d,%d*\\n", x8+1 == 0xff, x8+1 != 0xff); // 0xff may be '-1' in the bitcode + return 0; } ''' - self.do_test(src, '*4294967295,0,4294967219*\n*-1,1,-1,1*\n*-2,1,-2,1*\n*246,296*') + self.do_test(src, '*4294967295,0,4294967219*\n*-1,1,-1,1*\n*-2,1,-2,1*\n*246,296*\n*1,0*') def test_bitfields(self): global SAFE_HEAP; SAFE_HEAP = 0 # bitfields do loads on invalid areas, by design @@ -1639,9 +1644,8 @@ if 'benchmark' not in sys.argv: force_c=True) def test_openjpeg(self): - if COMPILER == LLVM_GCC: return # Not sure why, but fails in gcc - generally correct, but noisy output - global SAFE_HEAP; SAFE_HEAP = 0 # Very slow + global CORRECT_SIGNS; CORRECT_SIGNS = 1 # Needed for some comparisons, at least in gcc original_j2k = path_from_root('tests', 'openjpeg', 'syntensity_lobby_s.j2k') @@ -1672,11 +1676,14 @@ if 'benchmark' not in sys.argv: # check our output by comparing the average pixel difference def image_compare(output): # Get the image generated by JS, from the JSON.stringify'd array - m = re.search('\[[\d, ]*\]', output) + m = re.search('\[[\d, -]*\]', output) try: js_data = eval(m.group(0)) except AttributeError: print 'Failed to find proper image output in: ' + output + raise + + js_data = map(lambda x: x if x >= 0 else 256+x, js_data) # Our output may be signed, so unsign it # Generate the native code output using lli lli_file = os.path.join(self.get_dir(), 'lli.raw') @@ -1697,7 +1704,7 @@ if 'benchmark' not in sys.argv: diff_mean = diff_total/float(num) image_mean = 83 - print '[image stats:', js_mean, image_mean, lli_mean, diff_mean, num, ']' + #print '[image stats:', js_mean, image_mean, lli_mean, diff_mean, num, ']' assert abs(js_mean - image_mean) < 2 assert abs(lli_mean - image_mean) < 2 assert diff_mean < 2 # XXX All of these are not quite right... |