C2 employs optimizations to replace ModI/L DivI/L by a row of shifts, additions, multiplications, and subtractions if the divisor is a constant that isn't a power of 2. This is great for performance, but prevents some other optimizations:
- CmpUNode::sub() uses CmpUNode::is_index_range_check() to optimize ((X ModI Y) CmpU Y) patterns (for appropriate input ranges). As the ModI gets replaced too early, the range check is not eliminated if the size of an array is known to be constant.
- After JDK-8356813, ModI will provide better type information. But as Value() is only called after Ideal() in GVN, we don't call ModINode::Value() if the node is replaced beforehand. The replacement provides less precise type information, also preventing other (range check) optimizations.
Therefore I suggest delaying the transformation so other optimizations depending on finding a Mod node or on precise type information.
I'm not sure what the best way is there, so I'll leave this for someone else.
- CmpUNode::sub() uses CmpUNode::is_index_range_check() to optimize ((X ModI Y) CmpU Y) patterns (for appropriate input ranges). As the ModI gets replaced too early, the range check is not eliminated if the size of an array is known to be constant.
- After JDK-8356813, ModI will provide better type information. But as Value() is only called after Ideal() in GVN, we don't call ModINode::Value() if the node is replaced beforehand. The replacement provides less precise type information, also preventing other (range check) optimizations.
Therefore I suggest delaying the transformation so other optimizations depending on finding a Mod node or on precise type information.
I'm not sure what the best way is there, so I'll leave this for someone else.
- relates to
-
JDK-8282365 Consolidate and improve division by constant idealizations
-
- Open
-
-
JDK-8286679 more range check elimination for hash tables
-
- Open
-
-
JDK-8356813 Improve Mod(I|L)Node::Value
-
- Open
-