Closed Bug 2051528 Opened 4 months ago Closed 4 months ago

Improve riscv64 codegen for LWasm(CompareAnd)Select

Categories

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

enhancement

Tracking

()

RESOLVED FIXED
154 Branch
Tracking Status
firefox154 --- fixed

People

(Reporter: anba, Assigned: anba)

References

(Blocks 1 open bug)

Details

Attachments

(5 external files)

Don't use defineReuseInput to avoid some unnecessary register moves added by the register allocator. (Register allocation in riscv64 will then match what we do for arm64.)

Make it work by creating branchy code instead.

This change is needed for parts 2-3.

This can avoid unnecessary register moves added by the register allocator.

For example:

(module
  (func (export "f")
    (param $p1 i32) (param $p2 i32) (param $p3 i32) (param $p4 i32) (result i32)
    (select (local.get $p3) (local.get $p4)
            (i32.eq (local.get $p1) (local.get $p2)))))

Was compiled to:

sext.w    t1, a2
sext.w    t0, t1
xor       t4, a0, a1
snez      t4, t4
czero.nez t0, t0, t4
czero.eqz t4, a3, t4
add       t0, t0, t4
sext.w    a0, t0

But is now compiled to:

xor       t4, a0, a1
seqz      t4, t4
czero.eqz a0, a2, t4
czero.nez t4, a3, t4
add       a0, a0, t4

This also allows to handle more input types for LWasmCompareAndSelect.

For example:

(module
  (func (export "f")
    (param $p1 i32) (param $p2 i32) (param $p3 i32) (result i32)
    (select (local.get $p2) (local.get $p1) (local.get $p3))))

Was compiled to:

sext.w    t1, a1
sext.w    t0, t1
czero.eqz t0, t0, a2
czero.nez t4, a0, a2
add       t0, t0, t4
sext.w    a0, t0

And is now compiled to:

czero.nez a0, a0, a2
czero.eqz t4, a1, a2
add       a0, a0, t4

cmpPtrMovePtr can be implemented through ma_cmp_mv.

These two methods are no longer called after the changes from parts 3-4.

Severity: -- → N/A
Priority: -- → P1
Pushed by andre.bargull@gmail.com: https://github.com/mozilla-firefox/firefox/commit/8cc60fa1a394 https://hg.mozilla.org/integration/autoland/rev/c7d9ce4be772 Part 1: Make ma_cselz/ma_cselnz work without Zicond enabled. r=spidermonkey-reviewers,jandem https://github.com/mozilla-firefox/firefox/commit/2b54b137c144 https://hg.mozilla.org/integration/autoland/rev/763e957c3693 Part 2: Avoid defineReuseInput for LWasmCompareAndSelect. r=spidermonkey-reviewers,jandem https://github.com/mozilla-firefox/firefox/commit/b24fff225b93 https://hg.mozilla.org/integration/autoland/rev/2daf17ea90f2 Part 3: Avoid defineReuseInput for LWasmSelect/LWasmSelectI64. r=spidermonkey-reviewers,jandem https://github.com/mozilla-firefox/firefox/commit/5b74ad81502c https://hg.mozilla.org/integration/autoland/rev/0bd58ac6a734 Part 4: Call ma_cmp_mv in cmpPtrMovePtr. r=spidermonkey-reviewers,jandem https://github.com/mozilla-firefox/firefox/commit/ac4e86a1ab36 https://hg.mozilla.org/integration/autoland/rev/c138d27657a9 Part 5: Remove no longer used moveIfZero/moveIfNotZero. r=spidermonkey-reviewers,jandem
QA Whiteboard: [qa-triage-done-c155/b154]
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: