[X86] Add i512 ADD/SUB expansion on AVX512 targets
Based off https://www.numberworld.org/y-cruncher/internals/addition.html we can implement i512 ISD::ADD/SUB handling inside X86TargetLowering::ReplaceNodeResults for subtargets that support useAVX512Regs - similar to what we've done for AND/OR/XOR.
The AVX512F variant seems to give a better base implementation than AVX512DQ, we can leave other combines to decide whether to move scalar ops (ADD/SHL) back to mask register ops (KADD/KSHIFT etc.).
We will need to use mayFoldIntoVector to check that its worthwhile to perform this as transferring integer data to the FPU unit can be expensive.
A later patch would be to add support for the carry-in/out handling (ISD::UADDO_CARRY etc.) as well for completely general multi-precision arithmetic - but basic i512 addition/subtraction should be enough for this ticket.
@llvm/issue-subscribers-backend-x86
Author: Simon Pilgrim (RKSimon)
The AVX512F variant seems to give a better base implementation than AVX512DQ, we can leave other combines to decide whether to move scalar ops (ADD/SHL) back to mask register ops (KADD/KSHIFT etc.).
We will need to use mayFoldIntoVector to check that its worthwhile to perform this as transferring integer data to the FPU unit can be expensive.
A later patch would be to add support for the carry-in/out handling (ISD::UADDO_CARRY etc.) as well for completely general multi-precision arithmetic - but basic i512 addition/subtraction should be enough for this ticket.
Hi!
This issue may be a good introductory issue for people new to working on LLVM. If you would like to work on this issue, your first steps are:
- Check that no other contributor is working on this issue. If someone is assigned to the issue or claimed to be working on it, ping the person. After one week without a response, the assignee may be changed.
- Leave a comment indicating that you are working on the issue, or just create a pull request after following the steps below. Mention this issue in the description of the pull request.
- Fix the issue locally.
- Run the test suite locally. Remember that the subdirectories under
test/create fine-grained testing targets, so you can e.g. usemake check-clang-astto only run Clang's AST tests. - Create a Git commit.
- Run
git clang-format HEAD~1to format your changes. - Open a pull request to the upstream repository on GitHub. Detailed instructions can be found in GitHub's documentation. Mention this issue in the description of the pull request.
If you have any further questions about this issue, don't hesitate to ask via a comment in the thread below.
@llvm/issue-subscribers-good-first-issue
Author: Simon Pilgrim (RKSimon)
The AVX512F variant seems to give a better base implementation than AVX512DQ, we can leave other combines to decide whether to move scalar ops (ADD/SHL) back to mask register ops (KADD/KSHIFT etc.).
We will need to use mayFoldIntoVector to check that its worthwhile to perform this as transferring integer data to the FPU unit can be expensive.
A later patch would be to add support for the carry-in/out handling (ISD::UADDO_CARRY etc.) as well for completely general multi-precision arithmetic - but basic i512 addition/subtraction should be enough for this ticket.
Hi @RKSimon :) Could you assign this issue to me, please :) ?
Hi @RKSimon Can you assign this issue to me,please :) ?
@Islam-Imad @Arka-009 have you either got an avx512 capable machine to test this please?
I'm on an AMD Ryzen 5 laptop. It supports AVX/AVX2 :[
is it doable to utilize a given tool to solve this problem ?
I'm not sure what you mean?
An emulator for example that support avx512 to test the correctness on it instead of my machine. e.g Intel SDE i don't have any experience with these tools to be honest.
We might have enough constexpr handling support for avx512 intrinsics to do basic testing of the original code, you can do that on Godbolt without avx512 support.
I'll start working on it and will reach out if I have any questions. Please assign this to me.
Using SDE is simple too, you can download it here and use like sde64 -skx -- YourApplication
Hi, I am interested in working on this issue. I am new to LLVM. Could you please guide me on which files or functions I should look at first?
Hi, I am interested in working on this issue. I am new to LLVM. Could you please guide me on which files or functions I should look at first?
This issue is assigned to me already and i am still working on it. you can find other issues here https://github.com/llvm/llvm-project/issues?q=is%3Aissue%20state%3Aopen%20label%3A%22good%20first%20issue%22%20no%3Aassignee
Using SDE is simple too, you can download it here and use like
sde64 -skx -- YourApplication
I have already used this tool to test the correctness of my code. If you have time to see the problem of store vectorization in the opened PR that would be great :) @phoebewang