Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8247472

AArch64: Remove redundant `narrow` followed by compatible `extend`

    Details

    • Type: Enhancement
    • Status: Open
    • Priority: P4
    • Resolution: Unresolved
    • Affects Version/s: 15
    • Fix Version/s: tbd
    • Component/s: hotspot
    • Labels:
    • Subcomponent:
    • CPU:
      aarch64
    • OS:
      generic

      Description

      // test case
      public static long l2s2l(long x) {
             return (short) x;
      }

      // generated by C2
      [Verified Entry Point]
        0x0000ffffac27ca00: nop
        0x0000ffffac27ca04: sub sp, sp, #0x20
        0x0000ffffac27ca08: stp x29, x30, [sp, #16]
        0x0000ffffac27ca0c: sxth w11, w1 // redundant
        0x0000ffffac27ca10: sxtw x0, w11
        0x0000ffffac27ca14: ldp x29, x30, [sp, #16]
        0x0000ffffac27ca18: add sp, sp, #0x20
        0x0000ffffac27ca1c: ldr x8, [x28, #272]
        0x0000ffffac27ca20: ldr wzr, [x8] ; {poll_return}
        0x0000ffffac27ca24: ret

       

      According to the A64 instruction set:

          When a 32-bit register form is selected:
          • Writes to the W register set bits [63:32] of the X register to zero.

      Following this, the narrow ahead of extend can be safely removed.

      l2b2l, i2b2l, l2c2l, i2c2l, i2s2l also have this problem.

        Attachments

          Activity

            People

            • Assignee:
              yzhang Yang Zhang
              Reporter:
              yzhang Yang Zhang
            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated: