For example:
- x % 1 is optimized to 0 while Integer.remainderUnsigned(iFld, 1) is not.
- The control input is optimized away for DivI/L and ModI/L if the divisor cannot be zero while this is not done for UDivI/L and UModI/L. Note that the original report below wrongly assumed control *is* removed for the unsigned divisions and thus suffer from the same problems already fixed for the signed divisions with
This is not a complete list of missing optimizations. The goal of this RFE is to compare all Ideal/Identity/Value methods of the signed DivI/L and ModI/L nodes with the unsigned ones and figure out which optimizations can be applied to the unsigned versions as well. Ideally, we extract the shared logic into a separate class. We might not want to add a common super class for DivI/L and for ModI/L or make one a sub class of the other as this introduces some coupling and might have have unforeseeable consequences in existing code (e.g. is_Div() now also accepts UDiv nodes etc.). It might be cleaner to just have a separate class doing the logic, as for example done with IntegerTypeMultiplication:
https://github.com/openjdk/jdk/blob/f0b130e54f33d3190640ce33c991e35f27e9f812/src/hotspot/share/opto/mulnode.cpp#L346
Additionally, we should introduce IR framework tests that ensure the correctness of the new and existing (if not already exist) optimizations.
======================
Original report:
C2: PhaseIterGVN::no_dependent_zero_check() should handle unsigned div/mod
Summary:
Came up in the review for:
https://github.com/openjdk/jdk/pull/18377
"Looking at PhaseIterGVN::no_dependent_zero_check, I noticed that UDiv[I/L]Node and UMod[I/L]Node are not handled but I think they should. I think this was missed when these nodes where added by
- relates to
-
JDK-8259227 C2 crashes with SIGFPE due to a division that floats above its zero check
- Resolved
-
JDK-8336729 C2: Div/Mod nodes without zero check could be split through iv phi of outer loop of long counted loop nest resulting in SIGFPE
- Resolved
-
JDK-8346007 Incorrect copyright header in UModLNodeIdealizationTests.java
- Resolved
-
JDK-8345170 Use eqv_uncast in *Mod*Nodes::value in divnode.cpp
- Open
-
JDK-8282221 x86 intrinsics for divideUnsigned and remainderUnsigned methods in java.lang.Integer and java.lang.Long
- Resolved
- links to
-
Commit(master) openjdk/jdk/d381d581
-
Review(master) openjdk/jdk/22061