On Wed, 25 Feb 2026 09:07:56 GMT, Jatin Bhateja <[email protected]> wrote:

>> src/hotspot/share/opto/vectornode.cpp line 1363:
>> 
>>> 1361:     if (sop) {
>>> 1362:       sop = phase->transform(sop);
>>> 1363:       return new ReplicateNode(sop, vect_type());
>> 
>> Suppose we have an `add` operation on a `byte` vector. The operations are 
>> truncated. But the `AddI` operation would overflow the `byte` range. Does 
>> the `Replicate` node ensure that truncation?
>
> Yes, replicate will only read lower 8 / 16 bits of integral result.

As of now, there are implicit assumptions in many places for subword types that 
an int input is truncated. It is sort of convenient when working with the IR 
(fewer nodes), but the burden is pushed to platform-specific assembly code (in 
AD instructions) making it harder to track the invariants.  

It would be nice to eventually harden the Ideal IR and make truncation 
explicit. As a bonus, subword operations can assert that their inputs have 
proper types (ensuring that values are in proper bounds at runtime). And 
matcher can fuse truncation operations when corresponding instructions do it 
implicitly.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/25617#discussion_r2922017704

Reply via email to