Closed Bug 1672343 Opened 4 years ago Closed 3 years ago

SIMD optimization: Unused shuffle operands still generate code

Categories

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

enhancement

Tracking

()

RESOLVED FIXED
94 Branch
Tracking Status
firefox94 --- fixed

People

(Reporter: lth, Assigned: yury)

References

(Blocks 1 open bug)

Details

Attachments

(2 files)

Sometimes an i8x16.shuffle can be lowered to a single instruction, for example, a shuffle with one of the operands being zero can sometimes be lowered to an instruction that ignores the zero. This is typical of operations that shift bytes left and right in the vector, shifting in zeroes - the zeroes are implicit in the instruction.

In this situation, our current code for rewriting shuffles still leaves the zero constant floating around in the LIR graph because it is being reached before the shuffle operation that doesn't need it. And code is then generated for that node. It's just a pxor r,r where the r is dead before and after so it's not the end of the world, but it's annoying and it creates extra register pressure right there. And because it's a SIMD value we don't necessarily want to flag it as emittedAtUses (though there's a discussion to be had about that).

(In general, I would expect the same problem to be the case for most of the lowerings that ignore one operand, though the bytecode most likely uses the same input for the two arguments and it won't matter.)

To do better, we probably have to lift the rewriting of shuffle out of the LIR level and into the MIR level; that way, the constant MIR node can be ignored earlier and will not generate LIR.

Summary: Unused shuffle operands still generate code → SIMD optimization: Unused shuffle operands still generate code
Assignee: nobody → ydelendik
Attachment #9239010 - Attachment description: WIP: Bug 1672343 - Move shuffle analysis to the MIR. → Bug 1672343 - Move shuffle analysis to the MIR. r?lth
Pushed by ydelendik@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/a88e03315396 Move shuffle analysis to the MIR. r=lth https://hg.mozilla.org/integration/autoland/rev/682739fe4e83 Ignore one of the SIMD shuffle operands if it is not used. r=lth
Status: NEW → RESOLVED
Closed: 3 years ago
Resolution: --- → FIXED
Target Milestone: --- → 94 Branch
Regressions: 1770335
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: