It was using the full size of the vector as the SrcBitWidth. This patch
changes the code to split G_ASSERT_ZEXT away from the others (G_INTTOPTR
/ G_PTRTOINT / G_ZEXT / G_TRUNC) which are simpler, and make the code
match the SDAG equivalent.
This forwards the KnownBits / SignBits from the scalar operand through
to the vector elements. The value is implicitly truncated if it is
larger than the vector element size. The change in
GISelValueTracking::computeNumSignBits allows scalable sign-bits using a
single element demanded elts, and brings it in line with the code in
ValueTracking and SDAG (and GISelValueTracking::getKnownBits). That was
the main motivation for adding this opcode, to prevent scalable vector
asserts.
This adds a GISelValueTrackingPrinterPass that can print the known bits
and sign bit of each def in a function. It is built on the new pass
manager and so adds a NPM GISelValueTrackingAnalysis, renaming the older
class to GISelValueTrackingAnalysisLegacy.
The first 2 functions from the AArch64GISelMITest are ported over to an
mir test to show it working. It also runs successfully on all files in
llvm/test/CodeGen/AArch64/GlobalISel/*.mir that are not invalid. It can
hopefully be used to test GlobalISel known bits analysis more directly
in common cases, without jumping through the hoops that the C++ tests
requires.