This is an archive of the discontinued LLVM Phabricator instance.

[PowerPC] Provide XL-compatible builtins in altivec.h
ClosedPublic

Authored by nemanjai on Apr 22 2021, 8:42 PM.

Details

Summary

There are some interfaces in altivec.h that are not compatible between Clang and XL (although Clang is compatible with GCC). Currently, we have found 3 but there may be others.

Clang/GCC signatures:

vector double vec_ctf(vector signed long long)
vector double vec_ctf(vector unsigned long long)
vector signed long long vec_cts(vector double)
vector unsigned long long vec_ctu(vector double)

XL signatures:

vector float vec_ctf(vector signed long long)
vector float vec_ctf(vector unsigned long long)
vector signed int vec_cts(vector double)
vector unsigned int vec_ctu(vector double)

This patch provides the XL behaviour under the __XL_COMPAT_ALTIVEC__ macro for users that rely on XL behaviour.

Diff Detail

Event Timeline

nemanjai created this revision.Apr 22 2021, 8:42 PM
nemanjai requested review of this revision.Apr 22 2021, 8:42 PM
Herald added a project: Restricted Project. · View Herald TranscriptApr 22 2021, 8:42 PM
cebowleratibm accepted this revision.Apr 23 2021, 6:47 AM
cebowleratibm added inline comments.
clang/test/CodeGen/builtins-ppc-xlcompat.c
3

Suggest adding an explicit -mcpu.

This revision is now accepted and ready to land.Apr 23 2021, 6:47 AM

LGTM

clang/test/CodeGen/builtins-ppc-xlcompat.c
7

[nit] remove extra space

jsji added a subscriber: jsji.Apr 23 2021, 7:59 AM
jsji added inline comments.
clang/lib/Headers/altivec.h
3055

This only affects VSX version right? If so, can we move #ifdef __XL_COMPAT_ALTIVEC__ into #ifdef __VSX__
Or even better only into the part of affected types, eg: vector unsinged long long?

3065

Can we also add comments about what is the major difference with and without __XL_COMPAT_ALTIVEC__ , for long term maintenance?

clang/test/CodeGen/builtins-ppc-xlcompat.c
9

Can we add a RUN line to test that novsx are not affected?

jsji added inline comments.Apr 23 2021, 8:01 AM
clang/lib/Headers/altivec.h
3065

Can we also add comments about what is the major difference with and without __XL_COMPAT_ALTIVEC__ , for long term maintenance?

I know they are in commit message, but I think comments in source code would be more helpful than in commit message. Thanks.

nemanjai added inline comments.Apr 23 2021, 9:00 AM
clang/lib/Headers/altivec.h
3055

Sure, I'll make the non-vsx version unconditional on __XL_COMPAT_ALTIVEC__.

3065

Will do.

clang/test/CodeGen/builtins-ppc-xlcompat.c
3

I'm not sure that works with cc1. It would probably neeed to be something like -target-cpu.

7

Oops, I'll fix it.

9

I don't think this is useful as that would be a duplicate of the tests in builtins-ppc-vsx.c.

This revision was landed with ongoing or failed builds.Apr 23 2021, 1:15 PM
This revision was automatically updated to reflect the committed changes.