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

C2: Incorrect computation after JDK-8273454

    XMLWordPrintable

Details

    • b16
    • Verified

    Description

      Attached Fuzzer test caught a serious regression after JDK-8273454. Note how the result is different in C2:

      $ ~/trunks/jdk/build/linux-x86_64-server-fastdebug/images/jdk/bin/java -Xint Test | grep Test.instanceCount | uniq
      Test.instanceCount Test.iFld Test.byFld = -2635249129509180159,2,0

       ~/trunks/jdk/build/linux-x86_64-server-fastdebug/images/jdk/bin/java -XX:TieredStopAtLevel=1 Test | grep Test.instanceCount | uniq
      Test.instanceCount Test.iFld Test.byFld = -2635249129509180159,2,0

      $ ~/trunks/jdk/build/linux-x86_64-server-fastdebug/images/jdk/bin/java -XX:-TieredCompilation Test | grep Test.instanceCount | uniq
      Test.instanceCount Test.iFld Test.byFld = 2635249177264977449,2,0


      Minimized test case:

      public class Test {
          public static int f;

          public static void main(String... strArr) {
              for (int c = 0; c < 2; c++) {
                  f += c;
                  f *= -1;
              }
              f &= f;
              System.out.println("final = " + f);
          }
      }

      $ ~/trunks/jdk/build/linux-x86_64-server-fastdebug/images/jdk/bin/java -Xint Test
      final = -1

      $ ~/trunks/jdk/build/linux-x86_64-server-fastdebug/images/jdk/bin/java -Xcomp -XX:-TieredCompilation Test
      final = 1

      I suspect the trouble is here:

      Node *AndINode::Ideal(PhaseGVN *phase, bool can_reshape) {
        // Special case constant AND mask
        const TypeInt *t2 = phase->type( in(2) )->isa_int();
        if( !t2 || !t2->is_con() ) return MulNode::Ideal(phase, can_reshape); // <--- calls new code through here

      So while ((-x) * (-y)) == (x * y) is always true indeed, ((-x) & (-y)) == (x & y) is not!

      Attachments

        Issue Links

          Activity

            People

              shade Aleksey Shipilev
              shade Aleksey Shipilev
              Votes:
              0 Vote for this issue
              Watchers:
              5 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: