RFR: 8275202: C2: optimize out more redundant conditions

Roland Westrelin roland at openjdk.org
Wed Oct 11 13:47:11 UTC 2023


On Mon, 9 Oct 2023 23:21:06 GMT, Dean Long <dlong at openjdk.org> wrote:

> Does your solution handle code like this?
> 
> ```
>     if (i >= 1) {
>       if (i <= 2) {
>         if (i != 2) {
>           // do we know i == 1 here?
> ```
> 
> because the type system doesn't seem to handle != very well, unless it is != min or max.

I haven't tried it but I think it should. The new code relies on existing logic to compute the narrowed type:

https://github.com/openjdk/jdk/blob/1eb88623fa550f5fca9bb3e4f5f6c05d32d69384/src/hotspot/share/opto/subnode.cpp#L1899

And that logic does the right thing AFAICT.

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

PR Comment: https://git.openjdk.org/jdk/pull/14586#issuecomment-1757726788


More information about the hotspot-compiler-dev mailing list