Closed Bug 1716580 Opened 1 year ago Closed 8 months ago

ARM64+x64: Generate good code for i64 compare-and-select

Categories

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

enhancement

Tracking

()

RESOLVED FIXED
97 Branch
Tracking Status
firefox97 --- fixed

People

(Reporter: lth, Assigned: jseward)

References

(Blocks 1 open bug)

Details

Attachments

(1 file)

Pending patches on bug 1710024 clean up the compare-and-select code. However, this code is still specialized to int32 on x64 and to int32/float/double on arm64; on both platforms we should also support int64, but that requires at least one (but possibly three) new LIR nodes and/or some creative arithmetic when manipulating LIR operands. The technical problem is that LInt64Allocation is different from LAllocation and the LIR node needs space for the former, not the latter. In addition, there are three cases: the compare is int64 but the values are not; the values are int64 but the compare is not; and both are int64. (This is not hard, it's just annoying.)

Severity: -- → N/A
Priority: -- → P3
Assignee: nobody → jseward

For all targets, we generate good code for i32 compare followed by i32 select,
provided the compare result is only used once. "Good" in the sense that the
comparison result is not materialised into a register, but is instead
transmitted to the select instruction as a condition code.

On various targets float64 and float32 arguments are variously accepted as the
comparison and/or selection types. However, on no targets are 64-bit integers
accepted as either type.

This patch extends the machinery to create good code for the cases
compare-i32-select-i64, compare-i64-select-i32 and compare-i64-select-i64, on
x64 and arm64. All other targets are unaffected. The patch uses the existing
LWasmCompareAndSelect LIR node since that already has meaning "single
register compare, single register select", and we are not introducing any
double-register working here.

The methods LIRGenerator*::canSpecializeWasmCompareAndSelect,
LIRGenerator*::lowerWasmCompareAndSelect and
CodeGenerator*::visitWasmCompareAndSelect have been completely un-shared
(they were previously partly shared) and specialised to their specific
architectures. With the addition of the {i32,i64} x {i32,i64} cases the
remaining sharing is minimal and makes the code harder to follow.

The rest of the changes are straightforward.

tests/wasm/binop-arm64-ion-codegen.js
tests/wasm/binop-x64-ion-codegen.js

  • new tests

jit/shared/Lowering-shared.cpp

  • remove generic {canSpecialize,lower}WasmCompareAndSelect

jit/CodeGenerator.cpp:

  • remove generic emitWasmCompareAndSelect

jit/arm64/Lowering-arm64.cpp

  • extend existing {canSpecialize,lower}WasmCompareAndSelect

jit/arm64/CodeGenerator-arm64.cpp

  • extend existing visitWasmCompareAndSelect

jit/x64/Lowering-x64.cpp

  • private versions of {canSpecialize,lower}WasmCompareAndSelect

jit/x64/CodeGenerator-x64.cpp

  • new method visitWasmCompareAndSelect (heavily modified generic)

jit/arm/Lowering-arm.cpp

  • private versions of {canSpecialize,lower}WasmCompareAndSelect

jit/arm/CodeGenerator-arm.cpp

  • private version of emitWasmCompareAndSelect (specialisation of generic)

jit/x86/Lowering-x86.cpp

  • private versions of {canSpecialize,lower}WasmCompareAndSelect

jit/x86/CodeGenerator-x86.cpp

  • private version of emitWasmCompareAndSelect (copy of generic)

jit/arm64/MacroAssembler-arm64.h

  • new insn support for arm64

jit/x64/MacroAssembler-x64.h
jit/x64/MacroAssembler-x64.cpp

  • new insn support for x64
Pushed by jseward@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/d3f99095b5a7
ARM64+x64: Generate good code for i64 compare-and-select.  r=lth.
Status: NEW → RESOLVED
Closed: 8 months ago
Resolution: --- → FIXED
Target Milestone: --- → 97 Branch
Regressions: 1746702
Regressions: 1747087
Regressions: 1748700
You need to log in before you can comment on or make changes to this bug.