Skip to content

Interpreter: Implement floating point conversions#4884

Merged
jameysharp merged 3 commits into
bytecodealliance:mainfrom
dheaton-arm:interpret-fcvt
Sep 20, 2022
Merged

Interpreter: Implement floating point conversions#4884
jameysharp merged 3 commits into
bytecodealliance:mainfrom
dheaton-arm:interpret-fcvt

Conversation

@dheaton-arm
Copy link
Copy Markdown
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
Copy Markdown
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.

Comment thread cranelift/filetests/filetests/runtests/conversion.clif Outdated
Comment thread cranelift/interpreter/src/step.rs Outdated
Comment thread cranelift/interpreter/src/step.rs Outdated
Comment thread cranelift/interpreter/src/step.rs Outdated
Comment thread cranelift/interpreter/src/step.rs Outdated
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
Copy Markdown
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.

3 participants