RFR: 8349563: Improve AbsNode::Value() for integer types [v2]

Damon Fenacci dfenacci at openjdk.org
Mon Apr 7 08:31:09 UTC 2025


On Wed, 2 Apr 2025 14:48:20 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!
>
> Jasmine Karthikeyan has updated the pull request with a new target base due to a merge or a rebase. The pull request now contains two commits:
> 
>  - Merge
>  - Improve AbsNode::Value

test/hotspot/jtreg/compiler/c2/irTests/TestIRAbs.java line 249:

> 247:     @DontCompile
> 248:     public void checkIntRange(int i) {
> 249:         Asserts.assertEquals(Math.abs((i & 7) - 4) > 4, testIntRange1(i));

Cool improvement @jaskarth!
It might not be directly related to your optimization and marginally relevant but I was wondering if it would make sense to widen the choice of constants a bit (maybe adding few more or some randomly generated ones)?

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

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


More information about the hotspot-compiler-dev mailing list