This is an archive of the discontinued LLVM Phabricator instance.

[PowerPC] Implement cmplxl builtins
ClosedPublic

Authored by Conanap on Jul 30 2021, 1:28 AM.

Details

Reviewers
nemanjai
NeHuang
Group Reviewers
Restricted Project
Commits
rG9d4faa8ac3e7: [PowerPC] Implement cmplxl builtins
Summary

This patch implements the builtins for cmplxl by utilising
__builtin_complex. This builtin is implemented to match XL
functionality.

Diff Detail

Event Timeline

Conanap created this revision.Jul 30 2021, 1:28 AM
Conanap requested review of this revision.Jul 30 2021, 1:28 AM
Herald added projects: Restricted Project, Restricted Project. · View Herald TranscriptJul 30 2021, 1:28 AM
Conanap added reviewers: Restricted Project, nemanjai.Jul 30 2021, 1:28 AM
nemanjai requested changes to this revision.Jul 30 2021, 5:49 AM
nemanjai added inline comments.
clang/include/clang/Basic/BuiltinsPPC.def
146

Please remove this. The preprocessor will replace this and the builtin call will never make it to the front end.

clang/lib/Basic/Targets/PPC.cpp
238

I don't see a compelling reason to have this. Users that want this functionality in new code (that doesn't already use __cmplxl) can simply use __builtin_complex.

clang/test/CodeGen/builtins-ppc-xlcompat-complex.c
45

We really only need this test case and we should be able to just add it to one of the existing XL-compat clang test cases.

llvm/test/CodeGen/PowerPC/builtins-ppc-xlcompat-complex-32bit-only.ll
1

I don't think we need the back end tests. No new IR is produced in this patch.

This revision now requires changes to proceed.Jul 30 2021, 5:49 AM
NeHuang added inline comments.
clang/test/CodeGen/builtins-ppc-xlcompat-complex.c
1

// REQUIRES: powerpc-registered-target

1

Question: why do we need -O2 for this builtin?

llvm/test/CodeGen/PowerPC/builtins-ppc-xlcompat-complex-32bit-only.ll
1

+1

amyk added a subscriber: amyk.Jul 30 2021, 1:30 PM
amyk added inline comments.
clang/test/CodeGen/builtins-ppc-xlcompat-complex.c
35

I think it would probably be better not to hardcode the variable names in the tests.

Conanap updated this revision to Diff 364223.Aug 4 2021, 12:45 PM
Conanap marked 6 inline comments as done.

Removed backend tests, removed some uneeded definitions,
updated frontend test with regex for variable names.

Conanap marked an inline comment as done.Aug 4 2021, 12:45 PM
Conanap added inline comments.
clang/test/CodeGen/builtins-ppc-xlcompat-complex.c
1

it's not required, but removes a lot of the extra load and stores that make the test cases longer unnecessarily. I can change it to O1 if preferred.

NeHuang added inline comments.Aug 6 2021, 7:32 AM
clang/test/CodeGen/builtins-ppc-xlcompat-complex.c
45

As suggest above, can we add the test case __cmplxl to one of the existing clang test file builtins-ppc-xlcompat-cmplx.c? You can auto generate the CHECKS using utils/update_cc_test_checks.py to avoid hardcoding the variable names.

nemanjai added inline comments.Aug 7 2021, 9:45 AM
clang/test/CodeGen/builtins-ppc-xlcompat-complex.c
1

I prefer that front end tests should test what the front end does. The front end does not perform optimizations, the optimizer does. So the front end tests should not include optimization options (even though I do realize that adding -O<N> reduces the size of the produced code).
There is no need to add unnecessary churn in front end tests if the optimizer changes.

Conanap updated this revision to Diff 365289.Aug 9 2021, 2:34 PM
Conanap marked 3 inline comments as done.

Merged the test case into the existing cmplx test

Conanap updated this revision to Diff 365596.Aug 10 2021, 1:06 PM

Removed unintended change

nemanjai accepted this revision.Aug 10 2021, 2:44 PM

LGTM.

This revision is now accepted and ready to land.Aug 10 2021, 2:44 PM
NeHuang accepted this revision.Aug 11 2021, 5:56 AM

LGTM

This revision was landed with ongoing or failed builds.Aug 19 2021, 7:39 PM
This revision was automatically updated to reflect the committed changes.