RFR: 8315066: Add unsigned bounds and known bits to TypeInt/Long [v12]

Vladimir Kozlov kvn at openjdk.org
Wed Sep 4 22:16:54 UTC 2024


On Wed, 4 Sep 2024 19:50:01 GMT, Quan Anh Mai <qamai at openjdk.org> wrote:

>> Hi,
>> 
>> This patch adds unsigned bounds and known bits constraints to TypeInt and TypeLong. This opens more transformation opportunities in an elegant manner as well as helps avoid some ad-hoc rules in Hotspot.
>> 
>> In general, a TypeInt/Long represents a set of values x that satisfies: x s>= lo && x s<= hi && x u>= ulo && x u<= uhi && (x & zeros) == 0 && (~x & ones) == 0. These constraints are not independent, e.g. an int that lies in [0, 3] in signed domain must also lie in [0, 3] in unsigned domain and have all bits but the last 2 being unset. As a result, we must normalize the constraints (tighten the constraints so that they are optimal) before constructing a TypeInt/Long instance.
>> 
>> This is extracted from #15440 , node value transformations are left for later PRs. I have also added unit tests to verify the soundness of constraint normalization.
>> 
>> Please kindly review, thanks a lot.
>> 
>> Testing
>> 
>> - [x] GHA
>> - [x] Linux x64, tier 1-4
>
> Quan Anh Mai has updated the pull request incrementally with one additional commit since the last revision:
> 
>   fix build

My main complain now it your spread of `is_int()`, 'is_long()', 'is_integer()' all over C2 code. Why not call them inside `make()`?

src/hotspot/share/opto/type.hpp line 29:

> 27: 
> 28: #include "opto/adlcVMDeps.hpp"
> 29: #include "opto/compile.hpp"

Please, don't include `compile.hpp` here - it could be cyclic dependencies if not now but later.
If you need something from it put it into `type.cpp`

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

PR Review: https://git.openjdk.org/jdk/pull/17508#pullrequestreview-2281497013
PR Review Comment: https://git.openjdk.org/jdk/pull/17508#discussion_r1744566752


More information about the hotspot-compiler-dev mailing list