RFR: 8275202: C2: optimize out more redundant conditions

Roland Westrelin roland at openjdk.org
Wed Jul 12 15:57:14 UTC 2023


On Tue, 11 Jul 2023 16:34:15 GMT, Vladimir Kozlov <kvn at openjdk.org> wrote:

> Do you know why CCP phase can't help for simple cases (not in loop)? Can we fix CCP to handle simple cases?

CCP and IGVN keep track of types in a global table. In the example above:

if (i < 10) {
  if (i < 42) {

`i`'s type is `[min, 9]` only in the if branch so that `[min,9]` can't be stored in a global table that contains types that must be valid everywhere in the IR graph. The way c2 handles control dependent types is with cast nodes. The change I propose is equivalent to having cast nodes on every projection of every `CmpI`/`CmpU`/`CmpL`/`CmpL` for both inputs of the cmp node and then have logic in igvn to narrow the type of the cast. Instead of using cast nodes, that change keeps track of types in side tables. I think it's much better than trying to make things work with cast nodes because it's a lot less invasive and disruptive to the rest of c2. It's a single new standalone pass contained in a couple files that runs during loop opts.

What's your opinion on the compile time overhead for this? Do you find the number I mention too high?

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

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


More information about the hotspot-compiler-dev mailing list