Object unboxing on x86-64 sometimes has a pointless movq

RESOLVED FIXED in mozilla37

Status

()

defect
RESOLVED FIXED
5 years ago
5 years ago

People

(Reporter: bzbarsky, Assigned: bzbarsky)

Tracking

unspecified
mozilla37
x86
macOS
Points:
---

Firefox Tracking Flags

(Not tracked)

Details

Attachments

(1 attachment)

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: 5 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla37
You need to log in before you can comment on or make changes to this bug.