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

C2: Mask shift operands in ideal graph

XMLWordPrintable

    • b21

      Constant shift operand > 31 (int) or > 63 (long) are pointless. Mask them in the ideal graph.

      From the standard:
      https://docs.oracle.com/javase/specs/jls/se7/html/jls-15.html#jls-15.19
      If the promoted type of the left-hand operand is int, only the five lowest-order bits of the right-hand operand are used as the shift distance. It is as if the right-hand operand were subjected to a bitwise logical AND operator & (§15.22.1) with the mask value 0x1f (0b11111). The shift distance actually used is therefore always in the range 0 to 31, inclusive.

      If the promoted type of the left-hand operand is long, then only the six lowest-order bits of the right-hand operand are used as the shift distance. It is as if the right-hand operand were subjected to a bitwise logical AND operator & (§15.22.1) with the mask value 0x3f (0b111111). The shift distance actually used is therefore always in the range 0 to 63, inclusive.

            goetz Goetz Lindenmaier
            goetz Goetz Lindenmaier
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: