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

C2: Add new transform for bool eq/ne (cmp (and (urshift X const1) const2) 0)

XMLWordPrintable

    • generic
    • generic

      A DESCRIPTION OF THE PROBLEM :
      C2 can be improved to Idealize bool eq/ne (cmp (and (urshift X const1) const2) 0) into bool eq/ne (cmp (and X newconst) 0) where newconst is being computed from the two original constants.
      The following pattern can be improved:
      public boolean testFunc(int a) {
          int mask = 0b101;
          int shift = 12;
          return ((a >> shift) & mask) == 0;
      }
      On x86, this improvement means only a "test" instruction will be emitted instead of a "shift" followed by a "test".
      I've already created a PR: https://github.com/openjdk/jdk/pull/19310


            Unassigned Unassigned
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated: