[X86] computeKnownBitsForTargetNode - add X86ISD::GF2P8AFFINEQB handling
X86ISD::GF2P8AFFINEQB nodes are being used for many shift/rotate style expansions, it'd be very useful if we can access the known bits to attempt additional folding afterward (e.g #190502).
This should only be attempted by somebody with access to a CPU with GFNI support to allow them to actually test this properly (although constexpr testing can help now that GFNI intrinsics support it).
Reference: https://www.intel.com/content/www/us/en/docs/intrinsics-guide/index.html#ig_expand=172,3053,2650,3028,3046,849,3516,3630,3054,3053,3054,4389,2239,2239,4602,205,196,4461,3954,1601,2140,417,2873,2851,2571,5840,2571,2927,3639&text=VGF2P8AFFINEQB
(see also GFNIAffine() in llvm-project\clang\lib\AST\ExprConstant.cpp)
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)
This should only be attempted by somebody with access to a CPU with GFNI support to allow them to actually test this properly (although constexpr testing can help now that GFNI intrinsics support it).
Reference: https://www.intel.com/content/www/us/en/docs/intrinsics-guide/index.html#ig_expand=172,3053,2650,3028,3046,849,3516,3630,3054,3053,3054,4389,2239,2239,4602,205,196,4461,3954,1601,2140,417,2873,2851,2571,5840,2571,2927,3639&text=VGF2P8AFFINEQB
(see also GFNIAffine() in llvm-project\clang\lib\AST\ExprConstant.cpp)
@llvm/issue-subscribers-backend-x86
Author: Simon Pilgrim (RKSimon)
This should only be attempted by somebody with access to a CPU with GFNI support to allow them to actually test this properly (although constexpr testing can help now that GFNI intrinsics support it).
Reference: https://www.intel.com/content/www/us/en/docs/intrinsics-guide/index.html#ig_expand=172,3053,2650,3028,3046,849,3516,3630,3054,3053,3054,4389,2239,2239,4602,205,196,4461,3954,1601,2140,417,2873,2851,2571,5840,2571,2927,3639&text=VGF2P8AFFINEQB
(see also GFNIAffine() in llvm-project\clang\lib\AST\ExprConstant.cpp)
@RKSimon can i work on this ?
@Ko496-glitch since you asked for suggestions, one performant software implementation of a affine is to calculate one bit per iteration for all bytes at once. It seems you can use assignment operators on the KnownBits struct to calculate both ones and zeros simultaneously, it allows for splats by the bit width to generate the needed constants for arbitrary vector sizes without code duplication:
- Splat the
ithrow within each matrix, to all its rows. Maybe using shift + masking + multiplication on the APInt fields? - AND with the vector KnownBits to isolate the bit which are "selected" by that row.
- Calculate the byte-wise parity by doing a cumulative xor:
x ^= x >> 1; x ^= x >> 2; x ^= x >> 4;. The least bit should contain that byte's parity. The shift can cross the byte boundary without issue. - OR that parity to the
7-i thbit position within the accumulator, which should initially be zero. - After 8 iterations, all accumulator bit should be computed. XOR that with the immediate splatted to all lanes.
@WalterKruger thank you so much for this, i will read this more in depth later today
@RKSimon Apologies, but i just checked and my pc does not have GFI support, it is an older version machine so testing wont be possible. You can reassign it but again sorry i should have checked this before asking to work on this
You might want to consider using SDE?
Hi @Ko496-glitch are you still working on this? I have a CPU with GFNI support if you would still like to reassign this task
Feel free to work,i am trying to figure this on intel SDE but we can always match our findings :)
@asadium hey just wanted to check in if you are active on this ? otherwise i can work on the PR
Yes go ahead, I haven't made substantial progress just yet
@RKSimon just wanted to inform i have started working on this, sorry for the delay i was taking care of something
Hi @Ko496-glitch are you still active on this? If not I can make a PR also
Hi @Ko496-glitch are you still active on this? If not I can make a PR also
Hi, yes please go ahead
Hey @asadium, are you still working on this?
Hi, yes. Feel free to ping me in 2 weeks if I haven't made any updates though : )