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

Optimize out redundant ifs for constant test.

XMLWordPrintable

    • Icon: Enhancement Enhancement
    • Resolution: Unresolved
    • Icon: P4 P4
    • tbd
    • 17
    • hotspot

      ```
       public static int condgt(int a, int b) {
           if (b > 0) {
             if (b > -10) { // redundant test
               return 0xdd;
             }else {
               return 0xff; // dead code
             }
           }else {
             return 0xee;
           }
         }
      ```

      For the test case above, "b > -10" could be removed safely as it's always true.

      So far c2 did related work for BoolTest::eq but remains some other cases like ne, le, ge, lt, gt.

            eliu Eric Liu
            eliu Eric Liu
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated: