Author: Jay Foad Date: 2021-01-14T14:02:43Z New Revision: 517196e569129677be32d6ebcfa57bac552268a4
URL: https://github.com/llvm/llvm-project/commit/517196e569129677be32d6ebcfa57bac552268a4 DIFF: https://github.com/llvm/llvm-project/commit/517196e569129677be32d6ebcfa57bac552268a4.diff LOG: [Analysis,CodeGen] Make use of KnownBits::makeConstant. NFC. Differential Revision: https://reviews.llvm.org/D94588 Added: Modified: llvm/lib/Analysis/ValueTracking.cpp llvm/lib/CodeGen/GlobalISel/GISelKnownBits.cpp llvm/lib/CodeGen/SelectionDAG/FunctionLoweringInfo.cpp llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp Removed: ################################################################################ diff --git a/llvm/lib/Analysis/ValueTracking.cpp b/llvm/lib/Analysis/ValueTracking.cpp index b138caa05610..61c992d0eedf 100644 --- a/llvm/lib/Analysis/ValueTracking.cpp +++ b/llvm/lib/Analysis/ValueTracking.cpp @@ -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. diff --git a/llvm/lib/CodeGen/GlobalISel/GISelKnownBits.cpp b/llvm/lib/CodeGen/GlobalISel/GISelKnownBits.cpp index 64c7fb486493..aac7a73e858f 100644 --- a/llvm/lib/CodeGen/GlobalISel/GISelKnownBits.cpp +++ b/llvm/lib/CodeGen/GlobalISel/GISelKnownBits.cpp @@ -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: { diff --git a/llvm/lib/CodeGen/SelectionDAG/FunctionLoweringInfo.cpp b/llvm/lib/CodeGen/SelectionDAG/FunctionLoweringInfo.cpp index 0b830f462c90..32a4f60df097 100644 --- a/llvm/lib/CodeGen/SelectionDAG/FunctionLoweringInfo.cpp +++ b/llvm/lib/CodeGen/SelectionDAG/FunctionLoweringInfo.cpp @@ -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."); diff --git a/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp b/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp index e080408bbe42..7084ab68524b 100644 --- a/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp +++ b/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp @@ -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()); } } } diff --git a/llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp b/llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp index 173e45a4b18e..6ae0a39962b3 100644 --- a/llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp +++ b/llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp @@ -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; } _______________________________________________ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits