RFR: 8331717: C2: Crash with SIGFPE Because Loop Predication Wrongly Hoists Division Requiring Zero Check [v2]
theoweidmannoracle
duke at openjdk.org
Wed Dec 18 12:25:48 UTC 2024
On Tue, 17 Dec 2024 12:10:21 GMT, Quan Anh Mai <qamai at openjdk.org> wrote:
> Maybe we should fix whatever is rewiring the DivI to the range check here?
The DivI is rewired and attached to the RangeCheck by IGVN in this case. Looking at the code
int i1 = 0;
for (int i4 : iArr) {
i4 = i1;
try {
iArr[0] = 1 / i4; // 183 DivI
i4 = iArr[2 / i4]; // 230 DivI
} catch (ArithmeticException a_e) {
}
}
and the resulting relevant nodes:

After several rounds of IGVN, we arrive at this state, where everything is still completely expected. 230 DivI is connected to its zero-check

IGVN/Idealization will now see that the zero-check-if for 230 DivI is dominated by the uero-check-if for 183 DivI and therefore remove it from the graph. This seems a benign and useful transformation in general.
-------------
PR Comment: https://git.openjdk.org/jdk/pull/22666#issuecomment-2551184815
More information about the hotspot-compiler-dev
mailing list