This is an archive of the discontinued LLVM Phabricator instance.

[clang] Implement VectorType logic not operator.
ClosedPublic

Authored by junparser on Jun 1 2020, 10:43 PM.

Details

Diff Detail

Event Timeline

junparser created this revision.Jun 1 2020, 10:43 PM
Herald added a project: Restricted Project. · View Herald TranscriptJun 1 2020, 10:43 PM
Herald added a subscriber: cfe-commits. · View Herald Transcript
simoll added a subscriber: simoll.Jun 2 2020, 4:21 AM

Write some codegen tests please, I'd like to have a better idea of what you want ! to do here. Additionally, I'm not sure as to the limits you've placed on this patch. Please justifiy them.C

clang/lib/CodeGen/CGExprScalar.cpp
2746

Why limit this to just the base vector type? Doesn't this remove the ext-vector implementation?

clang/lib/Sema/SemaExpr.cpp
14448

Why C++ only? It seems if we're doing this, it should be for all language modes.

clang/test/CodeGen/vector.c
90 ↗(On Diff #267788)

Can you clarify what this is doing here? It doesn't seem clear to me what the output of this is.

Additionally, what about FP types? What do we expect this to emit?

98 ↗(On Diff #267788)

Why is the IR so different between int and long long (here and the above test)? It would seem to me the IR should be basically identical, perhaps with a cast somewhere, but not completely different IR.

junparser marked 3 inline comments as done.Jun 3 2020, 8:52 PM
junparser added inline comments.
clang/lib/CodeGen/CGExprScalar.cpp
2746

the kind of ext-vector is GenericVector as well. so it also includes ext-vector.

clang/lib/Sema/SemaExpr.cpp
14448

Here we keep the behavior as same as gcc since ! of vector only allows with C++ in gcc

clang/test/CodeGen/vector.c
90 ↗(On Diff #267788)

sorry for the confusing. it seems i add the wrong code which test the != rather than !. I'll add the new testcases

This patch implement the logic not operation of vector type. it keeps same behavior as gcc does (only allows in C++). I'll update the wrong testcases

junparser updated this revision to Diff 268366.EditedJun 3 2020, 10:36 PM

address the comment.
hi @erichkeane, most of the function in vector-1.cpp are copied from ext-vector.c with vector type changed to gcc vector type, they should emit same ir. I add test7 and test8 which test logic operation of gcc vector type.

junparser marked 2 inline comments as done.Jun 3 2020, 10:38 PM
junparser added inline comments.
clang/test/CodeGen/vector-1.cpp
183 ↗(On Diff #268366)

logic operation with vector int

201 ↗(On Diff #268366)

logic operation with vector float

erichkeane added inline comments.Jun 4 2020, 5:46 AM
clang/lib/CodeGen/CGExprScalar.cpp
2746

"isVectorType" also includes ExtVectorType. My question is which vector types are you attempting to exclude here?

Can the ExtVectorKind ever be a AltiVec* or Neon Vector type? If so, this change would break code for those.

erichkeane added inline comments.Jun 4 2020, 5:55 AM
clang/lib/CodeGen/CGExprScalar.cpp
2746

Just dug in and answered my own question, ExtVector is always created as Generic, see ASTContext::getExtVectorType. So I think the check for GenericVector (here and in Sema) properly constrains this patch to only adding C++-mode standard vector-types.

clang/test/CodeGen/vector-1.cpp
2 ↗(On Diff #268366)

I don't think copying the whole test from the other file is the right idea. We already validate the rest of the operations on normal vectors in a number of places. If any of those are C++ tests, just add your tests there. Otherwise this test should only validate the logical-not operator.

junparser marked 2 inline comments as done.Jun 4 2020, 6:37 PM
junparser added inline comments.
clang/test/CodeGen/vector-1.cpp
2 ↗(On Diff #268366)

ok, I'll only add the logical-not operator test

junparser updated this revision to Diff 268649.Jun 4 2020, 8:14 PM

address the comment.

erichkeane accepted this revision.Jun 5 2020, 6:32 AM
This revision is now accepted and ready to land.Jun 5 2020, 6:32 AM
This revision was automatically updated to reflect the committed changes.
thakis added a subscriber: thakis.Jun 7 2020, 8:22 PM

This breaks tests on Windows: http://45.33.8.238/win/17077/step_7.txt

Please take a look and revert if it takes a while to fix.