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

Better implementation for signed extract

    XMLWordPrintable

    Details

    • Subcomponent:
    • Resolved In Build:
      b23
    • CPU:
      generic
    • OS:
      generic

      Backports

        Description

        For java code "(i >> 31) >>> 31", it can be optimized to "i >>> 31".
        AArch64 has implemented this in back-end match rules, while AMD64
        hasn’t.

        Indeed, this pattern can be optimized in mid-end by adding some simple
        transformations. Besides, "0 - (i >> 31)" could also be optimized to
        "i >>> 31".

        This patch adds two conversions:

                1. URShiftINode: (i >> 31) >>> 31 ==> i >>> 31

                +------+ +----------+
                | Parm | | ConI(31) |
                +------+ +----------+
                   | / |
                   | / |
                   | / |
              +---------+ |
              | RShiftI | |
              +---------+ |
                       \ |
                        \ |
                         \ |
                          +----------+
                          | URShiftI |
                          +----------+

                2. SubINode: 0 - (i >> 31) ==> i >>> 31

                +------+ +----------+
                | Parm | | ConI(31) |
                +------+ +----------+
                       \ |
                        \ |
                         \ |
                          \ |
           +---------+ +---------+
           | ConI(0) | | RShiftI |
           +---------+ +---------+
                       \ |
                        \ |
                         \ |
                          +------+
                          | SubI |
                          +------+

        With this patch, these two graghs above both can be optimized to below:

                +------+ +----------+
                | Parm | | ConI(31) |
                +------+ +----------+
                    | /
                    | /
                    | /
                    | /
                +----------+
                | URShiftI |
                +----------+

          Attachments

            Issue Links

              Activity

                People

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

                  Dates

                  Created:
                  Updated:
                  Resolved: