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

incorrect integer optimization (loosing and op-r in a given example)

    XMLWordPrintable

    Details

    • Subcomponent:
    • Introduced In Build:
      b06
    • Introduced In Version:
    • Resolved In Build:
      b07
    • CPU:
      generic, x86
    • OS:
      generic, linux
    • Verification:
      Verified

      Backports

        Description

        The server compiler replaces the expression "(x & -32) / 2" by "x >> 1" which is not correct. Actually it's ok to replace the division by a right shift, but the removal of the "and operation" is not correct.


        1) Test program

        DivIdealizeAndMinus32FollowedByDivConst2Bug.java:

        public class DivIdealizeAndMinus32FollowedByDivConst2Bug {

            public static void main(String[] args) {
                long iteration = 0;
                while (true) {
                    iteration++;
                    int result = andMinus32FollowedByDivConst2(255);
                    if (result != 112) {
                        System.out.println("expected 112, but got " + result + " after iteration " + iteration);
                        System.exit(-1);
                    }
                }
            }

            private static int andMinus32FollowedByDivConst2(int x) {
                return (x & -32) / 2;
            }

        }


        2) Output of the test program on linux-x86_64

        $ bin/java -showversion -classpath tests -server -XX:-UseOnStackReplacement -XX:+PrintCompilation DivIdealizeAndMinus32FollowedByDivConst2Bug

        java version "1.6.0_17"
        Java(TM) SE Runtime Environment (build 1.6.0_17-b04)
        Java HotSpot(TM) 64-Bit Server VM (build 14.3-b01, mixed mode)

          1 DivIdealizeAndMinus32FollowedByDivConst2Bug::andMinus32FollowedByDivConst2 (7 bytes)
        expected 112, but got 127 after iteration 171644

          Attachments

            Issue Links

              Activity

                People

                Assignee:
                kvn Vladimir Kozlov
                Reporter:
                ikrylov Ivan Krylov
                Votes:
                0 Vote for this issue
                Watchers:
                0 Start watching this issue

                  Dates

                  Created:
                  Updated:
                  Resolved:
                  Imported:
                  Indexed: