Closed Bug 1641595 Opened 4 years ago Closed 4 years ago

Use bitwiseAndSimd128(SimdConstant, reg) and similar to lower register pressure

Categories

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

x86_64
All
enhancement

Tracking

()

RESOLVED FIXED
84 Branch
Tracking Status
firefox84 --- fixed

People

(Reporter: lth, Assigned: lth)

References

(Blocks 1 open bug)

Details

Attachments

(2 files)

During lowering on x86 and x64 we frequently load a mask and then bitwise-op a value with the mask, and then throw the mask away. We can operate directly from memory. With the x86 port there's already a bitwiseAndSimd128(SimdConstant, reg) operation; other operations could be added here, and used to improve code generation locally.

A wrinkle is that these operations may not be allowed to use the scratch register, since the higher-level operation wanting to use these operations may already be using that. This requires some thought.

A related, but complementary, matter that could be investigated in the context of this bug is that loaded constants could be lifted out of the lowering context so as to be exposed properly to MIR and subject to commoning, hoisting, and whatnot.

In general, memory constants can be used when they are only used once. In shuffleInt8x16(), we load two constants to use with PSHUFB and these require an extra temp register because the SIMD temp is taken. But PSHUFB can take a mask from memory, so we could use that here.

Assignee: nobody → lhansen
Status: NEW → ASSIGNED

Instead of loading instruction-internal simd constants separately (on
x86/x64) and thus increasing register pressure by requiring temps,
load them as part of the operation.

This patch adapts the shuffle operation (pshufb). There's a fair
amount of plumbing in the assemblers but the change amounts to
inlining the constant loads into the instruction, getting rid of a
temp, and making sure we bias in favor of lhs == output.

Depends on D94554

Instead of loading instruction-internal simd constants separately (on
x86/x64) and thus potentially increasing register pressure by
requiring temps, load them as part of the operation.

This patch handles a few remaining single-use-of-loaded-const cases,
none of which are probably all that important, this is just hygiene.

In the case where a loaded const is used multiple times, or a single
use can't be gotten rid of without introducing additional moves, we
assume (for now) that it's OK to load the constant separately. The
cases that remain in this class are blends (that will use a mask and
its negation) and a few floating-point slow paths (some with multiple
uses, some with knotty logic).

Depends on D94556

Pushed by lhansen@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/326887a2b839
inline constants, part 1: shuffle. r=jseward
https://hg.mozilla.org/integration/autoland/rev/b5f6faabcb09
inline constants, part 2: random other cases. r=jseward
Pushed by lhansen@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/23f94c8ec53b
inline constants, part 1: shuffle. r=jseward
https://hg.mozilla.org/integration/autoland/rev/83ffcdef5940
inline constants, part 2: random other cases. r=jseward
Status: ASSIGNED → RESOLVED
Closed: 4 years ago
Resolution: --- → FIXED
Target Milestone: --- → 84 Branch
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: