diff --git a/llvm/lib/Analysis/ValueTracking.cpp b/llvm/lib/Analysis/ValueTracking.cpp --- a/llvm/lib/Analysis/ValueTracking.cpp +++ b/llvm/lib/Analysis/ValueTracking.cpp @@ -1337,8 +1337,8 @@ 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 @@ /*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 @@ 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 --- a/llvm/lib/CodeGen/GlobalISel/GISelKnownBits.cpp +++ b/llvm/lib/CodeGen/GlobalISel/GISelKnownBits.cpp @@ -217,8 +217,7 @@ 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 --- a/llvm/lib/CodeGen/SelectionDAG/FunctionLoweringInfo.cpp +++ b/llvm/lib/CodeGen/SelectionDAG/FunctionLoweringInfo.cpp @@ -458,8 +458,7 @@ if (ConstantInt *CI = dyn_cast(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 --- a/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp +++ b/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp @@ -3134,13 +3134,10 @@ } } else if (BitWidth == CstTy->getPrimitiveSizeInBits()) { if (auto *CInt = dyn_cast(Cst)) { - const APInt &Value = CInt->getValue(); - Known.One = Value; - Known.Zero = ~Value; + Known = KnownBits::makeConstant(CInt->getValue()); } else if (auto *CFP = dyn_cast(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 --- a/llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp +++ b/llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp @@ -912,15 +912,14 @@ if (Op.getOpcode() == ISD::Constant) { // We know all of the bits for a constant! - Known.One = cast(Op)->getAPIntValue(); - Known.Zero = ~Known.One; + Known = KnownBits::makeConstant(cast(Op)->getAPIntValue()); return false; } if (Op.getOpcode() == ISD::ConstantFP) { // We know all of the bits for a floating point constant! - Known.One = cast(Op)->getValueAPF().bitcastToAPInt(); - Known.Zero = ~Known.One; + Known = KnownBits::makeConstant( + cast(Op)->getValueAPF().bitcastToAPInt()); return false; }