wasm non-trapping float-to-int conversions - #5014
Conversation
|
Note: Tested locally, but there are no tests attached to the PR yet. I will push tests to the PR later once I figure out how to port the spec tests. |
|
For the tests, I think you can look at what I did for Sign extension. |
| IR::Opnd* | ||
| LowererMD::GenerateTruncChecks(_In_ IR::Instr* instr, _In_opt_ IR::LabelInstr* doneLabel) | ||
| { | ||
| AnalysisAssert(!Saturate || doneLabel); |
There was a problem hiding this comment.
I feel we should assert here that dst is int32 or uint32 #Closed
| LoadFloatZero(zeroReg, instr); | ||
|
|
||
| m_lowerer->InsertCompareBranch(src64, zeroReg, Js::OpCode::BrGt_A, tooBigLabel, instr, true /*no NaN check*/); | ||
| instr->InsertBefore(IR::BranchInstr::New(Js::OpCode::JP, nanLabel, m_func)); |
There was a problem hiding this comment.
if dst is unsigned, we could just jump to nanLabel since both branch just set dst to 0 #Closed
| MACRO_EXTEND_WMS( Conv_Check_DTL , Long1Double1 , None ) | ||
| MACRO_EXTEND_WMS( Conv_Check_DTUL , Long1Double1 , None ) | ||
|
|
||
| MACRO_EXTEND_WMS( Conv_Sat_DTI , Int1Double1 , None ) |
There was a problem hiding this comment.
This will require an update of the ByteCode Guid (you'll see unit test failure in ChakraFull) #Closed
| <tags>exclude_dynapogo</tags> | ||
| </default> | ||
| </test> | ||
| <test> |
There was a problem hiding this comment.
In order to get this and not lose it next time I update the spec repo.
You have to add an entry in test\WasmSpec\convert-test-suite\config.json "folders": [ ... "features/nontrapping" ]
Then you need to run node convert-test-suite to generate rlexe.xml #Closed
| instr->InsertBefore(oobLabel); | ||
| if (Saturate) | ||
| { | ||
| IR::LabelInstr * tooBigLabel = IR::LabelInstr::New(Js::OpCode::Label, m_func, true); |
There was a problem hiding this comment.
We can eliminate the additional cmp with zero by doing the following
xorps dst, dst ;; mov dst, 0
cmp minInt, src1
jae truncMinInt
jp done ;; src1 is NaN and we've initialized dst to 0, so we're done
cmp maxInt, src1
ja conversion ;; src1 is in the valid range do the conversion
mov dst, maxInt ;; we know we're greater then maxInt
jmp done
:truncMinInt
mov dst, minInt
jmp done
:conversion
...
:doneWe can either initialize dst to 0 and do jp done or do jp nan; ... :nan mov dst, 0; jmp done;.
Merge pull request #5014 from MikeHolman:nontrapping Implements the wasm proposal, as specified here: https://github.com/WebAssembly/nontrapping-float-to-int-conversions Closes #3228
Implements the wasm proposal, as specified here:
https://github.com/WebAssembly/nontrapping-float-to-int-conversions
Closes #3228