SIMD optimization x64/x86: Better code for float->int conversion
Categories
(Core :: JavaScript: WebAssembly, enhancement, P3)
Tracking
()
Tracking | Status | |
---|---|---|
firefox102 | --- | fixed |
People
(Reporter: lth, Assigned: yury)
References
(Blocks 1 open bug)
Details
Attachments
(2 files)
We have fairly elaborate code for int->float conversion, see eg MacroAssemblerX86Shared::truncSatFloat32x4Toint32x2 or the even worse unsigned variant right below it. We can do better: https://github.com/WebAssembly/simd/issues/173, in the third comment, "option 2" is appealing. It's also possible v8 has updated its code since I let myself be inspired by it for these functions, and we should let it inspire us again.
(Also: https://github.com/WebAssembly/simd/issues/190, though it mostly points to #173.)
Assignee | ||
Comment 1•4 years ago
|
||
Looked into "option 2" (vmaxps dst, src, [rip + OFFSET_THAT_CONTAINS_INT_MAX_AS_FLOAT]
looks incorrect):
- even with
vminps
... - there is no exact representation for INT_MAX as float: 2147483520.f as INT_MAX produces 0x7FFFFF80, and 2147483647.f gives 0x80000000f
Reporter | ||
Comment 2•4 years ago
|
||
Surely there is a canonical representation for INT_MAX as float on the architecture even if it is not exact? Indeed our own unsignedTruncSatFloat32x4ToInt32x4 uses such a representation.
Happy to delay this until we have time to concentrate on those details.
Assignee | ||
Comment 3•3 years ago
|
||
For non-AVX, the approach saves one instruction.
For AVX, the savings are 3 instructions.
Updated•3 years ago
|
Assignee | ||
Updated•3 years ago
|
Assignee | ||
Comment 4•3 years ago
|
||
Fix alu vs fpu xor, reword comment.
Depends on D144463
Comment 6•3 years ago
|
||
bugherder |
https://hg.mozilla.org/mozilla-central/rev/8bd424227b76
https://hg.mozilla.org/mozilla-central/rev/4ee04d98cd3d
Description
•