Skip to content
This repository was archived by the owner on Nov 1, 2020. It is now read-only.

Wasm: fix unsigned extend to uint64 and add test#7891

Merged
jkotas merged 2 commits intodotnet:masterfrom
yowl:zext-uint64
Dec 12, 2019
Merged

Wasm: fix unsigned extend to uint64 and add test#7891
jkotas merged 2 commits intodotnet:masterfrom
yowl:zext-uint64

Conversation

@yowl
Copy link
Contributor

@yowl yowl commented Nov 27, 2019

This widening cast was failing, particular causing a problem in

public DiyFp Multiply(in DiyFp other)
{
// Simply "emulates" a 128-bit multiplication
//
// However: the resulting number only contains 64-bits. The least
// signficant 64-bits are only used for rounding the most significant
// 64-bits.
uint a = (uint)(f >> 32);
uint b = (uint)(f);
uint c = (uint)(other.f >> 32);
uint d = (uint)(other.f);
ulong ac = ((ulong)(a) * c);
ulong bc = ((ulong)(b) * c);
ulong ad = ((ulong)(a) * d);
ulong bd = ((ulong)(b) * d);
ulong tmp = (bd >> 32) + (uint)(ad) + (uint)(bc);
// By adding (1UL << 31) to tmp, we round the final result.
// Halfway cases will be rounded up.
tmp += (1U << 31);
return new DiyFp(ac + (ad >> 32) + (bc >> 32) + (tmp >> 32), e + other.e + SignificandSize);
.

Added a test that failed previously and zext instead of sext for unsigned widening. There is a parameter that I thought to use, but it is passed false here: https://github.com/dotnet/corert/blob/master/src/Common/src/TypeSystem/IL/ILImporter.cs#L574-L578. Maybe that is wrong?

Also I updated emscripten, this wasn't necessary to fix this, but I got sidetracked with a build error and upgraded. Its not a bad idea anyway as they changed the build tooling to allow for either the fastcomp or llvm backend and we will need to upgrade at some point. If you just git pull emscripten you will hit a problem with the current scripts due to these changes. Changed a bit of documentation to fit today's reality.

Copy link
Member

@jkotas jkotas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks

@jkotas jkotas merged commit d2f36cf into dotnet:master Dec 12, 2019
@yowl yowl deleted the zext-uint64 branch December 12, 2019 18:52
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants