Closed Bug 1995490 Opened 1 year ago Closed 1 year ago

Optimise left-rotate for riscv64

Categories

(Core :: JavaScript Engine: JIT, enhancement, P3)

enhancement

Tracking

()

RESOLVED FIXED
146 Branch
Tracking Status
firefox146 --- fixed

People

(Reporter: anba, Assigned: anba)

References

(Blocks 1 open bug)

Details

Attachments

(2 external files)

Left-rotate is implemented by performing 32 - (count % 32)) in assembly code, which is fairly inefficient.

i32.rotl was compiled to:

li        t5, 32
remw      t4, a1, t5
negw      t4, t4
addi      t4, t4, 32
negw      t5, t4
sllw      t5, a0, t5
srlw      a0, a0, t4
or        a0, t5, a0
sext.w    a0, a0

And now it's directly:

negw      t4, a1
srlw      t4, a0, t4
sllw      a0, a0, a1
or        a0, t4, a0
sext.w    a0, a0

Shift and rotate instructions are defined as using the low five resp. six bits.
This is more accurately implemented when using bit-and instead of (signed)
integer modulus.

Severity: -- → S4
Priority: -- → P3
Pushed by andre.bargull@gmail.com: https://github.com/mozilla-firefox/firefox/commit/f8e4fb61645e https://hg.mozilla.org/integration/autoland/rev/9ae44eb6b083 Part 1: Optimise left-rotate for riscv64. r=spidermonkey-reviewers,iain https://github.com/mozilla-firefox/firefox/commit/46af4d9a893a https://hg.mozilla.org/integration/autoland/rev/6c2445409807 Part 2: Replace modulus with bit-and for shift/rotate with immediate. r=spidermonkey-reviewers,iain
Status: ASSIGNED → RESOLVED
Closed: 1 year ago
Resolution: --- → FIXED
Target Milestone: --- → 146 Branch
QA Whiteboard: [qa-triage-done-c147/b146]
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: