Switch signed/unsigned instructions when upcasting 32- to 64-bit integers, fixes #247

Matches C semantics now. Turns around some instructions in tests, especially libm, but doesn't break anything.
This commit is contained in:
dcodeIO
2018-09-10 14:25:33 +02:00
parent 9603c13fb7
commit 6949cf9f9e
17 changed files with 231 additions and 96 deletions

View File

@ -2641,7 +2641,7 @@ export class Compiler extends DiagnosticEmitter {
// i32 or smaller to i64
} else if (toType.is(TypeFlags.LONG)) {
expr = module.createUnary(
toType.is(TypeFlags.SIGNED) ? UnaryOp.ExtendI32 : UnaryOp.ExtendU32,
fromType.is(TypeFlags.SIGNED) ? UnaryOp.ExtendI32 : UnaryOp.ExtendU32,
this.ensureSmallIntegerWrap(expr, fromType) // must clear garbage bits
);
wrapMode = WrapMode.NONE;