RFR: 8349563: Improve AbsNode::Value() for integer types

Chen Liang liach at openjdk.org
Wed Feb 19 16:16:55 UTC 2025


On Wed, 19 Feb 2025 05:10:04 GMT, Jasmine Karthikeyan <jkarthikeyan at openjdk.org> wrote:

> Hi all,
> This is a small patch that improves the implementation of Value() for `AbsINode` and `AbsLNode` by returning the absolute value of the input range. Most of the logic is trivial except for the special case where `_lo == jint_min/jlong_min` which must return the entire type range when encountered, for which I've added a small proof in the comments. I've also added some unit tests and updated the file to limit IR check platforms with more granularity.
> 
> Thoughts and reviews would be appreciated!

src/hotspot/share/opto/subnode.cpp line 1941:

> 1939: 
> 1940:   if (lo_abs < 0) {
> 1941:     assert(lo_abs == std::numeric_limits<NativeType>::min(), "uabs(t->_lo) must be min value if negative!");

I think asserting `t->_lo` to be min is more straightforward, and also indicates `(t->_lo) + 1`, which yields max, is in the type. We can simplify the comment below too.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/23685#discussion_r1961978914


More information about the hotspot-compiler-dev mailing list