Skip to content
This repository has been archived by the owner on Jun 26, 2020. It is now read-only.

fcvt_from_uint for 8bit and 16bit uints is incorrect #996

Closed
bjorn3 opened this issue Sep 7, 2019 · 3 comments · Fixed by #997
Closed

fcvt_from_uint for 8bit and 16bit uints is incorrect #996

bjorn3 opened this issue Sep 7, 2019 · 3 comments · Fixed by #997

Comments

@bjorn3
Copy link
Contributor

bjorn3 commented Sep 7, 2019

v0 = iconst.i8 0xff
v1 = fcvt_from_uint.f32 v0

Gives 254.0 instead of 255.0.

@bjorn3
Copy link
Contributor Author

bjorn3 commented Sep 7, 2019

This breaks the saturating-float-casts test of the rustc test suite.

cc bjorn3/rustc_codegen_cranelift#381

@bjorn3
Copy link
Contributor Author

bjorn3 commented Sep 7, 2019

Minimal repro:

test compile
target x86_64

function u0:0() system_v {
ebb0:
    v0 = iconst.i8 255
    v1 = fcvt_from_uint.f32 v0

    v5 = f32const 0x1.fe0000p7
    v7 = fcmp ne v1, v5
    brnz v7, ebb1
    return

ebb1:
    trap user65535
}

@bjorn3
Copy link
Contributor Author

bjorn3 commented Sep 7, 2019

It seems the generic legalization with uextend of input operand doesn't get triggered, but it immediately uses the x86 legalization, which doesn't uextend first.

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 a pull request may close this issue.

1 participant