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

regression in identity for x | 0

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P3 P3
    • 6
    • 6
    • hotspot
    • None
    • b29
    • sparc
    • solaris_9

      The fix for 5107650 accidentally removed the identity for x | 0. Previously this was handled by AddNode::Identity but when OrINode::Identity was introduced it didn't call it's super so now x | 0 is no longer being optimized. This was noticed in spec/jbb/infra/Util/DisplayScreen.putInt. The code there uses a bitwise or instead of a logical or for a range check, but this shouldn't result in any different code, apart from any reordering allowed by different code shapes. here's a test case with both forms.

      public class or {
          static public int v = 0;
          static public int l = 10;
          static public int e = 0;
          
          public static void main(String[] args) {
              for (int i = 0; i < 100000; i++) {
                  logic_or(i % 10);
              }
              for (int i = 0; i < 100000; i++) {
                  bitwise_or(i % 10);
              }
          }
          public static void bitwise_or(int x) {
              if ((x < 0) | x >= l) {
                  throw new InternalError("out of range " + x);
              } else {
                  e++;
              }
          }
          public static void logic_or(int x) {
              if ((x < 0) || x >= l) {
                  throw new InternalError("out of range " + x);
              } else {
                  e++;
              }
          }
      }

      OrLNode has the same problem.
      ###@###.### 2005-03-14 20:47:08 GMT

            azeemj Azeem Jiva
            never Tom Rodriguez
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: