This is an archive of the discontinued LLVM Phabricator instance.

[clang][AArch64][SVE] Implicit conversions for vector-scalar operations
ClosedPublic

Authored by DavidTruby on May 25 2022, 7:33 AM.

Details

Summary

This patch allows the same implicit conversions for vector-scalar
operations in SVE that are allowed for NEON.

Depends on D126377

Diff Detail

Event Timeline

DavidTruby created this revision.May 25 2022, 7:33 AM
DavidTruby requested review of this revision.May 25 2022, 7:33 AM
Herald added a project: Restricted Project. · View Herald TranscriptMay 25 2022, 7:33 AM
Herald added a subscriber: cfe-commits. · View Herald Transcript
Matt added a subscriber: Matt.May 25 2022, 2:06 PM
c-rhodes added inline comments.May 26 2022, 2:01 AM
clang/lib/Sema/SemaChecking.cpp
13521–13543

a lot of this is duplicated by what you've added below

13569

this is the same as Target defined on line 13473

clang/lib/Sema/SemaExpr.cpp
10266

how about:

if (const auto *VT = VectorTy->getAs<VectorType>()) {
  assert(!isa<ExtVectorType>(VT) &&
         "ExtVectorTypes should not be handled here!");
  ...

?

10269–10270
VectorEltTy =
    VectorTy->castAs<BuiltinType>()->getSveEltType(S.getASTContext());
10272

nit: fixed-length

clang/test/CodeGen/aarch64-sve-vector-arith-ops.c
336

took me a moment to realise lit -> literal, maybe add an underscore to make it clearer? I.e. add_i8_i_lit

clang/test/Sema/aarch64-sve-vector-scalar-ops.c
1 ↗(On Diff #431989)

There's so few tests in here is it not worth add them to clang/test/Sema/aarch64-sve-vector-arith-ops.c?

5 ↗(On Diff #431989)

what's NEON needed for in this test?

12 ↗(On Diff #431989)

unused

17 ↗(On Diff #431989)

there's already a test for this in clang/test/Sema/aarch64-sve-vector-arith-ops.c.

DavidTruby added inline comments.Jun 6 2022, 5:34 AM
clang/lib/Sema/SemaChecking.cpp
13569

The control flow in this function is a little odd, but it isn't necessarily the same target; we could have entered one or more of the if statements above that modify the target, and we need to inspect the original target here.

DavidTruby updated this revision to Diff 434445.Jun 6 2022, 5:39 AM

Clean up code based on review comments
Move additional tests to existing file

@DavidTruby thanks for updating, just one last comment otherwise LGTM

clang/lib/Sema/SemaChecking.cpp
13569

The control flow in this function is a little odd, but it isn't necessarily the same target; we could have entered one or more of the if statements above that modify the target, and we need to inspect the original target here.

Ah ofc, I missed that, thanks for clarifying.

13578–13582

can a test be added for this?

DavidTruby updated this revision to Diff 435553.Jun 9 2022, 7:52 AM

Remove redundant code

clang/lib/Sema/SemaChecking.cpp
13578–13582

It appears this code doesn't actually do anything as this condition is covered elsewhere (and tested below) so I've just removed it

c-rhodes accepted this revision.Jun 9 2022, 8:09 AM
c-rhodes added inline comments.
clang/lib/Sema/SemaChecking.cpp
13578–13582

It appears this code doesn't actually do anything as this condition is covered elsewhere (and tested below) so I've just removed it

Great! Thanks for investigating, can this code also be removed from the generic vector version this was copied from then? Just curious I won't let that hold up this patch.

This revision is now accepted and ready to land.Jun 9 2022, 8:09 AM
DavidTruby added inline comments.Jun 9 2022, 9:01 AM
clang/lib/Sema/SemaChecking.cpp
13578–13582

I don't think so, I believe the reason this isn't necessary here is that vector -> scalar casts are forbidden for SVE vectors but are allowed in specific cases for fixed width vectors, this warning is here for cases where it's allowed but nonsensical. That's at least my understanding