RFR: 8338021: Support saturating vector operators in VectorAPI [v2]
Jatin Bhateja
jbhateja at openjdk.org
Mon Aug 12 06:32:33 UTC 2024
On Fri, 9 Aug 2024 03:28:53 GMT, Jasmine Karthikeyan <jkarthikeyan at openjdk.org> wrote:
>> Jatin Bhateja has updated the pull request with a new target base due to a merge or a rebase. The incremental webrev excludes the unrelated changes brought in by the merge/rebase. The pull request contains three additional commits since the last revision:
>>
>> - Merge branch 'master' of http://github.com/openjdk/jdk into JDK-8338201
>> - Removed redundant comment
>> - 8338021: Support saturating vector operators in VectorAPI
>
> src/hotspot/share/opto/type.cpp line 495:
>
>> 493: TypeInt::POS1 = TypeInt::make(1,max_jint, WidenMin); // Positive values
>> 494: TypeInt::INT = TypeInt::make(min_jint,max_jint, WidenMax); // 32-bit integers
>> 495: TypeInt::UINT = TypeInt::make(0, max_juint, WidenMin); // Unsigned ints
>
> This would make an illegal type, right? Since `TypeInt` is signed using `max_juint` as the hi value would end up as signed -1, resulting in the type `0..-1`, an empty type. I wonder if there's a better way to handle this, since in the type system empty types are in a sense equivalent to `TOP`.
@jaskarth , its usage in existing patch is limited to [type comparison.](https://github.com/openjdk/jdk/pull/20507/files#diff-3559dcf23b719805be5fd06fd5c1851dbd8f53e47afe6d99cba13a3de0ebc6b2R1542).
My plan is to address intrinsification of new core lib APIs, associated value range folding optimization (since unsigned numbers have different value range of [0, MAX_VALUE) vs signed [-MIN_VALUE/2, +MAX_VALUE/2) numbers) and auto-vectorization in a follow up patch.
**Notes on C2 type system:**
Unlike Type::FLOAT, integral type ranges are specified using _lo and _hi value range, these ranges are pruned using flow functions associated with each operation IR. Constraining the value ranges allows logic pruning, e.g. in1[TypeInt] & 0x7FFFFFFF will chop off -ve values ranges from in1, thus a constrol structure like . `if (in1 < 0) { true_path ; } else { false_path; } ` which uses in1 as a flow condition will sweepout the true path.
C2 type system only maintains value ranges for integral types i.e. long and int, any sub-word type which as per JVM specification has an int storage "word" only constrains the value range of TypeInt.
A type which represent a constant value has same _hi and _lo value.
Floating point types Type::FLOAT / DOUBLE cannot maintain upper / lower value ranges due to rounding constraints.
Thus a C2 type system maintains a separate type TypeF and TypeD which are singletons and represent a constant value.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/20507#discussion_r1713220777
More information about the hotspot-compiler-dev
mailing list