Closed Bug 1111166 Opened 10 years ago Closed 10 years ago

Object unboxing on x86-64 sometimes has a pointless movq

Categories

(Core :: JavaScript Engine: JIT, defect)

x86
macOS
defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla37

People

(Reporter: bzbarsky, Assigned: bzbarsky)

Details

Attachments

(1 file)

This is what we output for a fallible unbox to object:

[Unbox:Object]
    movq       %rcx, %r11
    shrq       $47, %r11
    cmpl       $0x1fff8, %r11d
    jne        ((2478))
    movabsq    $0x7fffffffffff, %r11
    movq       %rcx, %rcx
    andq       %r11, %rcx

That "movq %rcx, %rcx" is pointless, afaict.  We only need that mov if the operand had been something like %rcx(whatever), right?
Comment on attachment 8535970 [details] [diff] [review]
Don't emit a movq from a register to itself when unboxing things on x86-64

Review of attachment 8535970 [details] [diff] [review]:
-----------------------------------------------------------------

> That "movq %rcx, %rcx" is pointless, afaict.  We only need that mov if the
> operand had been something like %rcx(whatever), right?

Right.

Also, if you're interested, the sequence

      movabsq    $0x7fffffffffff, %r11
      andq       %r11, %rcx

is 13 bytes long. An alternative:

      shlq       $17. %rcx
      shrq       $17, %rcx

is only 8 bytes long. However, it does lengthen the dependence chain for the result, so performance would need to be considered.
Attachment #8535970 - Flags: review?(sunfish) → review+
https://hg.mozilla.org/mozilla-central/rev/1cd8295305eb
Status: NEW → RESOLVED
Closed: 10 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla37
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: