Skip to content

Commit 3fb08d1

Browse files
committed
[SDAG] Address post commit review feedback from f8c63a7
The major change is falling through to ComputeKnownBits when we don't have an implementation of ComputeNumSignBits due to conservatism over scalable vectors. Right now, we're mostly conservative in the same cases, but this allows our results to improve when we change ComputeKnownBits without also needing to improve ComputeNumSignBits at the same time.
1 parent 8dfd883 commit 3fb08d1

File tree

1 file changed

+12
-13
lines changed

1 file changed

+12
-13
lines changed

llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4058,7 +4058,7 @@ unsigned SelectionDAG::ComputeNumSignBits(SDValue Op, const APInt &DemandedElts,
40584058

40594059
case ISD::BITCAST: {
40604060
if (VT.isScalableVector())
4061-
return 1;
4061+
break;
40624062
SDValue N0 = Op.getOperand(0);
40634063
EVT SrcVT = N0.getValueType();
40644064
unsigned SrcBits = SrcVT.getScalarSizeInBits();
@@ -4117,7 +4117,7 @@ unsigned SelectionDAG::ComputeNumSignBits(SDValue Op, const APInt &DemandedElts,
41174117
return std::max(Tmp, Tmp2);
41184118
case ISD::SIGN_EXTEND_VECTOR_INREG: {
41194119
if (VT.isScalableVector())
4120-
return 1;
4120+
break;
41214121
SDValue Src = Op.getOperand(0);
41224122
EVT SrcVT = Src.getValueType();
41234123
APInt DemandedSrcElts = DemandedElts.zext(SrcVT.getVectorNumElements());
@@ -4336,7 +4336,7 @@ unsigned SelectionDAG::ComputeNumSignBits(SDValue Op, const APInt &DemandedElts,
43364336
}
43374337
case ISD::EXTRACT_ELEMENT: {
43384338
if (VT.isScalableVector())
4339-
return 1;
4339+
break;
43404340
const int KnownSign = ComputeNumSignBits(Op.getOperand(0), Depth+1);
43414341
const int BitWidth = Op.getValueSizeInBits();
43424342
const int Items = Op.getOperand(0).getValueSizeInBits() / BitWidth;
@@ -4351,7 +4351,7 @@ unsigned SelectionDAG::ComputeNumSignBits(SDValue Op, const APInt &DemandedElts,
43514351
}
43524352
case ISD::INSERT_VECTOR_ELT: {
43534353
if (VT.isScalableVector())
4354-
return 1;
4354+
break;
43554355
// If we know the element index, split the demand between the
43564356
// source vector and the inserted element, otherwise assume we need
43574357
// the original demanded vector elements and the value.
@@ -4382,8 +4382,7 @@ unsigned SelectionDAG::ComputeNumSignBits(SDValue Op, const APInt &DemandedElts,
43824382
return Tmp;
43834383
}
43844384
case ISD::EXTRACT_VECTOR_ELT: {
4385-
if (VT.isScalableVector())
4386-
return 1;
4385+
assert(!VT.isScalableVector());
43874386
SDValue InVec = Op.getOperand(0);
43884387
SDValue EltNo = Op.getOperand(1);
43894388
EVT VecVT = InVec.getValueType();
@@ -4423,7 +4422,7 @@ unsigned SelectionDAG::ComputeNumSignBits(SDValue Op, const APInt &DemandedElts,
44234422
}
44244423
case ISD::CONCAT_VECTORS: {
44254424
if (VT.isScalableVector())
4426-
return 1;
4425+
break;
44274426
// Determine the minimum number of sign bits across all demanded
44284427
// elts of the input vectors. Early out if the result is already 1.
44294428
Tmp = std::numeric_limits<unsigned>::max();
@@ -4443,7 +4442,7 @@ unsigned SelectionDAG::ComputeNumSignBits(SDValue Op, const APInt &DemandedElts,
44434442
}
44444443
case ISD::INSERT_SUBVECTOR: {
44454444
if (VT.isScalableVector())
4446-
return 1;
4445+
break;
44474446
// Demand any elements from the subvector and the remainder from the src its
44484447
// inserted into.
44494448
SDValue Src = Op.getOperand(0);
@@ -4551,12 +4550,12 @@ unsigned SelectionDAG::ComputeNumSignBits(SDValue Op, const APInt &DemandedElts,
45514550
Opcode == ISD::INTRINSIC_VOID) {
45524551
// TODO: This can probably be removed once target code is audited. This
45534552
// is here purely to reduce patch size and review complexity.
4554-
if (VT.isScalableVector())
4555-
return 1;
4556-
unsigned NumBits =
4553+
if (!VT.isScalableVector()) {
4554+
unsigned NumBits =
45574555
TLI->ComputeNumSignBitsForTargetNode(Op, DemandedElts, *this, Depth);
4558-
if (NumBits > 1)
4559-
FirstAnswer = std::max(FirstAnswer, NumBits);
4556+
if (NumBits > 1)
4557+
FirstAnswer = std::max(FirstAnswer, NumBits);
4558+
}
45604559
}
45614560

45624561
// Finally, if we can prove that the top bits of the result are 0's or 1's,

0 commit comments

Comments
 (0)