fix for i64 mode 1 conversion of double to i64
This commit is contained in:
Родитель
17ee516bcd
Коммит
b61f32f98d
|
@ -576,7 +576,7 @@ function makeI64(low, high) {
|
||||||
|
|
||||||
// Splits a number (an integer in a double, possibly > 32 bits) into an I64_MODE 1 i64 value.
|
// Splits a number (an integer in a double, possibly > 32 bits) into an I64_MODE 1 i64 value.
|
||||||
// Will suffer from rounding. margeI64 does the opposite.
|
// Will suffer from rounding. margeI64 does the opposite.
|
||||||
// TODO: optimize I64 calcs
|
// TODO: optimize I64 calcs. For example, saving their parts as signed 32 as opposed to unsigned would help
|
||||||
function splitI64(value) {
|
function splitI64(value) {
|
||||||
assert(I64_MODE == 1);
|
assert(I64_MODE == 1);
|
||||||
return makeInlineCalculation(makeI64('VALUE>>>0', 'Math.floor(VALUE/4294967296)'), value, 'tempBigInt');
|
return makeInlineCalculation(makeI64('VALUE>>>0', 'Math.floor(VALUE/4294967296)'), value, 'tempBigInt');
|
||||||
|
@ -1590,7 +1590,7 @@ function processMathop(item) { with(item) {
|
||||||
return makeInlineCalculation('VALUE-VALUE%1', value, 'tempBigInt');
|
return makeInlineCalculation('VALUE-VALUE%1', value, 'tempBigInt');
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((type == 'i64' || paramTypes[0] == 'i64' || paramTypes[1] == 'i64') && I64_MODE == 1) {
|
if ((type == 'i64' || paramTypes[0] == 'i64' || paramTypes[1] == 'i64' || ident2 == '(i64)') && I64_MODE == 1) {
|
||||||
function warnI64_1() {
|
function warnI64_1() {
|
||||||
warnOnce('Arithmetic on 64-bit integers in mode 1 is rounded and flaky, like mode 0, but much slower!');
|
warnOnce('Arithmetic on 64-bit integers in mode 1 is rounded and flaky, like mode 0, but much slower!');
|
||||||
}
|
}
|
||||||
|
@ -1618,6 +1618,7 @@ function processMathop(item) { with(item) {
|
||||||
ident1 + '[1] >>> ' + ident2 + ']';
|
ident1 + '[1] >>> ' + ident2 + ']';
|
||||||
}
|
}
|
||||||
case 'uitofp': case 'sitofp': return ident1 + '[0] + ' + ident1 + '[1]*4294967296';
|
case 'uitofp': case 'sitofp': return ident1 + '[0] + ' + ident1 + '[1]*4294967296';
|
||||||
|
case 'fptoui': case 'fptosi': return splitI64(ident1);
|
||||||
case 'icmp': {
|
case 'icmp': {
|
||||||
switch (variant) {
|
switch (variant) {
|
||||||
case 'uge': case 'sge': return ident1 + '[1] >= ' + ident2 + '[1] && (' + ident1 + '[1] > ' + ident2 + '[1] || ' +
|
case 'uge': case 'sge': return ident1 + '[1] >= ' + ident2 + '[1] && (' + ident1 + '[1] > ' + ident2 + '[1] || ' +
|
||||||
|
|
|
@ -459,6 +459,14 @@ if 'benchmark' not in str(sys.argv):
|
||||||
// global structs with i64s
|
// global structs with i64s
|
||||||
printf("*%d,%Ld*\n*%d,%Ld*\n", iub[0].c, iub[0].d, iub[1].c, iub[1].d);
|
printf("*%d,%Ld*\n*%d,%Ld*\n", iub[0].c, iub[0].d, iub[1].c, iub[1].d);
|
||||||
|
|
||||||
|
// Math mixtures with doubles
|
||||||
|
{
|
||||||
|
uint64_t a = 5;
|
||||||
|
double b = 6.8;
|
||||||
|
uint64_t c = a * b;
|
||||||
|
printf("*prod:%llu*\n*%d,%d,%d*", c, (int)&a, (int)&b, (int)&c); // printing addresses prevents optimizations
|
||||||
|
}
|
||||||
|
|
||||||
// Basic (rounded, for now) math. Just check compilation.
|
// Basic (rounded, for now) math. Just check compilation.
|
||||||
int64_t a = 0x1234def123450789ULL;
|
int64_t a = 0x1234def123450789ULL;
|
||||||
a--; if (truthy()) a--; // confuse optimizer
|
a--; if (truthy()) a--; // confuse optimizer
|
||||||
|
@ -472,7 +480,8 @@ if 'benchmark' not in str(sys.argv):
|
||||||
self.do_run(src, '*1311918518731868200\n0,0,0,1,1\n1,0,1,0,1*\n*245127260211081*\n*245127260209443*\n' +
|
self.do_run(src, '*1311918518731868200\n0,0,0,1,1\n1,0,1,0,1*\n*245127260211081*\n*245127260209443*\n' +
|
||||||
'*18446744073709552000*\n*576460752303423500*\n' +
|
'*18446744073709552000*\n*576460752303423500*\n' +
|
||||||
'm1: 127\n*123*\n*127*\n' +
|
'm1: 127\n*123*\n*127*\n' +
|
||||||
'*55,17179869201*\n*122,25769803837*\n')
|
'*55,17179869201*\n*122,25769803837*\n' +
|
||||||
|
'*prod:34*\n')
|
||||||
|
|
||||||
Settings.CORRECT_SIGNS = 1
|
Settings.CORRECT_SIGNS = 1
|
||||||
|
|
||||||
|
|
Загрузка…
Ссылка в новой задаче