Page MenuHomePhabricator

[WebAssembly] Saturating float to int intrinsics
ClosedPublic

Authored by tlively on Oct 8 2018, 4:24 PM.

Details

Summary

Although the saturating float to int instructions are already
emitted from normal IR, the fpto{s,u}i instructions produce poison
values if the argument cannot fit in the result type. These intrinsics
are therefore necessary to get guaranteed defined saturating behavior.

Diff Detail

Event Timeline

tlively created this revision.Oct 8 2018, 4:24 PM
scanon added a subscriber: scanon.Oct 9 2018, 9:53 AM

Are these documented anywhere? I haven't seen it in any of the patches so far. What do they return for NaN inputs?

Do we need a new SDNode and a new lowering routine in ISelLowering for each of new intrinsics? Can't we use the intrinsics directly in *.td files like instructions?

lib/Target/WebAssembly/WebAssemblyInstrConv.td
100

We can not delete this :)

112

This too

tlively marked 2 inline comments as done.Oct 10 2018, 4:43 PM

Are these documented anywhere? I haven't seen it in any of the patches so far. What do they return for NaN inputs?

No, these new intrinsics aren't explicitly documented anywhere, but they do exactly match the semantics of the corresponding wasm instructions. NaN is converted to zero.

tlively updated this revision to Diff 169129.Oct 10 2018, 4:56 PM
  • Don't create new SDNodes
tlively updated this revision to Diff 169130.Oct 10 2018, 4:58 PM
  • Remove unused WebAssemblyISD elements
aheejin accepted this revision.Oct 10 2018, 5:00 PM

Great!

This revision is now accepted and ready to land.Oct 10 2018, 5:00 PM
This revision was automatically updated to reflect the committed changes.