[DAG] computeKnownBits/ComputeNumSignBits - add ISD::VECTOR_COMPRESS integer vector types handling and test coverage
/// VECTOR_COMPRESS(Vec, Mask, Passthru)
/// consecutively place vector elements based on mask
/// e.g., vec = {A, B, C, D} and mask = {1, 0, 1, 0}
/// --> {A, C, ?, ?} where ? is undefined
/// If passthru is defined, ?s are replaced with elements from passthru.
/// If passthru is undef, ?s remain undefined.
VECTOR_COMPRESS,
computeKnownBits should return the common knownbits between the Vec and PassThru values
ComputeNumSignBits should return the minimum of the num signbits of the Vec and PassThru values
If PassThru is undef you should earlyout and return knownbits = unknown / signbits = 1
You should probably ignore the computeKnownBits/ComputeNumSignBits DemandedElts parameter and analyse all vector elements of both operands.
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)
ComputeNumSignBits should return the minimum of the num signbits of the Vec and PassThru values
If PassThru is undef you should earlyout and return knownbits = unknown / signbits = 1
You should probably ignore the computeKnownBits/ComputeNumSignBits DemandedElts parameter and analyse all vector elements of both operands.
Hi, I would like to contribute. May I be assigned this issue @RKSimon?
Hey @RKSimon, just for some clarification, can the mask vector be ignored, or should that be taken into consideration?
Yes under most circumstances the mask must ignored and all elements of the other two sources demanded. If the mask is constant it's possible to compute the different demanded elements for the two sources but that can be a TODO for now.
My apologies but are there any resources for writing tests? Any test cases for the other computeKnownBits isd operations? Thanks! @RKSimon
Plenty a good starter would be this one for knownbits:
define <8 x i64> @test_compress_zext_v8i16_8i64(<8 x i16> %vec, <8 x i1> %mask, <8 x i64> %passthru) nounwind {
%xvec = zext <8 x i16> %vec to <8 x i64> ; 0 -> 65535
%xpassthru = and <8 x i64> %passthru, splat (i64 3) ; 0 -> 3
%out = call <8 x i64> @llvm.experimental.vector.compress(<8 x i64> %xvec, <8 x i1> %mask, <8 x i64> %xpassthru)
%res = and <8 x i64> %out, splat (i64 65535) unnecessary - %out guaranteed to be 0 -> 65535
ret <8 x i64> %res
}