Open Bug 1693473 Opened 4 years ago Updated 4 years ago

SIMD optimization x64/x86: integer compare less than zero can use PSIGNB to avoid constant load

Categories

(Core :: JavaScript: WebAssembly, enhancement, P3)

x86_64
All
enhancement

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.

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?

(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.

You need to log in before you can comment on or make changes to this bug.