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

C2: LShiftLNode::Ideal produces wrong result after JDK-8278114

XMLWordPrintable

    • b28
    • Verified

        JDK-8278114 converts "(x + x) << c0" into "x << (c0 + 1)" for a long shift. However, that is not correct if c0 is 63:

        (1 + 1) << 63 is converted to (1 << 1) << 63
        = 1 << 64 = 1 << 0 [according to the Java spec we only consider the six lowest-order bits of the right-hand operand (i.e. 64 = 0b10000000 & 0b0111111 = 0)]
        = 1

        while

        (1 + 1) << 63 = 2 << 63 = 0

        which is different. We should exclude the optimization added by JDK-8278114 if c0 = 63.

        Integer shifts are note affected since we only apply the optimization for shift values smaller than 16.

        This was found by the Java Fuzzer.

              chagedorn Christian Hagedorn
              chagedorn Christian Hagedorn
              Votes:
              0 Vote for this issue
              Watchers:
              5 Start watching this issue

                Created:
                Updated:
                Resolved: