Closed Bug 2044242 Opened 5 months ago Closed 5 months ago

Improve ma_cmp_set with Imm32

Categories

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

enhancement

Tracking

()

RESOLVED FIXED
153 Branch
Tracking Status
firefox153 --- fixed

People

(Reporter: anba, Assigned: anba)

References

(Blocks 1 open bug)

Details

Attachments

(3 external files)

ma_cmp_set calls to ma_cmp to use shared code for more conditions, but this approach requires performing an additional xori to negate the result.

For example:

function f(x) {
  return x >= 100000;
}

Is compiled to:

lui       t4, 0x18
addiw     t4, t4, 1696
slt       t1, t0, t4
xori      t1, t1, 0x1

But can instead be compiled to:

lui       t4, 0x18
addiw     t4, t4, 1695
slt       t1, t4, t0

In addition to that, ma_cmp_set with an ImmWord operand should also support negative Imm32 values. For example:

function f(i64) {
  return i64[0] <= -10;
}

Is currently compiled to:

li        t4, -10
slt       t0, t4, t1
xori      t0, t0, 0x1

Instead of the expected:

slti      t0, t1, -9

And improve it to require no more than three instructions.

For example:

function f(x) {
  return x >= 100000;
}

Was compiled to:

lui       t4, 0x18
addiw     t4, t4, 1696
slt       t1, t0, t4
xori      t1, t1, 0x1

And is now compiled to:

lui       t4, 0x18
addiw     t4, t4, 1695
slt       t1, t4, t0

This restriction was copied mips64/loong64, but I don't see any obvious issues
why riscv64 needs to have the same restriction.

Severity: -- → N/A
Priority: -- → P1
Status: ASSIGNED → RESOLVED
Closed: 5 months ago
Resolution: --- → FIXED
Target Milestone: --- → 153 Branch
QA Whiteboard: [qa-triage-done-c154/b153]
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: