1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-22 18:54:02 +01:00

[Analysis,CodeGen] Make use of KnownBits::makeConstant. NFC.

Differential Revision: https://reviews.llvm.org/D94588
This commit is contained in:
Jay Foad 2021-01-13 11:25:35 +00:00
parent 3959fb7bf5
commit 541d0407ff
5 changed files with 12 additions and 21 deletions

View File

@ -1337,8 +1337,8 @@ static void computeKnownBitsFromOperator(const Operator *I,
AccConstIndices += IndexConst.sextOrTrunc(BitWidth);
continue;
} else {
ScalingFactor.Zero = ~TypeSizeInBytes;
ScalingFactor.One = TypeSizeInBytes;
ScalingFactor =
KnownBits::makeConstant(APInt(IndexBitWidth, TypeSizeInBytes));
}
IndexBits = KnownBits::computeForMul(IndexBits, ScalingFactor);
@ -1353,9 +1353,7 @@ static void computeKnownBitsFromOperator(const Operator *I,
/*Add=*/true, /*NSW=*/false, Known, IndexBits);
}
if (!Known.isUnknown() && !AccConstIndices.isNullValue()) {
KnownBits Index(BitWidth);
Index.Zero = ~AccConstIndices;
Index.One = AccConstIndices;
KnownBits Index = KnownBits::makeConstant(AccConstIndices);
Known = KnownBits::computeForAddSub(
/*Add=*/true, /*NSW=*/false, Known, Index);
}
@ -1818,8 +1816,7 @@ void computeKnownBits(const Value *V, const APInt &DemandedElts,
const APInt *C;
if (match(V, m_APInt(C))) {
// We know all of the bits for a scalar constant or a splat vector constant!
Known.One = *C;
Known.Zero = ~Known.One;
Known = KnownBits::makeConstant(*C);
return;
}
// Null and aggregate-zero are all-zeros.

View File

@ -217,8 +217,7 @@ void GISelKnownBits::computeKnownBitsImpl(Register R, KnownBits &Known,
auto CstVal = getConstantVRegVal(R, MRI);
if (!CstVal)
break;
Known.One = *CstVal;
Known.Zero = ~Known.One;
Known = KnownBits::makeConstant(*CstVal);
break;
}
case TargetOpcode::G_FRAME_INDEX: {

View File

@ -458,8 +458,7 @@ void FunctionLoweringInfo::ComputePHILiveOutRegInfo(const PHINode *PN) {
if (ConstantInt *CI = dyn_cast<ConstantInt>(V)) {
APInt Val = CI->getValue().zextOrTrunc(BitWidth);
DestLOI.NumSignBits = Val.getNumSignBits();
DestLOI.Known.Zero = ~Val;
DestLOI.Known.One = Val;
DestLOI.Known = KnownBits::makeConstant(Val);
} else {
assert(ValueMap.count(V) && "V should have been placed in ValueMap when its"
"CopyToReg node was created.");

View File

@ -3134,13 +3134,10 @@ KnownBits SelectionDAG::computeKnownBits(SDValue Op, const APInt &DemandedElts,
}
} else if (BitWidth == CstTy->getPrimitiveSizeInBits()) {
if (auto *CInt = dyn_cast<ConstantInt>(Cst)) {
const APInt &Value = CInt->getValue();
Known.One = Value;
Known.Zero = ~Value;
Known = KnownBits::makeConstant(CInt->getValue());
} else if (auto *CFP = dyn_cast<ConstantFP>(Cst)) {
APInt Value = CFP->getValueAPF().bitcastToAPInt();
Known.One = Value;
Known.Zero = ~Value;
Known =
KnownBits::makeConstant(CFP->getValueAPF().bitcastToAPInt());
}
}
}

View File

@ -912,15 +912,14 @@ bool TargetLowering::SimplifyDemandedBits(
if (Op.getOpcode() == ISD::Constant) {
// We know all of the bits for a constant!
Known.One = cast<ConstantSDNode>(Op)->getAPIntValue();
Known.Zero = ~Known.One;
Known = KnownBits::makeConstant(cast<ConstantSDNode>(Op)->getAPIntValue());
return false;
}
if (Op.getOpcode() == ISD::ConstantFP) {
// We know all of the bits for a floating point constant!
Known.One = cast<ConstantFPSDNode>(Op)->getValueAPF().bitcastToAPInt();
Known.Zero = ~Known.One;
Known = KnownBits::makeConstant(
cast<ConstantFPSDNode>(Op)->getValueAPF().bitcastToAPInt());
return false;
}