RFR: 8349563: Improve AbsNode::Value() for integer types
Tobias Hotz
duke at openjdk.org
Sun Feb 23 09:29:52 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!
test/hotspot/jtreg/compiler/c2/irTests/TestIRAbs.java line 295:
> 293: public boolean testIntRange3(int in) {
> 294: // [-9, -2] => [2, 9]
> 295: return Math.abs(-((in & 7) + 2)) < 2;
Not sure if this is in scope for this PR, but `abs(x)` should be idealized into `0 - x` if x <= 0. This seems to be missing at the moment.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/23685#discussion_r1966721899
More information about the hotspot-compiler-dev
mailing list