This is an archive of the discontinued LLVM Phabricator instance.

[OpenCL] Fix as_type3 invalid store creation
ClosedPublic

Authored by svenvh on Aug 20 2021, 9:13 AM.

Details

Summary

With -fpreserve-vec3-type enabled, a cast was not created when
converting from a non-vec3 type to a vec3 type, even though a
conversion to vec3 was performed. This resulted in creation of
invalid store instructions.

Related to D107963, but now for the to-vec3 case.

Diff Detail

Event Timeline

svenvh created this revision.Aug 20 2021, 9:13 AM
svenvh requested review of this revision.Aug 20 2021, 9:13 AM

If possible, can you add more tests for different types as previous patch please?

svenvh updated this revision to Diff 368058.Aug 23 2021, 3:29 AM

Added more tests as requested.

Can you also add "double2_to_float3" and "float4_to_float3" tests please?

Can you also add "double2_to_float3"

Instead of double2_to_float3, I decided to add char8_to_short3. Same idea (vectorN to vector3), but reinterpreting 8 chars as 3 shorts feels like a more realistic case than reinterpreting 2 doubles as 3 floats. But I'm happy to add double2_to_float3 if you think there is a good reason to do so.

and "float4_to_float3" tests please?

That test is already there, see line 17.

Can you also add "double2_to_float3"

Instead of double2_to_float3, I decided to add char8_to_short3. Same idea (vectorN to vector3), but reinterpreting 8 chars as 3 shorts feels like a more realistic case than reinterpreting 2 doubles as 3 floats. But I'm happy to add double2_to_float3 if you think there is a good reason to do so.

I am sorry for asking more tests because I did not add enough tests previously.
I do not know well how many type conversions with vec3 the recent OpenCL spec cover but it could be good to add more the tests of the type conversions which the spec mentions. If you feel the tests you have added are enough for it, I am ok with it.

and "float4_to_float3" tests please?

That test is already there, see line 17.

Sorry, I missed it.

LGTM

Instead of double2_to_float3, I decided to add char8_to_short3. Same idea (vectorN to vector3), but reinterpreting 8 chars as 3 shorts feels like a more realistic case than reinterpreting 2 doubles as 3 floats. But I'm happy to add double2_to_float3 if you think there is a good reason to do so.

I am sorry for asking more tests because I did not add enough tests previously.
I do not know well how many type conversions with vec3 the recent OpenCL spec cover but it could be good to add more the tests of the type conversions which the spec mentions. If you feel the tests you have added are enough for it, I am ok with it.

You were absolutely right about asking for more tests! I believe we now have much better coverage, let's see if @Anastasia (or any other reviewer) is also fine with the current set.

Anastasia accepted this revision.Sep 1 2021, 11:11 AM

LGTM! Thanks

This revision is now accepted and ready to land.Sep 1 2021, 11:11 AM
This revision was automatically updated to reflect the committed changes.