RFR: 8330163: C2: improve CMoveNode::Value() when condition is always true or false [v2]

Quan Anh Mai qamai at openjdk.org
Tue Apr 16 17:11:41 UTC 2024


On Tue, 16 Apr 2024 14:12:10 GMT, Roland Westrelin <roland at openjdk.org> wrote:

>> Can we check `Identity` during `PhaseCCP` instead? I see other inferences such as `AndINode` that may benefit from it.
>> 
>> Thanks.
>
>> Can we check `Identity` during `PhaseCCP` instead? I see other inferences such as `AndINode` that may benefit from it.
> 
> Can you give more details on the cases that are not covered by CCP currently? Can `Value` be extended instead of changing CCP?
> 
> In any case, that would be out of the scope of this change, right?

@rwestrel

> Can you give more details on the cases that are not covered by CCP currently?

For example, given `a & b`, during CCP, if the current value of `a` is `-1`, then `AndINode::Value` would yield `TypeInt::INT` while we can return a more rigorous value of `b`.

> Can Value be extended instead of changing CCP? In any case, that would be out of the scope of this change, right?

I think that if the issue is simply improving `CMoveNode::Value` then you are right, it would be out of the scope. However, given the reasoning for the issue being that it can improve CCP, I think it would be more generalised if we can consult `Identity` during CCP instead, maybe simply changing: `const Type* new_type = n->Value(this);` into `const Type* new_type = n->Identity(this)->Value(this);` would be adequate.

https://github.com/openjdk/jdk/blob/master/src/hotspot/share/opto/phaseX.cpp#L1810

Or even better, if we can incorporate `Identity` into `Value` of all nodes then it may have a positive impact on all use sites of `Value`, too.

Cheers,
Quan Anh

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

PR Comment: https://git.openjdk.org/jdk/pull/18757#issuecomment-2059557240


More information about the hotspot-compiler-dev mailing list