Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Interpreter: Implement floating point conversions #4884

Merged
merged 3 commits into from
Sep 20, 2022

Conversation

dheaton-arm
Copy link
Contributor

Implemented the following opcodes for the interpreter:

  • FcvtToUint
  • FcvtToSint
  • FcvtToUintSat
  • FcvtToSintSat
  • FcvtFromUint
  • FcvtFromSint
  • FcvtLowFromSint
  • FvpromoteLow
  • Fvdemote

Copyright (c) 2022 Arm Limited

@github-actions github-actions bot added the cranelift Issues related to the Cranelift code generator label Sep 8, 2022
Copy link
Contributor

@afonso360 afonso360 left a comment

Choose a reason for hiding this comment

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

Thanks for working on this! Some small nits below.

I ran this through the fuzzer and it picked up some issues:

`fcvt_to_uint.i128` traps with `IntegerOverflow`
test interpret

function %a_128(f32) -> i128 {
block0(v0: f32):
    v1 = fcvt_to_uint.i128 v0
    return v1
}
; run: %a_128(0.0) == 0

The equivalent test for i32 returns 0, so this should too right?

I'm going to let this run for a little bit, but I'll report back if I find anything.


As an aside fcvt_low_from_sint allows for scalar values, but I think that is probably a mistake, since the docs explicitly state: "The result type will have half the number of vector lanes as the input."

Which doesn't make a lot of sense for scalar values. But that's probably something for a different PR.

cranelift/filetests/filetests/runtests/conversion.clif Outdated Show resolved Hide resolved
cranelift/interpreter/src/step.rs Outdated Show resolved Hide resolved
cranelift/interpreter/src/step.rs Outdated Show resolved Hide resolved
cranelift/interpreter/src/step.rs Outdated Show resolved Hide resolved
cranelift/interpreter/src/step.rs Outdated Show resolved Hide resolved
Implemented the following opcodes for the interpreter:
- `FcvtToUint`
- `FcvtToSint`
- `FcvtToUintSat`
- `FcvtToSintSat`
- `FcvtFromUint`
- `FcvtFromSint`
- `FcvtLowFromSint`
- `FvpromoteLow`
- `Fvdemote`

Copyright (c) 2022 Arm Limited
Copyright (c) 2022 Arm Limited
Copy link
Contributor

@jameysharp jameysharp left a comment

Choose a reason for hiding this comment

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

Thank you for implementing these, @dheaton-arm! And @afonso360, thanks for fuzzing and reviewing!

@jameysharp jameysharp merged commit cae7c19 into bytecodealliance:main Sep 20, 2022
afonso360 pushed a commit to afonso360/wasmtime that referenced this pull request Sep 21, 2022
)

* Interpreter: Implement floating point conversions

Implemented the following opcodes for the interpreter:
- `FcvtToUint`
- `FcvtToSint`
- `FcvtToUintSat`
- `FcvtToSintSat`
- `FcvtFromUint`
- `FcvtFromSint`
- `FcvtLowFromSint`
- `FvpromoteLow`
- `Fvdemote`

Copyright (c) 2022 Arm Limited

* Fix `I128` bounds checks for `FcvtTo{U,S}int{_,Sat}`

Copyright (c) 2022 Arm Limited

* Fix broken test

Copyright (c) 2022 Arm Limited
@dheaton-arm dheaton-arm deleted the interpret-fcvt branch September 21, 2022 10:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cranelift Issues related to the Cranelift code generator
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants