Closed
Bug 1995488
Opened 1 year ago
Closed 1 year ago
Optimise clamp{Double}IntToUint8 on riscv64
Categories
(Core :: JavaScript Engine: JIT, enhancement, P3)
Core
JavaScript Engine: JIT
Tracking
()
RESOLVED
FIXED
146 Branch
| Tracking | Status | |
|---|---|---|
| firefox146 | --- | fixed |
People
(Reporter: anba, Assigned: anba)
References
(Blocks 1 open bug)
Details
Attachments
(2 external files)
No description provided.
| Assignee | ||
Comment 1•1 year ago
|
||
ClampIToUint8 was compiled to:
slti t4, t0, 0
li t5, 1
bne t4, t5, 0 -> skip
mv t0, zero
j 0 -> skip2
li t5, 255
bge t5, t0, 0 -> skip2
li t0, 255
Loading the immediate 1 into t5 is unnecessary when instead comparing
against zero. But we can go even further and use the same approach as used
in MacroAssemblerRiscv64Compat::minMax32 to check for negative values. That
saves another branch and ClampIToUint8 is now compiled to:
sgtz t4, t0
neg t4, t4
and t0, t0, t4
li t4, 255
bge t4, t0, 0 -> skip
li t0, 255
| Assignee | ||
Comment 2•1 year ago
|
||
Improves the generated code from:
feq.d t4, ft1, ft1
beq t4, zero, 0 -> nan
addi zero, t4, 17
fcvt.w.d [RNE] t0, ft1
sgtz t5, t0
neg t5, t5
and t0, t0, t5
li t5, 255
bge t5, t0, 0 -> skip
li t0, 255
j 0 -> done
mv t0, zero
To:
fcvt.w.d [RNE] t0, ft1
feq.d t4, ft1, ft1
neg t4, t4
and t0, t0, t4
sgtz t4, t0
neg t4, t4
and t0, t0, t4
li t4, 255
bge t4, t0, 0 -> skip
li t0, 255
Two less instructions and only a single conditional jump.
Updated•1 year ago
|
Severity: -- → N/A
Priority: -- → P3
Pushed by andre.bargull@gmail.com:
https://github.com/mozilla-firefox/firefox/commit/f6e86e9a5e2b
https://hg.mozilla.org/integration/autoland/rev/b7f1cbaf21f0
Part 1: Avoid comparison against non-zero in clampIntToUint8 for riscv64. r=spidermonkey-reviewers,iain
https://github.com/mozilla-firefox/firefox/commit/9aa3304e2fa4
https://hg.mozilla.org/integration/autoland/rev/c28e2144cb69
Part 2: Remove branches from clampDoubleToUint8 on riscv64. r=spidermonkey-reviewers,iain
Comment 4•1 year ago
|
||
| bugherder | ||
https://hg.mozilla.org/mozilla-central/rev/b7f1cbaf21f0
https://hg.mozilla.org/mozilla-central/rev/c28e2144cb69
Status: ASSIGNED → RESOLVED
Closed: 1 year ago
status-firefox146:
--- → fixed
Resolution: --- → FIXED
Target Milestone: --- → 146 Branch
Updated•11 months ago
|
QA Whiteboard: [qa-triage-done-c147/b146]
You need to log in
before you can comment on or make changes to this bug.
Description
•