RFR(M): 8173470: [C2] Mask shift operands in ideal graph.

Lindenmaier, Goetz goetz.lindenmaier at sap.com
Thu Feb 16 08:26:51 UTC 2017


Hi,

Constant shift operand > 31 (int) or > 63 (long) are pointless.
Mask them in the ideal graph, i.e.
if a constant is too large replace it by a smaller one.

The code also should use BitsPerJavaInteger instead of BitsPerInt.



Please review this change. I please need a sponsor.

http://cr.openjdk.java.net/~goetz/wr17/8173470-maskShift/webrev.01

>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.

Best regards,
  Goetz.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.openjdk.java.net/pipermail/hotspot-compiler-dev/attachments/20170216/0fdc87bd/attachment.html>


More information about the hotspot-compiler-dev mailing list