SIMD optimization x64/x86: Optimize floating point min/max with constant
Categories
(Core :: JavaScript: WebAssembly, enhancement, P3)
Tracking
()
People
(Reporter: lth, Unassigned)
References
(Blocks 1 open bug)
Details
(Moved from bug 1673391. Looks like bug 1139501 was a previous incarnation of this, and there are additional ideas there.)
Floating point min/max on intel is a real horror show because the native instructions are very quirky. But I believe we can do better when one operand is a constant, and we should:
For fNxM.{min,max}(constant, var) and fNxM.{min,max}(var, constant) where constant is not NaN and not -0, we can use {MIN,MAX}{PS,PD} with the constant loaded into lhsDest and var loaded into rhs, and this will return the var if it is NaN, or -0 if it is -0 and the constant is +0, and compute the right answer in all other cases too. The only remaining complication (I think) is that an SNaN input must be converted to QNaN, and this will require some fixup code, with a test+branch on the hot path just as we have now, though likely simpler.
This is especially nice for constants like 0 and -1 that are cheap to generate, but even for constants loaded from memory this will be better than the current code.
Description
•