RFR: 8324630: C1: Canonicalizer::do_LookupSwitch doesn't break the loop when the successor is found [v3]

Dean Long dlong at openjdk.org
Mon Jan 29 21:46:32 UTC 2024


On Sat, 27 Jan 2024 03:20:52 GMT, Denghui Dong <ddong at openjdk.org> wrote:

>> src/hotspot/share/c1/c1_Canonicalizer.cpp line 848:
>> 
>>> 846:     int high = x->length() - 1;
>>> 847:     while (low <= high) {
>>> 848:       int mid = low + ((high - low) >> 1);
>> 
>> Isn't this the same as
>> `int mid = (low + high) >> 1;`
>
> `low + ((high - low) >> 1)`  can avoid integer overflow (it seems unlikely to happen though).

Good point.  Integer overflow is a real concern.

-------------

PR Review Comment: https://git.openjdk.org/jdk/pull/17553#discussion_r1470256667


More information about the hotspot-compiler-dev mailing list