RFR: 8341834: C2 compilation fails with "bad AD file" due to Replicate [v2]
Roland Westrelin
roland at openjdk.org
Fri Oct 25 15:19:25 UTC 2024
On Thu, 24 Oct 2024 16:33:25 GMT, Vladimir Kozlov <kvn at openjdk.org> wrote:
>> @vnkozlov You can very easily see how it goes with my `Test4` above, I split the things onto different lines so we can see what is from where easily.
>>
>> The pack that `p0` belongs to is a `ConvL2I` pack. In my case, I have an `short[]`, just to make things even more interesting. Since the type is propagated from use -> def, the output of the `ConvL2I` is interpreted as a `short`, it is essentially a truncated `int`. `velt_basic_type(p0) == T_SHORT`. The vector node should be a `VectorCastL2X === _ 873 [[ ]] #vectors<S,2>`, i.e. casting from long-vector to short-vector.
>>
>> But now we see that the input to the pack of `p0` is all the same, and so we want to introduce a `Replicate`. We should of course replicate for `long`. But `velt_basic_type(p0) == T_SHORT` - so you get a `Replicate === _ 717 [[ ]] #vectorx<S,2>`, and then eventually a `VectorCastS2X === _ 890 [[ ]] #vectors<S,2>`... but of course the AD file has no matching node for a VectorCast from short to short -> `bad AD file`.
>>
>> The issue is really that `velt_basic_type(p0)` gives us the output-type, but we actually would need the input-type. In almost all cases input-type == output-type. But of course that does not hold with Convert.
>>
>> With Roland's fix, we now ask for the output-type of the `ConvL2I`'s input. That is the same as asking for the `ConvL2I`'s input-type. That way, we know what type to Replicate for - the `element_type`.
>>
>> @rwestrel given that @vnkozlov also did not right away understand what is going on, I think you need to properly explain what happens in the comments ;)
>
> Thank you for explanation. Yes, to have comment would be nice.
I added a comment. Does it look ok to you?
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/21660#discussion_r1816904205
More information about the hotspot-compiler-dev
mailing list