Page MenuHomePhabricator

[ExtVectorType] Support conditional select operator for C++.

Authored by fhahn on Mar 5 2021, 9:42 AM.



This patch implements the conditional select operator for
ext_vector_types in C++. It does so by using the same semantics as for

D71463 added support for the conditional select operator for VectorType
in C++. Unfortunately the semantics between ext_vector_type in C are
different to VectorType in C++. Select for ext_vector_type is based on
the MSB of the condition vector, whereas for VectorType it is != 0.

This unfortunately means that the behavior is inconsistent between
ExtVectorType and VectorType, but I think using the C semantics for
ExtVectorType in C++ as well should be less surprising for users.

Diff Detail

Event Timeline

fhahn requested review of this revision.Mar 5 2021, 9:42 AM
fhahn created this revision.
Herald added a project: Restricted Project. · View Herald TranscriptMar 5 2021, 9:42 AM
erichkeane added inline comments.Mar 5 2021, 9:49 AM

Why is this change necessary? Doesn't ExtVectorType inherit from VectorType? These should both be calling the same function here.


Oh boy, this is awkward as all heck...

Makes me think we should instead have a templated function Context.getVectorType<VectorType>() or <ExtVectorType>


Again I wonder why the 'if' here is necessary? Shouldn't just removing the 'error' diag in the call take care of this?

fhahn updated this revision to Diff 328815.Mar 6 2021, 1:37 PM

Got rid of the template parameter, greatly simplified the code.

fhahn added inline comments.Mar 6 2021, 1:40 PM

It's not really necessary, it turns out the template argument is not really needed and the whole function can be simplified a lot!


That's gone now, it just checks for ExtvectorType now.


It's gone now. I also added a few additional test cases that mix vector_size/ext_vector_type vectors, which should be rejected I think (see mix_vector_types in clang/test/SemaCXX/ext-vector-type-conditional.cpp)

erichkeane accepted this revision.Mar 8 2021, 5:54 AM
This revision is now accepted and ready to land.Mar 8 2021, 5:54 AM
aaron.ballman accepted this revision.Mar 8 2021, 1:00 PM


fhahn marked an inline comment as done.Mar 9 2021, 4:52 AM
fhahn added inline comments.

I'll fix that before committing, thanks!

This revision was automatically updated to reflect the committed changes.
fhahn marked an inline comment as done.