[RFC][IR] Remove Constant::isZeroValue (#181521)
`Constant::isZeroValue` currently behaves same as `Constant::isNullValue` for all types except floating-point, where it additionally returns true for negative zero (`-0.0`). However, in practice, almost all callers operate on integer/pointer types where the two are equivalent, and the few FP-relevant callers have no meaningful dependence on the `-0.0` behavior. This PR removes `isZeroValue` to eliminate the confusing API. All callers are changed to `isNullValue` with no test failures. `isZeroValue` will be reintroduced in a future change with clearer semantics: when null pointers may have non-zero bit patterns, `isZeroValue` will check for bitwise-all-zeros, while `isNullValue` will check for the semantic null (which may be non-zero).
This commit is contained in:
parent
0f7791e9d8
commit
70905e0afa
@ -1070,7 +1070,7 @@ static llvm::Constant *constStructWithPadding(CodeGenModule &CGM,
|
||||
Values.push_back(patternOrZeroFor(CGM, isPattern, PadTy));
|
||||
}
|
||||
llvm::Constant *CurOp;
|
||||
if (constant->isZeroValue())
|
||||
if (constant->isNullValue())
|
||||
CurOp = llvm::Constant::getNullValue(STy->getElementType(i));
|
||||
else
|
||||
CurOp = cast<llvm::Constant>(constant->getAggregateElement(i));
|
||||
@ -2023,7 +2023,7 @@ void CodeGenFunction::EmitAutoVarInit(const AutoVarEmission &emission) {
|
||||
D.mightBeUsableInConstantExpressions(getContext())) {
|
||||
assert(!capturedByInit && "constant init contains a capturing block?");
|
||||
constant = ConstantEmitter(*this).tryEmitAbstractForInitializer(D);
|
||||
if (constant && !constant->isZeroValue() &&
|
||||
if (constant && !constant->isNullValue() &&
|
||||
(trivialAutoVarInit !=
|
||||
LangOptions::TrivialAutoVarInitKind::Uninitialized)) {
|
||||
IsPattern isPattern =
|
||||
|
||||
@ -916,7 +916,7 @@ static llvm::Constant *pointerAuthResignConstant(
|
||||
return nullptr;
|
||||
|
||||
assert(CPA->getKey()->getZExtValue() == CurAuthInfo.getKey() &&
|
||||
CPA->getAddrDiscriminator()->isZeroValue() &&
|
||||
CPA->getAddrDiscriminator()->isNullValue() &&
|
||||
CPA->getDiscriminator() == CurAuthInfo.getDiscriminator() &&
|
||||
"unexpected key or discriminators");
|
||||
|
||||
|
||||
@ -72,6 +72,12 @@ Changes to the LLVM IR
|
||||
Changes to LLVM infrastructure
|
||||
------------------------------
|
||||
|
||||
* Removed ``Constant::isZeroValue``. It was functionally identical to
|
||||
``Constant::isNullValue`` for all types except floating-point negative
|
||||
zero. All callers should use ``isNullValue`` instead. ``isZeroValue``
|
||||
will be reintroduced in the future with bitwise-all-zeros semantics
|
||||
to support non-zero null pointers.
|
||||
|
||||
* Removed TypePromoteFloat legalization from SelectionDAG
|
||||
|
||||
Changes to building LLVM
|
||||
|
||||
@ -69,9 +69,6 @@ public:
|
||||
/// getZeroValueForNegation.
|
||||
LLVM_ABI bool isNegativeZeroValue() const;
|
||||
|
||||
/// Return true if the value is negative zero or null value.
|
||||
LLVM_ABI bool isZeroValue() const;
|
||||
|
||||
/// Return true if the value is not the smallest signed value, or,
|
||||
/// for vectors, does not contain smallest signed value elements.
|
||||
LLVM_ABI bool isNotMinSignedValue() const;
|
||||
|
||||
@ -630,9 +630,8 @@ computeUnlikelySuccessors(const BasicBlock *BB, Loop *L,
|
||||
CI->getPredicate(), CmpLHSConst, CmpConst, DL);
|
||||
// If the result means we don't branch to the block then that block is
|
||||
// unlikely.
|
||||
if (Result &&
|
||||
((Result->isZeroValue() && B == BI->getSuccessor(0)) ||
|
||||
(Result->isOneValue() && B == BI->getSuccessor(1))))
|
||||
if (Result && ((Result->isNullValue() && B == BI->getSuccessor(0)) ||
|
||||
(Result->isOneValue() && B == BI->getSuccessor(1))))
|
||||
UnlikelyBlocks.insert(B);
|
||||
}
|
||||
}
|
||||
|
||||
@ -3133,7 +3133,7 @@ static Constant *ConstantFoldScalarCall1(StringRef Name,
|
||||
break;
|
||||
|
||||
case Intrinsic::wasm_anytrue:
|
||||
return Op->isZeroValue() ? ConstantInt::get(Ty, 0)
|
||||
return Op->isNullValue() ? ConstantInt::get(Ty, 0)
|
||||
: ConstantInt::get(Ty, 1);
|
||||
|
||||
case Intrinsic::wasm_alltrue:
|
||||
@ -3142,7 +3142,7 @@ static Constant *ConstantFoldScalarCall1(StringRef Name,
|
||||
for (unsigned I = 0; I != E; ++I) {
|
||||
Constant *Elt = Op->getAggregateElement(I);
|
||||
// Return false as soon as we find a non-true element.
|
||||
if (Elt && Elt->isZeroValue())
|
||||
if (Elt && Elt->isNullValue())
|
||||
return ConstantInt::get(Ty, 0);
|
||||
// Bail as soon as we find an element we cannot prove to be true.
|
||||
if (!Elt || !isa<ConstantInt>(Elt))
|
||||
|
||||
@ -553,7 +553,7 @@ static bool isZero(Value *V, const DataLayout &DL, DominatorTree *DT,
|
||||
if (!C)
|
||||
return false;
|
||||
|
||||
if (C->isZeroValue())
|
||||
if (C->isNullValue())
|
||||
return true;
|
||||
|
||||
// For a vector, KnownZero will only be true if all values are zero, so check
|
||||
|
||||
@ -41,7 +41,7 @@ Value *llvm::emitGEPOffset(IRBuilderBase *Builder, const DataLayout &DL,
|
||||
++i, ++GTI) {
|
||||
Value *Op = *i;
|
||||
if (Constant *OpC = dyn_cast<Constant>(Op)) {
|
||||
if (OpC->isZeroValue())
|
||||
if (OpC->isNullValue())
|
||||
continue;
|
||||
|
||||
// Handle a struct index, which adds its field offset to the pointer.
|
||||
|
||||
@ -152,7 +152,7 @@ static bool CanProveNotTakenFirstIteration(const BasicBlock *ExitBlock,
|
||||
if (!SimpleCst)
|
||||
return false;
|
||||
if (ExitBlock == BI->getSuccessor(0))
|
||||
return SimpleCst->isZeroValue();
|
||||
return SimpleCst->isNullValue();
|
||||
assert(ExitBlock == BI->getSuccessor(1) && "implied by above");
|
||||
return SimpleCst->isAllOnesValue();
|
||||
}
|
||||
|
||||
@ -9641,7 +9641,7 @@ ScalarEvolution::ExitLimit ScalarEvolution::computeShiftCompareExitLimit(
|
||||
assert(Result->getType()->isIntegerTy(1) &&
|
||||
"Otherwise cannot be an operand to a branch instruction");
|
||||
|
||||
if (Result->isZeroValue()) {
|
||||
if (Result->isNullValue()) {
|
||||
unsigned BitWidth = getTypeSizeInBits(RHS->getType());
|
||||
const SCEV *UpperBound =
|
||||
getConstant(getEffectiveSCEVType(RHS->getType()), BitWidth);
|
||||
|
||||
@ -1725,7 +1725,7 @@ static void computeKnownBitsFromOperator(const Operator *I,
|
||||
|
||||
// Handle case when index is zero.
|
||||
Constant *CIndex = dyn_cast<Constant>(Index);
|
||||
if (CIndex && CIndex->isZeroValue())
|
||||
if (CIndex && CIndex->isNullValue())
|
||||
continue;
|
||||
|
||||
if (StructType *STy = GTI.getStructTypeOrNull()) {
|
||||
|
||||
@ -2431,7 +2431,7 @@ void ComplexDeinterleavingGraph::processReductionSingle(
|
||||
|
||||
Value *NewInit = nullptr;
|
||||
if (auto *C = dyn_cast<Constant>(Init)) {
|
||||
if (C->isZeroValue())
|
||||
if (C->isNullValue())
|
||||
NewInit = Constant::getNullValue(NewVTy);
|
||||
}
|
||||
|
||||
|
||||
@ -572,7 +572,7 @@ static void getGapMask(const Constant &MaskConst, unsigned Factor,
|
||||
bool AllZero = true;
|
||||
for (unsigned Idx = 0U; Idx < LeafMaskLen; ++Idx) {
|
||||
Constant *C = MaskConst.getAggregateElement(F + Idx * Factor);
|
||||
if (!C->isZeroValue()) {
|
||||
if (!C->isNullValue()) {
|
||||
AllZero = false;
|
||||
break;
|
||||
}
|
||||
@ -594,7 +594,7 @@ static std::pair<Value *, APInt> getMask(Value *WideMask, unsigned Factor,
|
||||
// Check if all the intrinsic arguments are the same, except those that
|
||||
// are zeros, which we mark as gaps in the gap mask.
|
||||
for (auto [Idx, Arg] : enumerate(IMI->args())) {
|
||||
if (auto *C = dyn_cast<Constant>(Arg); C && C->isZeroValue()) {
|
||||
if (auto *C = dyn_cast<Constant>(Arg); C && C->isNullValue()) {
|
||||
GapMask.clearBit(Idx);
|
||||
continue;
|
||||
}
|
||||
|
||||
@ -338,7 +338,7 @@ void InstModificationIRStrategy::mutate(Instruction &Inst,
|
||||
// constant 0.
|
||||
Value *Operand = Inst.getOperand(0);
|
||||
if (Constant *C = dyn_cast<Constant>(Operand)) {
|
||||
if (!C->isZeroValue()) {
|
||||
if (!C->isNullValue()) {
|
||||
ShuffleItems = {0, 1};
|
||||
}
|
||||
}
|
||||
|
||||
@ -4871,7 +4871,7 @@ static void upgradeDbgIntrinsicToDbgRecord(StringRef Name, CallBase *CI) {
|
||||
if (CI->arg_size() == 4) {
|
||||
auto *Offset = dyn_cast_or_null<Constant>(CI->getArgOperand(1));
|
||||
// Nonzero offset dbg.values get dropped without a replacement.
|
||||
if (!Offset || !Offset->isZeroValue())
|
||||
if (!Offset || !Offset->isNullValue())
|
||||
return;
|
||||
VarOp = 2;
|
||||
ExprOp = 3;
|
||||
@ -5195,7 +5195,7 @@ void llvm::UpgradeIntrinsicCall(CallBase *CI, Function *NewFn) {
|
||||
assert(CI->arg_size() == 4);
|
||||
// Drop nonzero offsets instead of attempting to upgrade them.
|
||||
if (auto *Offset = dyn_cast_or_null<Constant>(CI->getArgOperand(1)))
|
||||
if (Offset->isZeroValue()) {
|
||||
if (Offset->isNullValue()) {
|
||||
NewCall = Builder.CreateCall(
|
||||
NewFn,
|
||||
{CI->getArgOperand(0), CI->getArgOperand(2), CI->getArgOperand(3)});
|
||||
|
||||
@ -71,22 +71,6 @@ bool Constant::isNegativeZeroValue() const {
|
||||
return isNullValue();
|
||||
}
|
||||
|
||||
// Return true iff this constant is positive zero (floating point), negative
|
||||
// zero (floating point), or a null value.
|
||||
bool Constant::isZeroValue() const {
|
||||
// Floating point values have an explicit -0.0 value.
|
||||
if (const ConstantFP *CFP = dyn_cast<ConstantFP>(this))
|
||||
return CFP->isZero();
|
||||
|
||||
// Check for constant splat vectors of 1 values.
|
||||
if (getType()->isVectorTy())
|
||||
if (const auto *SplatCFP = dyn_cast_or_null<ConstantFP>(getSplatValue()))
|
||||
return SplatCFP->isZero();
|
||||
|
||||
// Otherwise, just use +0.0.
|
||||
return isNullValue();
|
||||
}
|
||||
|
||||
bool Constant::isNullValue() const {
|
||||
// 0 is null.
|
||||
if (const ConstantInt *CI = dyn_cast<ConstantInt>(this))
|
||||
@ -752,7 +736,7 @@ static bool constantIsDead(const Constant *C, bool RemoveDeadUsers) {
|
||||
ReplaceableMetadataImpl::SalvageDebugInfo(*C);
|
||||
const_cast<Constant *>(C)->destroyConstant();
|
||||
}
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@ -2374,7 +2374,7 @@ static void setAssignmentTrackingModuleFlag(Module &M) {
|
||||
|
||||
static bool getAssignmentTrackingModuleFlag(const Module &M) {
|
||||
Metadata *Value = M.getModuleFlag(AssignmentTrackingModuleFlag);
|
||||
return Value && !cast<ConstantAsMetadata>(Value)->getValue()->isZeroValue();
|
||||
return Value && !cast<ConstantAsMetadata>(Value)->getValue()->isNullValue();
|
||||
}
|
||||
|
||||
bool llvm::isAssignmentTrackingEnabled(const Module &M) {
|
||||
|
||||
@ -342,7 +342,7 @@ static bool shouldConvertImpl(const Constant *Cst) {
|
||||
// instances of Cst.
|
||||
// Ideally, we could promote this into a global and rematerialize the constant
|
||||
// when it was a bad idea.
|
||||
if (Cst->isZeroValue())
|
||||
if (Cst->isNullValue())
|
||||
return false;
|
||||
|
||||
// Globals cannot be or contain scalable vectors.
|
||||
|
||||
@ -1454,7 +1454,7 @@ GCNTTIImpl::instCombineIntrinsic(InstCombiner &IC, IntrinsicInst &II) const {
|
||||
auto *BC = cast<ConstantInt>(II.getArgOperand(5));
|
||||
auto *RM = cast<ConstantInt>(II.getArgOperand(3));
|
||||
auto *BM = cast<ConstantInt>(II.getArgOperand(4));
|
||||
if (BC->isZeroValue() || RM->getZExtValue() != 0xF ||
|
||||
if (BC->isNullValue() || RM->getZExtValue() != 0xF ||
|
||||
BM->getZExtValue() != 0xF || isa<PoisonValue>(Old))
|
||||
break;
|
||||
|
||||
|
||||
@ -618,7 +618,7 @@ static Value *promoteAllocaUserToVector(Instruction *Inst, const DataLayout &DL,
|
||||
Type *AccessTy = Inst->getType();
|
||||
TypeSize AccessSize = DL.getTypeStoreSize(AccessTy);
|
||||
if (Constant *CI = dyn_cast<Constant>(Index)) {
|
||||
if (CI->isZeroValue() && AccessSize == VecStoreSize) {
|
||||
if (CI->isNullValue() && AccessSize == VecStoreSize) {
|
||||
Inst->replaceAllUsesWith(
|
||||
Builder.CreateBitPreservingCastChain(DL, CurVal, AccessTy));
|
||||
return nullptr;
|
||||
@ -696,7 +696,7 @@ static Value *promoteAllocaUserToVector(Instruction *Inst, const DataLayout &DL,
|
||||
Type *AccessTy = Val->getType();
|
||||
TypeSize AccessSize = DL.getTypeStoreSize(AccessTy);
|
||||
if (Constant *CI = dyn_cast<Constant>(Index))
|
||||
if (CI->isZeroValue() && AccessSize == VecStoreSize)
|
||||
if (CI->isNullValue() && AccessSize == VecStoreSize)
|
||||
return Builder.CreateBitPreservingCastChain(DL, Val, AA.Vector.Ty);
|
||||
|
||||
// Storing a subvector.
|
||||
|
||||
@ -277,7 +277,7 @@ static Value *expandVecReduceAdd(CallInst *Orig, Intrinsic::ID IntrinsicId) {
|
||||
// Handle the initial start value for floating-point addition.
|
||||
if (IsFAdd) {
|
||||
Constant *StartValue = dyn_cast<Constant>(Orig->getOperand(0));
|
||||
if (StartValue && !StartValue->isZeroValue())
|
||||
if (StartValue && !StartValue->isNullValue())
|
||||
Sum = Builder.CreateFAdd(Sum, StartValue);
|
||||
}
|
||||
|
||||
|
||||
@ -1172,7 +1172,7 @@ HexagonTargetLowering::LowerConstantPool(SDValue Op, SelectionDAG &DAG) const {
|
||||
assert(isPowerOf2_32(VecLen) &&
|
||||
"conversion only supported for pow2 VectorSize");
|
||||
for (unsigned i = 0; i < VecLen; ++i)
|
||||
NewConst.push_back(IRB.getInt8(CV->getOperand(i)->isZeroValue()));
|
||||
NewConst.push_back(IRB.getInt8(CV->getOperand(i)->isNullValue()));
|
||||
|
||||
CVal = ConstantVector::get(NewConst);
|
||||
isVTi1Type = true;
|
||||
|
||||
@ -3349,7 +3349,7 @@ auto HexagonVectorCombine::getConstInt(int Val, unsigned Width) const
|
||||
|
||||
auto HexagonVectorCombine::isZero(const Value *Val) const -> bool {
|
||||
if (auto *C = dyn_cast<Constant>(Val))
|
||||
return C->isZeroValue();
|
||||
return C->isNullValue();
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@ -813,7 +813,7 @@ bool X86LowerAMXCast::optimizeAMXCastFromPhi(
|
||||
// might support const.
|
||||
if (isa<Constant>(IncValue)) {
|
||||
auto *IncConst = dyn_cast<Constant>(IncValue);
|
||||
if (!isa<UndefValue>(IncValue) && !IncConst->isZeroValue())
|
||||
if (!isa<UndefValue>(IncValue) && !IncConst->isNullValue())
|
||||
return false;
|
||||
Value *Row = nullptr, *Col = nullptr;
|
||||
std::tie(Row, Col) = getShape(OldPN);
|
||||
|
||||
@ -10050,7 +10050,7 @@ struct AAPotentialConstantValuesFloating : AAPotentialConstantValuesImpl {
|
||||
bool OnlyLeft = false, OnlyRight = false;
|
||||
if (C && *C && (*C)->isOneValue())
|
||||
OnlyLeft = true;
|
||||
else if (C && *C && (*C)->isZeroValue())
|
||||
else if (C && *C && (*C)->isNullValue())
|
||||
OnlyRight = true;
|
||||
|
||||
bool LHSContainsUndef = false, RHSContainsUndef = false;
|
||||
|
||||
@ -455,13 +455,13 @@ Constant *InstCostVisitor::visitSelectInst(SelectInst &I) {
|
||||
assert(LastVisited != KnownConstants.end() && "Invalid iterator!");
|
||||
|
||||
if (I.getCondition() == LastVisited->first) {
|
||||
Value *V = LastVisited->second->isZeroValue() ? I.getFalseValue()
|
||||
Value *V = LastVisited->second->isNullValue() ? I.getFalseValue()
|
||||
: I.getTrueValue();
|
||||
return findConstantFor(V);
|
||||
}
|
||||
if (Constant *Condition = findConstantFor(I.getCondition()))
|
||||
if ((I.getTrueValue() == LastVisited->first && Condition->isOneValue()) ||
|
||||
(I.getFalseValue() == LastVisited->first && Condition->isZeroValue()))
|
||||
(I.getFalseValue() == LastVisited->first && Condition->isNullValue()))
|
||||
return LastVisited->second;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@ -2660,7 +2660,7 @@ Instruction *InstCombinerImpl::visitAnd(BinaryOperator &I) {
|
||||
Constant *Log2C1 = ConstantExpr::getExactLogBase2(C1);
|
||||
Constant *Cmp =
|
||||
ConstantFoldCompareInstOperands(ICmpInst::ICMP_ULT, Log2C3, C2, DL);
|
||||
if (Cmp && Cmp->isZeroValue()) {
|
||||
if (Cmp && Cmp->isNullValue()) {
|
||||
// iff C1,C3 is pow2 and Log2(C3) >= C2:
|
||||
// ((C1 >> X) << C2) & C3 -> X == (cttz(C1)+C2-cttz(C3)) ? C3 : 0
|
||||
Constant *ShlC = ConstantExpr::getAdd(C2, Log2C1);
|
||||
@ -5322,7 +5322,7 @@ Instruction *InstCombinerImpl::visitXor(BinaryOperator &I) {
|
||||
m_AShr(m_Value(X), m_APIntAllowPoison(CA))))) &&
|
||||
*CA == X->getType()->getScalarSizeInBits() - 1 &&
|
||||
!match(C1, m_AllOnes())) {
|
||||
assert(!C1->isZeroValue() && "Unexpected xor with 0");
|
||||
assert(!C1->isNullValue() && "Unexpected xor with 0");
|
||||
Value *IsNotNeg = Builder.CreateIsNotNeg(X);
|
||||
return createSelectInstWithUnknownProfile(IsNotNeg, Op1,
|
||||
Builder.CreateNot(Op1));
|
||||
|
||||
@ -892,7 +892,7 @@ Instruction *InstCombinerImpl::tryFoldInstWithCtpopWithNot(Instruction *I) {
|
||||
if (Opc == Instruction::ICmp && !cast<ICmpInst>(I)->isEquality()) {
|
||||
Constant *Cmp =
|
||||
ConstantFoldCompareInstOperands(ICmpInst::ICMP_UGT, C, BitWidthC, DL);
|
||||
if (!Cmp || !Cmp->isZeroValue())
|
||||
if (!Cmp || !Cmp->isNullValue())
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
||||
@ -2363,7 +2363,7 @@ DFSanFunction::loadShadowOrigin(Value *Addr, uint64_t Size, Align InstAlignment,
|
||||
if (ClTrackOrigins == 2) {
|
||||
IRBuilder<> IRB(Pos->getParent(), Pos);
|
||||
auto *ConstantShadow = dyn_cast<Constant>(PrimitiveShadow);
|
||||
if (!ConstantShadow || !ConstantShadow->isZeroValue())
|
||||
if (!ConstantShadow || !ConstantShadow->isNullValue())
|
||||
Origin = updateOriginIfTainted(PrimitiveShadow, Origin, IRB);
|
||||
}
|
||||
}
|
||||
@ -2552,7 +2552,7 @@ void DFSanFunction::storeOrigin(BasicBlock::iterator Pos, Value *Addr,
|
||||
Value *CollapsedShadow = collapseToPrimitiveShadow(Shadow, Pos);
|
||||
IRBuilder<> IRB(Pos->getParent(), Pos);
|
||||
if (auto *ConstantShadow = dyn_cast<Constant>(CollapsedShadow)) {
|
||||
if (!ConstantShadow->isZeroValue())
|
||||
if (!ConstantShadow->isNullValue())
|
||||
paintOrigin(IRB, updateOrigin(Origin, IRB), StoreOriginAddr, Size,
|
||||
OriginAlignment);
|
||||
return;
|
||||
|
||||
@ -1176,7 +1176,7 @@ void InstrLowerer::lowerCover(InstrProfCoverInst *CoverInstruction) {
|
||||
|
||||
void InstrLowerer::lowerTimestamp(
|
||||
InstrProfTimestampInst *TimestampInstruction) {
|
||||
assert(TimestampInstruction->getIndex()->isZeroValue() &&
|
||||
assert(TimestampInstruction->getIndex()->isNullValue() &&
|
||||
"timestamp probes are always the first probe for a function");
|
||||
auto &Ctx = M.getContext();
|
||||
auto *TimestampAddr = getCounterAddress(TimestampInstruction);
|
||||
@ -1194,7 +1194,7 @@ void InstrLowerer::lowerIncrement(InstrProfIncrementInst *Inc) {
|
||||
|
||||
IRBuilder<> Builder(Inc);
|
||||
if (Options.Atomic || AtomicCounterUpdateAll ||
|
||||
(Inc->getIndex()->isZeroValue() && AtomicFirstCounter)) {
|
||||
(Inc->getIndex()->isNullValue() && AtomicFirstCounter)) {
|
||||
Builder.CreateAtomicRMW(AtomicRMWInst::Add, Addr, Inc->getStep(),
|
||||
MaybeAlign(), AtomicOrdering::Monotonic);
|
||||
} else {
|
||||
|
||||
@ -1356,7 +1356,7 @@ struct MemorySanitizerVisitor : public InstVisitor<MemorySanitizerVisitor> {
|
||||
// ZExt cannot convert between vector and scalar
|
||||
Value *ConvertedShadow = convertShadowToScalar(Shadow, IRB);
|
||||
if (auto *ConstantShadow = dyn_cast<Constant>(ConvertedShadow)) {
|
||||
if (!ClCheckConstantShadow || ConstantShadow->isZeroValue()) {
|
||||
if (!ClCheckConstantShadow || ConstantShadow->isNullValue()) {
|
||||
// Origin is not needed: value is initialized or const shadow is
|
||||
// ignored.
|
||||
return;
|
||||
@ -1519,7 +1519,7 @@ struct MemorySanitizerVisitor : public InstVisitor<MemorySanitizerVisitor> {
|
||||
Value *ConvertedShadow = ShadowData.Shadow;
|
||||
|
||||
if (auto *ConstantShadow = dyn_cast<Constant>(ConvertedShadow)) {
|
||||
if (!ClCheckConstantShadow || ConstantShadow->isZeroValue()) {
|
||||
if (!ClCheckConstantShadow || ConstantShadow->isNullValue()) {
|
||||
// Skip, value is initialized or const shadow is ignored.
|
||||
continue;
|
||||
}
|
||||
@ -3522,7 +3522,7 @@ struct MemorySanitizerVisitor : public InstVisitor<MemorySanitizerVisitor> {
|
||||
|
||||
// If zero poison is requested, mix in with the shadow
|
||||
Constant *IsZeroPoison = cast<Constant>(I.getOperand(1));
|
||||
if (!IsZeroPoison->isZeroValue()) {
|
||||
if (!IsZeroPoison->isNullValue()) {
|
||||
Value *BoolZeroPoison = IRB.CreateIsNull(Src, "_mscz_bzp");
|
||||
OutputShadow = IRB.CreateOr(OutputShadow, BoolZeroPoison, "_mscz_bs");
|
||||
}
|
||||
|
||||
@ -224,7 +224,7 @@ static Value *getValueOnEdge(LazyValueInfo *LVI, Value *Incoming,
|
||||
if (Constant *C = LVI->getConstantOnEdge(Condition, From, To, CxtI)) {
|
||||
if (C->isOneValue())
|
||||
return SI->getTrueValue();
|
||||
if (C->isZeroValue())
|
||||
if (C->isNullValue())
|
||||
return SI->getFalseValue();
|
||||
}
|
||||
}
|
||||
|
||||
@ -109,9 +109,9 @@ TEST_F(ValueLatticeTest, getCompareIntegers) {
|
||||
EXPECT_TRUE(LV1.getCompare(CmpInst::ICMP_EQ, I1Ty, LV1, DL)->isOneValue());
|
||||
EXPECT_TRUE(LV1.getCompare(CmpInst::ICMP_SGE, I1Ty, LV1, DL)->isOneValue());
|
||||
EXPECT_TRUE(LV1.getCompare(CmpInst::ICMP_SLE, I1Ty, LV1, DL)->isOneValue());
|
||||
EXPECT_TRUE(LV1.getCompare(CmpInst::ICMP_NE, I1Ty, LV1, DL)->isZeroValue());
|
||||
EXPECT_TRUE(LV1.getCompare(CmpInst::ICMP_SLT, I1Ty, LV1, DL)->isZeroValue());
|
||||
EXPECT_TRUE(LV1.getCompare(CmpInst::ICMP_SGT, I1Ty, LV1, DL)->isZeroValue());
|
||||
EXPECT_TRUE(LV1.getCompare(CmpInst::ICMP_NE, I1Ty, LV1, DL)->isNullValue());
|
||||
EXPECT_TRUE(LV1.getCompare(CmpInst::ICMP_SLT, I1Ty, LV1, DL)->isNullValue());
|
||||
EXPECT_TRUE(LV1.getCompare(CmpInst::ICMP_SGT, I1Ty, LV1, DL)->isNullValue());
|
||||
|
||||
auto LV2 =
|
||||
ValueLatticeElement::getRange({APInt(32, 10, true), APInt(32, 20, true)});
|
||||
@ -119,9 +119,9 @@ TEST_F(ValueLatticeTest, getCompareIntegers) {
|
||||
EXPECT_TRUE(LV1.getCompare(CmpInst::ICMP_SLT, I1Ty, LV2, DL)->isOneValue());
|
||||
EXPECT_TRUE(LV1.getCompare(CmpInst::ICMP_SLE, I1Ty, LV2, DL)->isOneValue());
|
||||
EXPECT_TRUE(LV1.getCompare(CmpInst::ICMP_NE, I1Ty, LV2, DL)->isOneValue());
|
||||
EXPECT_TRUE(LV1.getCompare(CmpInst::ICMP_EQ, I1Ty, LV2, DL)->isZeroValue());
|
||||
EXPECT_TRUE(LV1.getCompare(CmpInst::ICMP_SGE, I1Ty, LV2, DL)->isZeroValue());
|
||||
EXPECT_TRUE(LV1.getCompare(CmpInst::ICMP_SGT, I1Ty, LV2, DL)->isZeroValue());
|
||||
EXPECT_TRUE(LV1.getCompare(CmpInst::ICMP_EQ, I1Ty, LV2, DL)->isNullValue());
|
||||
EXPECT_TRUE(LV1.getCompare(CmpInst::ICMP_SGE, I1Ty, LV2, DL)->isNullValue());
|
||||
EXPECT_TRUE(LV1.getCompare(CmpInst::ICMP_SGT, I1Ty, LV2, DL)->isNullValue());
|
||||
|
||||
auto LV3 =
|
||||
ValueLatticeElement::getRange({APInt(32, 15, true), APInt(32, 19, true)});
|
||||
@ -155,9 +155,9 @@ TEST_F(ValueLatticeTest, getCompareFloat) {
|
||||
EXPECT_TRUE(LV1.getCompare(CmpInst::FCMP_OEQ, I1Ty, LV2, DL)->isOneValue());
|
||||
EXPECT_TRUE(LV1.getCompare(CmpInst::FCMP_OGE, I1Ty, LV2, DL)->isOneValue());
|
||||
EXPECT_TRUE(LV1.getCompare(CmpInst::FCMP_OLE, I1Ty, LV2, DL)->isOneValue());
|
||||
EXPECT_TRUE(LV1.getCompare(CmpInst::FCMP_ONE, I1Ty, LV2, DL)->isZeroValue());
|
||||
EXPECT_TRUE(LV1.getCompare(CmpInst::FCMP_OLT, I1Ty, LV2, DL)->isZeroValue());
|
||||
EXPECT_TRUE(LV1.getCompare(CmpInst::FCMP_OGT, I1Ty, LV2, DL)->isZeroValue());
|
||||
EXPECT_TRUE(LV1.getCompare(CmpInst::FCMP_ONE, I1Ty, LV2, DL)->isNullValue());
|
||||
EXPECT_TRUE(LV1.getCompare(CmpInst::FCMP_OLT, I1Ty, LV2, DL)->isNullValue());
|
||||
EXPECT_TRUE(LV1.getCompare(CmpInst::FCMP_OGT, I1Ty, LV2, DL)->isNullValue());
|
||||
|
||||
EXPECT_TRUE(
|
||||
LV1.mergeIn(ValueLatticeElement::get(ConstantFP::get(FloatTy, 2.2))));
|
||||
|
||||
@ -654,7 +654,7 @@ llvm::Constant *mlir::LLVM::detail::getLLVMConstant(
|
||||
llvm::ElementCount::get(numElements, /*Scalable=*/isScalable), child);
|
||||
if (llvmType->isArrayTy()) {
|
||||
auto *arrayType = llvm::ArrayType::get(elementType, numElements);
|
||||
if (child->isZeroValue() && !elementType->isFPOrFPVectorTy()) {
|
||||
if (child->isNullValue() && !elementType->isFPOrFPVectorTy()) {
|
||||
return llvm::ConstantAggregateZero::get(arrayType);
|
||||
}
|
||||
if (llvm::ConstantDataSequential::isElementTypeCompatible(elementType)) {
|
||||
|
||||
@ -427,7 +427,7 @@ public:
|
||||
|
||||
auto *Divisor = SRem->getOperand(1);
|
||||
auto *CI = dyn_cast<ConstantInt>(Divisor);
|
||||
if (!CI || CI->isZeroValue())
|
||||
if (!CI || CI->isNullValue())
|
||||
return visitGenericInst(SRem, S);
|
||||
|
||||
auto *Dividend = SRem->getOperand(0);
|
||||
|
||||
@ -436,7 +436,7 @@ isl::union_map ZoneAlgorithm::getWrittenValue(MemoryAccess *MA,
|
||||
if (auto *Memset = dyn_cast<MemSetInst>(AccInst)) {
|
||||
auto *WrittenConstant = dyn_cast<Constant>(Memset->getValue());
|
||||
Type *Ty = MA->getLatestScopArrayInfo()->getElementType();
|
||||
if (WrittenConstant && WrittenConstant->isZeroValue()) {
|
||||
if (WrittenConstant && WrittenConstant->isNullValue()) {
|
||||
Constant *Zero = Constant::getNullValue(Ty);
|
||||
return makeNormalizedValInst(Zero, Stmt, L);
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user