mirror of
https://github.com/RPCSX/llvm.git
synced 2024-11-27 13:40:30 +00:00
[Constants] If we already have a ConstantInt*, prefer to use isZero/isOne/isMinusOne instead of isNullValue/isOneValue/isAllOnesValue inherited from Constant. NFCI
Going through the Constant methods requires redetermining that the Constant is a ConstantInt and then calling isZero/isOne/isMinusOne. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@307292 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
9a2b6151ed
commit
6dbd34d261
@ -1432,8 +1432,8 @@ public:
|
||||
int64_t getSExtValue() const { return Value->getSExtValue(); }
|
||||
|
||||
bool isOne() const { return Value->isOne(); }
|
||||
bool isNullValue() const { return Value->isNullValue(); }
|
||||
bool isAllOnesValue() const { return Value->isAllOnesValue(); }
|
||||
bool isNullValue() const { return Value->isZero(); }
|
||||
bool isAllOnesValue() const { return Value->isMinusOne(); }
|
||||
|
||||
bool isOpaque() const { return ConstantSDNodeBits.IsOpaque; }
|
||||
|
||||
|
@ -1062,7 +1062,7 @@ public:
|
||||
|
||||
Value *CreateAnd(Value *LHS, Value *RHS, const Twine &Name = "") {
|
||||
if (Constant *RC = dyn_cast<Constant>(RHS)) {
|
||||
if (isa<ConstantInt>(RC) && cast<ConstantInt>(RC)->isAllOnesValue())
|
||||
if (isa<ConstantInt>(RC) && cast<ConstantInt>(RC)->isMinusOne())
|
||||
return LHS; // LHS & -1 -> LHS
|
||||
if (Constant *LC = dyn_cast<Constant>(LHS))
|
||||
return Insert(Folder.CreateAnd(LC, RC), Name);
|
||||
|
@ -538,7 +538,7 @@ bool BranchProbabilityInfo::calcZeroHeuristics(const BasicBlock *BB,
|
||||
// InstCombine canonicalizes X <= 0 into X < 1.
|
||||
// X <= 0 -> Unlikely
|
||||
isProb = false;
|
||||
} else if (CV->isAllOnesValue()) {
|
||||
} else if (CV->isMinusOne()) {
|
||||
switch (CI->getPredicate()) {
|
||||
case CmpInst::ICMP_EQ:
|
||||
// X == -1 -> Unlikely
|
||||
|
@ -405,7 +405,7 @@ void Lint::visitMemoryReference(Instruction &I,
|
||||
Assert(!isa<UndefValue>(UnderlyingObject),
|
||||
"Undefined behavior: Undef pointer dereference", &I);
|
||||
Assert(!isa<ConstantInt>(UnderlyingObject) ||
|
||||
!cast<ConstantInt>(UnderlyingObject)->isAllOnesValue(),
|
||||
!cast<ConstantInt>(UnderlyingObject)->isMinusOne(),
|
||||
"Unusual: All-ones pointer dereference", &I);
|
||||
Assert(!isa<ConstantInt>(UnderlyingObject) ||
|
||||
!cast<ConstantInt>(UnderlyingObject)->isOne(),
|
||||
|
@ -131,7 +131,7 @@ PHINode *Loop::getCanonicalInductionVariable() const {
|
||||
PHINode *PN = cast<PHINode>(I);
|
||||
if (ConstantInt *CI =
|
||||
dyn_cast<ConstantInt>(PN->getIncomingValueForBlock(Incoming)))
|
||||
if (CI->isNullValue())
|
||||
if (CI->isZero())
|
||||
if (Instruction *Inc =
|
||||
dyn_cast<Instruction>(PN->getIncomingValueForBlock(Backedge)))
|
||||
if (Inc->getOpcode() == Instruction::Add &&
|
||||
|
@ -326,7 +326,7 @@ bool SCEV::isOne() const {
|
||||
|
||||
bool SCEV::isAllOnesValue() const {
|
||||
if (const SCEVConstant *SC = dyn_cast<SCEVConstant>(this))
|
||||
return SC->getValue()->isAllOnesValue();
|
||||
return SC->getValue()->isMinusOne();
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -5421,9 +5421,9 @@ const SCEV *ScalarEvolution::createSCEV(Value *V) {
|
||||
// For an expression like x&255 that merely masks off the high bits,
|
||||
// use zext(trunc(x)) as the SCEV expression.
|
||||
if (ConstantInt *CI = dyn_cast<ConstantInt>(BO->RHS)) {
|
||||
if (CI->isNullValue())
|
||||
if (CI->isZero())
|
||||
return getSCEV(BO->RHS);
|
||||
if (CI->isAllOnesValue())
|
||||
if (CI->isMinusOne())
|
||||
return getSCEV(BO->LHS);
|
||||
const APInt &A = CI->getValue();
|
||||
|
||||
@ -5498,7 +5498,7 @@ const SCEV *ScalarEvolution::createSCEV(Value *V) {
|
||||
case Instruction::Xor:
|
||||
if (ConstantInt *CI = dyn_cast<ConstantInt>(BO->RHS)) {
|
||||
// If the RHS of xor is -1, then this is a not operation.
|
||||
if (CI->isAllOnesValue())
|
||||
if (CI->isMinusOne())
|
||||
return getNotSCEV(getSCEV(BO->LHS));
|
||||
|
||||
// Model xor(and(x, C), C) as and(~x, C), if C is a low-bits mask.
|
||||
@ -5577,7 +5577,7 @@ const SCEV *ScalarEvolution::createSCEV(Value *V) {
|
||||
if (CI->getValue().uge(BitWidth))
|
||||
break;
|
||||
|
||||
if (CI->isNullValue())
|
||||
if (CI->isZero())
|
||||
return getSCEV(BO->LHS); // shift by zero --> noop
|
||||
|
||||
uint64_t AShrAmt = CI->getZExtValue();
|
||||
@ -7640,7 +7640,7 @@ ScalarEvolution::howFarToZero(const SCEV *V, const Loop *L, bool ControlsExit,
|
||||
// Handle unitary steps, which cannot wraparound.
|
||||
// 1*N = -Start; -1*N = Start (mod 2^BW), so:
|
||||
// N = Distance (as unsigned)
|
||||
if (StepC->getValue()->equalsInt(1) || StepC->getValue()->isAllOnesValue()) {
|
||||
if (StepC->getValue()->isOne() || StepC->getValue()->isMinusOne()) {
|
||||
APInt MaxBECount = getUnsignedRangeMax(Distance);
|
||||
|
||||
// When a loop like "for (int i = 0; i != n; ++i) { /* body */ }" is rotated,
|
||||
@ -7696,7 +7696,7 @@ ScalarEvolution::howFarToNonZero(const SCEV *V, const Loop *L) {
|
||||
// If the value is a constant, check to see if it is known to be non-zero
|
||||
// already. If so, the backedge will execute zero times.
|
||||
if (const SCEVConstant *C = dyn_cast<SCEVConstant>(V)) {
|
||||
if (!C->getValue()->isNullValue())
|
||||
if (!C->getValue()->isZero())
|
||||
return getZero(C->getType());
|
||||
return getCouldNotCompute(); // Otherwise it will loop infinitely.
|
||||
}
|
||||
|
@ -1952,7 +1952,7 @@ bool isKnownNonZero(const Value *V, unsigned Depth, const Query &Q) {
|
||||
}
|
||||
// Check if all incoming values are non-zero constant.
|
||||
bool AllNonZeroConstants = all_of(PN->operands(), [](Value *V) {
|
||||
return isa<ConstantInt>(V) && !cast<ConstantInt>(V)->isZeroValue();
|
||||
return isa<ConstantInt>(V) && !cast<ConstantInt>(V)->isZero();
|
||||
});
|
||||
if (AllNonZeroConstants)
|
||||
return true;
|
||||
|
@ -301,7 +301,7 @@ const llvm::Value *llvm::getSplatValue(const Value *V) {
|
||||
auto *InsertEltInst =
|
||||
dyn_cast<InsertElementInst>(ShuffleInst->getOperand(0));
|
||||
if (!InsertEltInst || !isa<ConstantInt>(InsertEltInst->getOperand(2)) ||
|
||||
!cast<ConstantInt>(InsertEltInst->getOperand(2))->isNullValue())
|
||||
!cast<ConstantInt>(InsertEltInst->getOperand(2))->isZero())
|
||||
return nullptr;
|
||||
|
||||
return InsertEltInst->getOperand(1);
|
||||
|
@ -242,7 +242,7 @@ static Constant *ExtractConstantBytes(Constant *C, unsigned ByteStart,
|
||||
|
||||
// X | -1 -> -1.
|
||||
if (ConstantInt *RHSC = dyn_cast<ConstantInt>(RHS))
|
||||
if (RHSC->isAllOnesValue())
|
||||
if (RHSC->isMinusOne())
|
||||
return RHSC;
|
||||
|
||||
Constant *LHS = ExtractConstantBytes(CE->getOperand(0), ByteStart,ByteSize);
|
||||
@ -1041,7 +1041,7 @@ Constant *llvm::ConstantFoldBinaryInstruction(unsigned Opcode,
|
||||
break;
|
||||
case Instruction::And:
|
||||
if (CI2->isZero()) return C2; // X & 0 == 0
|
||||
if (CI2->isAllOnesValue())
|
||||
if (CI2->isMinusOne())
|
||||
return C1; // X & -1 == X
|
||||
|
||||
if (ConstantExpr *CE1 = dyn_cast<ConstantExpr>(C1)) {
|
||||
@ -1079,7 +1079,7 @@ Constant *llvm::ConstantFoldBinaryInstruction(unsigned Opcode,
|
||||
break;
|
||||
case Instruction::Or:
|
||||
if (CI2->equalsInt(0)) return C1; // X | 0 == X
|
||||
if (CI2->isAllOnesValue())
|
||||
if (CI2->isMinusOne())
|
||||
return C2; // X | -1 == -1
|
||||
break;
|
||||
case Instruction::Xor:
|
||||
@ -1126,18 +1126,18 @@ Constant *llvm::ConstantFoldBinaryInstruction(unsigned Opcode,
|
||||
case Instruction::Mul:
|
||||
return ConstantInt::get(CI1->getContext(), C1V * C2V);
|
||||
case Instruction::UDiv:
|
||||
assert(!CI2->isNullValue() && "Div by zero handled above");
|
||||
assert(!CI2->isZero() && "Div by zero handled above");
|
||||
return ConstantInt::get(CI1->getContext(), C1V.udiv(C2V));
|
||||
case Instruction::SDiv:
|
||||
assert(!CI2->isNullValue() && "Div by zero handled above");
|
||||
assert(!CI2->isZero() && "Div by zero handled above");
|
||||
if (C2V.isAllOnesValue() && C1V.isMinSignedValue())
|
||||
return UndefValue::get(CI1->getType()); // MIN_INT / -1 -> undef
|
||||
return ConstantInt::get(CI1->getContext(), C1V.sdiv(C2V));
|
||||
case Instruction::URem:
|
||||
assert(!CI2->isNullValue() && "Div by zero handled above");
|
||||
assert(!CI2->isZero() && "Div by zero handled above");
|
||||
return ConstantInt::get(CI1->getContext(), C1V.urem(C2V));
|
||||
case Instruction::SRem:
|
||||
assert(!CI2->isNullValue() && "Div by zero handled above");
|
||||
assert(!CI2->isZero() && "Div by zero handled above");
|
||||
if (C2V.isAllOnesValue() && C1V.isMinSignedValue())
|
||||
return UndefValue::get(CI1->getType()); // MIN_INT % -1 -> undef
|
||||
return ConstantInt::get(CI1->getContext(), C1V.srem(C2V));
|
||||
|
@ -547,7 +547,7 @@ bool SITargetLowering::getTgtMemIntrinsic(IntrinsicInfo &Info,
|
||||
Info.align = 0;
|
||||
|
||||
const ConstantInt *Vol = dyn_cast<ConstantInt>(CI.getOperand(4));
|
||||
Info.vol = !Vol || !Vol->isNullValue();
|
||||
Info.vol = !Vol || !Vol->isZero();
|
||||
Info.readMem = true;
|
||||
Info.writeMem = true;
|
||||
return true;
|
||||
|
@ -936,7 +936,7 @@ Value *InstCombiner::foldAndOfICmps(ICmpInst *LHS, ICmpInst *RHS,
|
||||
case ICmpInst::ICMP_ULT:
|
||||
if (LHSC == SubOne(RHSC)) // (X != 13 & X u< 14) -> X < 13
|
||||
return Builder->CreateICmpULT(LHS0, LHSC);
|
||||
if (LHSC->isNullValue()) // (X != 0 & X u< 14) -> X-1 u< 13
|
||||
if (LHSC->isZero()) // (X != 0 & X u< 14) -> X-1 u< 13
|
||||
return insertRangeTest(LHS0, LHSC->getValue() + 1, RHSC->getValue(),
|
||||
false, true);
|
||||
break; // (X != 13 & X u< 15) -> no change
|
||||
@ -2489,7 +2489,7 @@ Instruction *InstCombiner::visitXor(BinaryOperator &I) {
|
||||
|
||||
if (BinaryOperator *Op0I = dyn_cast<BinaryOperator>(Op0)) {
|
||||
// ~(c-X) == X-c-1 == X+(-c-1)
|
||||
if (Op0I->getOpcode() == Instruction::Sub && RHSC->isAllOnesValue())
|
||||
if (Op0I->getOpcode() == Instruction::Sub && RHSC->isMinusOne())
|
||||
if (Constant *Op0I0C = dyn_cast<Constant>(Op0I->getOperand(0))) {
|
||||
Constant *NegOp0I0C = ConstantExpr::getNeg(Op0I0C);
|
||||
return BinaryOperator::CreateAdd(Op0I->getOperand(1),
|
||||
@ -2499,7 +2499,7 @@ Instruction *InstCombiner::visitXor(BinaryOperator &I) {
|
||||
if (ConstantInt *Op0CI = dyn_cast<ConstantInt>(Op0I->getOperand(1))) {
|
||||
if (Op0I->getOpcode() == Instruction::Add) {
|
||||
// ~(X-c) --> (-c-1)-X
|
||||
if (RHSC->isAllOnesValue()) {
|
||||
if (RHSC->isMinusOne()) {
|
||||
Constant *NegOp0CI = ConstantExpr::getNeg(Op0CI);
|
||||
return BinaryOperator::CreateSub(SubOne(NegOp0CI),
|
||||
Op0I->getOperand(0));
|
||||
|
@ -213,7 +213,7 @@ Instruction *InstCombiner::SimplifyMemTransfer(MemIntrinsic *MI) {
|
||||
if (MDNode *M = MI->getMetadata(LLVMContext::MD_tbaa_struct)) {
|
||||
if (M->getNumOperands() == 3 && M->getOperand(0) &&
|
||||
mdconst::hasa<ConstantInt>(M->getOperand(0)) &&
|
||||
mdconst::extract<ConstantInt>(M->getOperand(0))->isNullValue() &&
|
||||
mdconst::extract<ConstantInt>(M->getOperand(0))->isZero() &&
|
||||
M->getOperand(1) &&
|
||||
mdconst::hasa<ConstantInt>(M->getOperand(1)) &&
|
||||
mdconst::extract<ConstantInt>(M->getOperand(1))->getValue() ==
|
||||
@ -2012,7 +2012,7 @@ Instruction *InstCombiner::visitCallInst(CallInst &CI) {
|
||||
if (Power->isOne())
|
||||
return replaceInstUsesWith(CI, II->getArgOperand(0));
|
||||
// powi(x, -1) -> 1/x
|
||||
if (Power->isAllOnesValue())
|
||||
if (Power->isMinusOne())
|
||||
return BinaryOperator::CreateFDiv(ConstantFP::get(CI.getType(), 1.0),
|
||||
II->getArgOperand(0));
|
||||
}
|
||||
|
@ -639,7 +639,7 @@ static ConstantInt *GetAnyNonZeroConstInt(PHINode &PN) {
|
||||
assert(isa<IntegerType>(PN.getType()) && "Expect only intger type phi");
|
||||
for (Value *V : PN.operands())
|
||||
if (auto *ConstVA = dyn_cast<ConstantInt>(V))
|
||||
if (!ConstVA->isZeroValue())
|
||||
if (!ConstVA->isZero())
|
||||
return ConstVA;
|
||||
return ConstantInt::get(cast<IntegerType>(PN.getType()), 1);
|
||||
}
|
||||
|
@ -227,8 +227,8 @@ static bool isSelect01(Constant *C1, Constant *C2) {
|
||||
return false;
|
||||
if (!C1I->isZero() && !C2I->isZero()) // One side must be zero.
|
||||
return false;
|
||||
return C1I->isOne() || C1I->isAllOnesValue() ||
|
||||
C2I->isOne() || C2I->isAllOnesValue();
|
||||
return C1I->isOne() || C1I->isMinusOne() ||
|
||||
C2I->isOne() || C2I->isMinusOne();
|
||||
}
|
||||
|
||||
/// Try to fold the select into one of the operands to allow further
|
||||
@ -617,10 +617,10 @@ Instruction *InstCombiner::foldSelectInstWithICmp(SelectInst &SI,
|
||||
if (TrueVal->getType() == Ty) {
|
||||
if (ConstantInt *Cmp = dyn_cast<ConstantInt>(CmpRHS)) {
|
||||
ConstantInt *C1 = nullptr, *C2 = nullptr;
|
||||
if (Pred == ICmpInst::ICMP_SGT && Cmp->isAllOnesValue()) {
|
||||
if (Pred == ICmpInst::ICMP_SGT && Cmp->isMinusOne()) {
|
||||
C1 = dyn_cast<ConstantInt>(TrueVal);
|
||||
C2 = dyn_cast<ConstantInt>(FalseVal);
|
||||
} else if (Pred == ICmpInst::ICMP_SLT && Cmp->isNullValue()) {
|
||||
} else if (Pred == ICmpInst::ICMP_SLT && Cmp->isZero()) {
|
||||
C1 = dyn_cast<ConstantInt>(FalseVal);
|
||||
C2 = dyn_cast<ConstantInt>(TrueVal);
|
||||
}
|
||||
@ -629,7 +629,7 @@ Instruction *InstCombiner::foldSelectInstWithICmp(SelectInst &SI,
|
||||
Value *AShr = Builder->CreateAShr(CmpLHS, Ty->getBitWidth()-1);
|
||||
|
||||
// Check if we can express the operation with a single or.
|
||||
if (C2->isAllOnesValue())
|
||||
if (C2->isMinusOne())
|
||||
return replaceInstUsesWith(SI, Builder->CreateOr(AShr, C1));
|
||||
|
||||
Value *And = Builder->CreateAnd(AShr, C2->getValue()-C1->getValue());
|
||||
|
@ -548,7 +548,7 @@ Value *InstCombiner::SimplifyDemandedUseBits(Value *V, APInt DemandedMask,
|
||||
if (ConstantInt *Rem = dyn_cast<ConstantInt>(I->getOperand(1))) {
|
||||
// X % -1 demands all the bits because we don't want to introduce
|
||||
// INT_MIN % -1 (== undef) by accident.
|
||||
if (Rem->isAllOnesValue())
|
||||
if (Rem->isMinusOne())
|
||||
break;
|
||||
APInt RA = Rem->getValue().abs();
|
||||
if (RA.isPowerOf2()) {
|
||||
|
@ -1230,7 +1230,7 @@ static void instrumentMaskedLoadOrStore(AddressSanitizer *Pass,
|
||||
if (auto *Vector = dyn_cast<ConstantVector>(Mask)) {
|
||||
// dyn_cast as we might get UndefValue
|
||||
if (auto *Masked = dyn_cast<ConstantInt>(Vector->getOperand(Idx))) {
|
||||
if (Masked->isNullValue())
|
||||
if (Masked->isZero())
|
||||
// Mask is constant false, so no instrumentation needed.
|
||||
continue;
|
||||
// If we have a true or undef value, fall through to doInstrumentAddress
|
||||
|
@ -224,7 +224,7 @@ std::string getBranchCondString(Instruction *TI) {
|
||||
OS << "_Zero";
|
||||
else if (CV->isOne())
|
||||
OS << "_One";
|
||||
else if (CV->isAllOnesValue())
|
||||
else if (CV->isMinusOne())
|
||||
OS << "_MinusOne";
|
||||
else
|
||||
OS << "_Const";
|
||||
|
@ -670,7 +670,7 @@ bool EarlyCSE::processNode(DomTreeNode *Node) {
|
||||
if (auto *KnownCond = AvailableValues.lookup(CondI)) {
|
||||
// Is the condition known to be true?
|
||||
if (isa<ConstantInt>(KnownCond) &&
|
||||
cast<ConstantInt>(KnownCond)->isOneValue()) {
|
||||
cast<ConstantInt>(KnownCond)->isOne()) {
|
||||
DEBUG(dbgs() << "EarlyCSE removing guard: " << *Inst << '\n');
|
||||
removeMSSA(Inst);
|
||||
Inst->eraseFromParent();
|
||||
|
@ -1598,7 +1598,7 @@ bool GVN::propagateEquality(Value *LHS, Value *RHS, const BasicBlockEdge &Root,
|
||||
// RHS neither 'true' nor 'false' - bail out.
|
||||
continue;
|
||||
// Whether RHS equals 'true'. Otherwise it equals 'false'.
|
||||
bool isKnownTrue = CI->isAllOnesValue();
|
||||
bool isKnownTrue = CI->isMinusOne();
|
||||
bool isKnownFalse = !isKnownTrue;
|
||||
|
||||
// If "A && B" is known true then both A and B are known true. If "A || B"
|
||||
|
@ -232,7 +232,7 @@ bool InferAddressSpaces::rewriteIntrinsicOperands(IntrinsicInst *II,
|
||||
case Intrinsic::amdgcn_atomic_inc:
|
||||
case Intrinsic::amdgcn_atomic_dec:{
|
||||
const ConstantInt *IsVolatile = dyn_cast<ConstantInt>(II->getArgOperand(4));
|
||||
if (!IsVolatile || !IsVolatile->isNullValue())
|
||||
if (!IsVolatile || !IsVolatile->isZero())
|
||||
return false;
|
||||
|
||||
LLVM_FALLTHROUGH;
|
||||
|
@ -1160,7 +1160,7 @@ static bool detectPopcountIdiom(Loop *CurLoop, BasicBlock *PreCondBB,
|
||||
if (!Dec ||
|
||||
!((SubInst->getOpcode() == Instruction::Sub && Dec->isOne()) ||
|
||||
(SubInst->getOpcode() == Instruction::Add &&
|
||||
Dec->isAllOnesValue()))) {
|
||||
Dec->isMinusOne()))) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -2326,7 +2326,7 @@ LSRInstance::OptimizeLoopTermCond() {
|
||||
dyn_cast_or_null<SCEVConstant>(getExactSDiv(B, A, SE))) {
|
||||
const ConstantInt *C = D->getValue();
|
||||
// Stride of one or negative one can have reuse with non-addresses.
|
||||
if (C->isOne() || C->isAllOnesValue())
|
||||
if (C->isOne() || C->isMinusOne())
|
||||
goto decline_post_inc;
|
||||
// Avoid weird situations.
|
||||
if (C->getValue().getMinSignedBits() >= 64 ||
|
||||
|
@ -2148,7 +2148,7 @@ void ReassociatePass::ReassociateExpression(BinaryOperator *I) {
|
||||
if (I->getOpcode() == Instruction::Mul &&
|
||||
cast<Instruction>(I->user_back())->getOpcode() == Instruction::Add &&
|
||||
isa<ConstantInt>(Ops.back().Op) &&
|
||||
cast<ConstantInt>(Ops.back().Op)->isAllOnesValue()) {
|
||||
cast<ConstantInt>(Ops.back().Op)->isMinusOne()) {
|
||||
ValueEntry Tmp = Ops.pop_back_val();
|
||||
Ops.insert(Ops.begin(), Tmp);
|
||||
} else if (I->getOpcode() == Instruction::FMul &&
|
||||
|
@ -963,7 +963,7 @@ void SCCPSolver::visitBinaryOperator(Instruction &I) {
|
||||
} else {
|
||||
// X or -1 = -1
|
||||
if (ConstantInt *CI = NonOverdefVal->getConstantInt())
|
||||
if (CI->isAllOnesValue())
|
||||
if (CI->isMinusOne())
|
||||
return markConstant(IV, &I, NonOverdefVal->getConstant());
|
||||
}
|
||||
}
|
||||
|
@ -81,7 +81,7 @@ bool llvm::decomposeBitTestICmp(const ICmpInst *I, CmpInst::Predicate &Pred,
|
||||
break;
|
||||
case ICmpInst::ICMP_SGT:
|
||||
// X > -1 is equivalent to (X & SignMask) == 0.
|
||||
if (!C->isAllOnesValue())
|
||||
if (!C->isMinusOne())
|
||||
return false;
|
||||
Y = ConstantInt::get(I->getContext(), APInt::getSignMask(C->getBitWidth()));
|
||||
Pred = ICmpInst::ICMP_EQ;
|
||||
|
@ -402,7 +402,7 @@ bool Evaluator::EvaluateBlock(BasicBlock::iterator CurInst,
|
||||
Value *Ptr = PtrArg->stripPointerCasts();
|
||||
if (GlobalVariable *GV = dyn_cast<GlobalVariable>(Ptr)) {
|
||||
Type *ElemTy = GV->getValueType();
|
||||
if (!Size->isAllOnesValue() &&
|
||||
if (!Size->isMinusOne() &&
|
||||
Size->getValue().getLimitedValue() >=
|
||||
DL.getTypeStoreSize(ElemTy)) {
|
||||
Invariants.insert(GV);
|
||||
|
@ -656,7 +656,7 @@ Value *LibCallSimplifier::optimizeMemChr(CallInst *CI, IRBuilder<> &B) {
|
||||
ConstantInt *LenC = dyn_cast<ConstantInt>(CI->getArgOperand(2));
|
||||
|
||||
// memchr(x, y, 0) -> null
|
||||
if (LenC && LenC->isNullValue())
|
||||
if (LenC && LenC->isZero())
|
||||
return Constant::getNullValue(CI->getType());
|
||||
|
||||
// From now on we need at least constant length and string.
|
||||
@ -2280,7 +2280,7 @@ bool FortifiedLibCallSimplifier::isFortifiedCallFoldable(CallInst *CI,
|
||||
return true;
|
||||
if (ConstantInt *ObjSizeCI =
|
||||
dyn_cast<ConstantInt>(CI->getArgOperand(ObjSizeOp))) {
|
||||
if (ObjSizeCI->isAllOnesValue())
|
||||
if (ObjSizeCI->isMinusOne())
|
||||
return true;
|
||||
// If the object size wasn't -1 (unknown), bail out if we were asked to.
|
||||
if (OnlyLowerUnknownSize)
|
||||
|
Loading…
Reference in New Issue
Block a user