SIMD optimization x64/x86: integer compare less than zero can use PSIGNB to avoid constant load
Categories
(Core :: JavaScript: WebAssembly, enhancement, P3)
Tracking
()
People
(Reporter: lth, Unassigned)
References
(Blocks 1 open bug)
Details
We already generate good code for all integer compares with constant, but we can avoid loading the zero constant (which requires either a constant load or clearing a register) in at least this case:
y = x < 0 => PSIGNB/W/D y, x
Also see bug 1690462 for a similar optimization.
Comment 1•4 years ago
|
||
PSIGNB needs y argument specified: y = x != 0 ? (x < 0 ? -y : y) : 0
. Not sure we can avoid a clearing a register here.
Shall we try PSRAD y, 31
/PSRAW y, 15
for x < 0
instead?
Reporter | ||
Comment 2•4 years ago
|
||
(I assume you mean y < 0
.) I probably misread the manual.
The x < 0 case should generate the same code as we generate for sign replication I think (bug 1690462) since x < 0 is sign replication. Let's have the discussion over in that bug.
Indeed I suspect the "right" way to optimize x < 0 is to recognize it WasmIonCompile or lowering and lower it to sign replication, if we have a MIR/LIR representation for sign replication.
Description
•