mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-22 18:54:02 +01:00
[CodeGen] Fix ComputeNumSignBits for scalable vectors
When trying to calculate the number of sign bits for scalable vectors we should just bail out for now and pretend we know nothing. Differential Revision: https://reviews.llvm.org/D81093
This commit is contained in:
parent
bab5ba74e9
commit
f5847de3ec
@ -3539,6 +3539,11 @@ bool SelectionDAG::isKnownToBeAPowerOfTwo(SDValue Val) const {
|
||||
|
||||
unsigned SelectionDAG::ComputeNumSignBits(SDValue Op, unsigned Depth) const {
|
||||
EVT VT = Op.getValueType();
|
||||
|
||||
// TODO: Assume we don't know anything for now.
|
||||
if (VT.isScalableVector())
|
||||
return 1;
|
||||
|
||||
APInt DemandedElts = VT.isVector()
|
||||
? APInt::getAllOnesValue(VT.getVectorNumElements())
|
||||
: APInt(1, 1);
|
||||
@ -3562,7 +3567,7 @@ unsigned SelectionDAG::ComputeNumSignBits(SDValue Op, const APInt &DemandedElts,
|
||||
if (Depth >= MaxRecursionDepth)
|
||||
return 1; // Limit search depth.
|
||||
|
||||
if (!DemandedElts)
|
||||
if (!DemandedElts || VT.isScalableVector())
|
||||
return 1; // No demanded elts, better to assume we don't know anything.
|
||||
|
||||
unsigned Opcode = Op.getOpcode();
|
||||
|
@ -146,6 +146,20 @@ TEST_F(AArch64SelectionDAGTest, ComputeNumSignBits_SIGN_EXTEND_VECTOR_INREG) {
|
||||
EXPECT_EQ(DAG->ComputeNumSignBits(Op, DemandedElts), 15u);
|
||||
}
|
||||
|
||||
TEST_F(AArch64SelectionDAGTest, ComputeNumSignBitsSVE_SIGN_EXTEND_VECTOR_INREG) {
|
||||
if (!TM)
|
||||
return;
|
||||
SDLoc Loc;
|
||||
auto Int8VT = EVT::getIntegerVT(Context, 8);
|
||||
auto Int16VT = EVT::getIntegerVT(Context, 16);
|
||||
auto InVecVT = EVT::getVectorVT(Context, Int8VT, 4, /*IsScalable=*/true);
|
||||
auto OutVecVT = EVT::getVectorVT(Context, Int16VT, 2, /*IsScalable=*/true);
|
||||
auto InVec = DAG->getConstant(1, Loc, InVecVT);
|
||||
auto Op = DAG->getNode(ISD::SIGN_EXTEND_VECTOR_INREG, Loc, OutVecVT, InVec);
|
||||
auto DemandedElts = APInt(2, 3);
|
||||
EXPECT_EQ(DAG->ComputeNumSignBits(Op, DemandedElts), 1u);
|
||||
}
|
||||
|
||||
TEST_F(AArch64SelectionDAGTest, ComputeNumSignBits_EXTRACT_SUBVECTOR) {
|
||||
if (!TM)
|
||||
return;
|
||||
|
Loading…
Reference in New Issue
Block a user