[llvm] Use ConstantInt::{isZero,isOne} (NFC)
This commit is contained in:
parent
2b21327fee
commit
b9c4b95b11
|
@ -175,7 +175,7 @@ Constant *llvm::getPointerAtOffset(Constant *I, uint64_t Offset, Module &M,
|
|||
|
||||
// Relative-pointer support starts here.
|
||||
if (auto *CI = dyn_cast<ConstantInt>(I)) {
|
||||
if (Offset == 0 && CI->getZExtValue() == 0) {
|
||||
if (Offset == 0 && CI->isZero()) {
|
||||
return I;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -844,8 +844,8 @@ void IRTranslator::emitSwitchCase(SwitchCG::CaseBlock &CB,
|
|||
// For conditional branch lowering, we might try to do something silly like
|
||||
// emit an G_ICMP to compare an existing G_ICMP i1 result with true. If so,
|
||||
// just re-use the existing condition vreg.
|
||||
if (MRI->getType(CondLHS).getSizeInBits() == 1 && CI &&
|
||||
CI->getZExtValue() == 1 && CB.PredInfo.Pred == CmpInst::ICMP_EQ) {
|
||||
if (MRI->getType(CondLHS).getSizeInBits() == 1 && CI && CI->isOne() &&
|
||||
CB.PredInfo.Pred == CmpInst::ICMP_EQ) {
|
||||
Cond = CondLHS;
|
||||
} else {
|
||||
Register CondRHS = getOrCreateVReg(*CB.CmpRHS);
|
||||
|
|
|
@ -102,9 +102,7 @@ Value *IRBuilderBase::CreateVScale(Constant *Scaling, const Twine &Name) {
|
|||
Function *TheFn =
|
||||
Intrinsic::getDeclaration(M, Intrinsic::vscale, {Scaling->getType()});
|
||||
CallInst *CI = CreateCall(TheFn, {}, {}, Name);
|
||||
return cast<ConstantInt>(Scaling)->getSExtValue() == 1
|
||||
? CI
|
||||
: CreateMul(CI, Scaling);
|
||||
return cast<ConstantInt>(Scaling)->isOne() ? CI : CreateMul(CI, Scaling);
|
||||
}
|
||||
|
||||
Value *IRBuilderBase::CreateElementCount(Type *DstType, ElementCount EC) {
|
||||
|
|
|
@ -13953,7 +13953,7 @@ bool AArch64TargetLowering::shouldSinkOperands(
|
|||
ConstantInt *ElementConstant =
|
||||
dyn_cast<ConstantInt>(Insert->getOperand(2));
|
||||
// Check that the insertelement is inserting into element 0
|
||||
if (!ElementConstant || ElementConstant->getZExtValue() != 0)
|
||||
if (!ElementConstant || !ElementConstant->isZero())
|
||||
continue;
|
||||
|
||||
unsigned Opcode = OperandInstr->getOpcode();
|
||||
|
|
|
@ -2240,7 +2240,7 @@ bool AArch64InstructionSelector::earlySelect(MachineInstr &I) {
|
|||
case TargetOpcode::G_CONSTANT: {
|
||||
bool IsZero = false;
|
||||
if (I.getOperand(1).isCImm())
|
||||
IsZero = I.getOperand(1).getCImm()->getZExtValue() == 0;
|
||||
IsZero = I.getOperand(1).getCImm()->isZero();
|
||||
else if (I.getOperand(1).isImm())
|
||||
IsZero = I.getOperand(1).getImm() == 0;
|
||||
|
||||
|
|
|
@ -762,7 +762,7 @@ void ARMAsmPrinter::emitAttributes() {
|
|||
|
||||
auto *PACValue = mdconst::extract_or_null<ConstantInt>(
|
||||
SourceModule->getModuleFlag("sign-return-address"));
|
||||
if (PACValue && PACValue->getZExtValue() == 1) {
|
||||
if (PACValue && PACValue->isOne()) {
|
||||
// If "+pacbti" is used as an architecture extension,
|
||||
// Tag_PAC_extension is emitted in
|
||||
// ARMTargetStreamer::emitTargetAttributes().
|
||||
|
@ -775,7 +775,7 @@ void ARMAsmPrinter::emitAttributes() {
|
|||
|
||||
auto *BTIValue = mdconst::extract_or_null<ConstantInt>(
|
||||
SourceModule->getModuleFlag("branch-target-enforcement"));
|
||||
if (BTIValue && BTIValue->getZExtValue() == 1) {
|
||||
if (BTIValue && BTIValue->isOne()) {
|
||||
// If "+pacbti" is used as an architecture extension,
|
||||
// Tag_BTI_extension is emitted in
|
||||
// ARMTargetStreamer::emitTargetAttributes().
|
||||
|
|
|
@ -664,7 +664,7 @@ Value *PolynomialMultiplyRecognize::getCountIV(BasicBlock *BB) {
|
|||
continue;
|
||||
|
||||
if (auto *T = dyn_cast<ConstantInt>(IncV))
|
||||
if (T->getZExtValue() == 1)
|
||||
if (T->isOne())
|
||||
return PN;
|
||||
}
|
||||
return nullptr;
|
||||
|
|
|
@ -429,7 +429,7 @@ bool NVPTXAsmPrinter::isLoopHeaderOfNoUnroll(
|
|||
if (MDNode *UnrollCountMD =
|
||||
GetUnrollMetadata(LoopID, "llvm.loop.unroll.count")) {
|
||||
if (mdconst::extract<ConstantInt>(UnrollCountMD->getOperand(1))
|
||||
->getZExtValue() == 1)
|
||||
->isOne())
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -125,8 +125,7 @@ void GlobalDCEPass::ScanVTables(Module &M) {
|
|||
auto *LTOPostLinkMD =
|
||||
cast_or_null<ConstantAsMetadata>(M.getModuleFlag("LTOPostLink"));
|
||||
bool LTOPostLink =
|
||||
LTOPostLinkMD &&
|
||||
(cast<ConstantInt>(LTOPostLinkMD->getValue())->getZExtValue() != 0);
|
||||
LTOPostLinkMD && !cast<ConstantInt>(LTOPostLinkMD->getValue())->isZero();
|
||||
|
||||
for (GlobalVariable &GV : M.globals()) {
|
||||
Types.clear();
|
||||
|
@ -230,7 +229,7 @@ void GlobalDCEPass::AddVirtualFunctionDependencies(Module &M) {
|
|||
// Don't attempt VFE in that case.
|
||||
auto *Val = mdconst::dyn_extract_or_null<ConstantInt>(
|
||||
M.getModuleFlag("Virtual Function Elim"));
|
||||
if (!Val || Val->getZExtValue() == 0)
|
||||
if (!Val || Val->isZero())
|
||||
return;
|
||||
|
||||
ScanVTables(M);
|
||||
|
|
|
@ -244,7 +244,7 @@ bool lowertypetests::isJumpTableCanonical(Function *F) {
|
|||
return false;
|
||||
auto *CI = mdconst::extract_or_null<ConstantInt>(
|
||||
F->getParent()->getModuleFlag("CFI Canonical Jump Tables"));
|
||||
if (!CI || CI->getZExtValue() != 0)
|
||||
if (!CI || !CI->isZero())
|
||||
return true;
|
||||
return F->hasFnAttribute("cfi-canonical-jump-table");
|
||||
}
|
||||
|
@ -1242,7 +1242,7 @@ void LowerTypeTestsModule::createJumpTableEntry(
|
|||
bool Endbr = false;
|
||||
if (const auto *MD = mdconst::extract_or_null<ConstantInt>(
|
||||
Dest->getParent()->getModuleFlag("cf-protection-branch")))
|
||||
Endbr = MD->getZExtValue() != 0;
|
||||
Endbr = !MD->isZero();
|
||||
if (Endbr)
|
||||
AsmOS << (JumpTableArch == Triple::x86 ? "endbr32\n" : "endbr64\n");
|
||||
AsmOS << "jmp ${" << ArgIndex << ":c}@plt\n";
|
||||
|
|
|
@ -3324,7 +3324,7 @@ struct AAHeapToSharedFunction : public AAHeapToShared {
|
|||
auto Remark = [&](OptimizationRemark OR) {
|
||||
return OR << "Replaced globalized variable with "
|
||||
<< ore::NV("SharedMemory", AllocSize->getZExtValue())
|
||||
<< ((AllocSize->getZExtValue() != 1) ? " bytes " : " byte ")
|
||||
<< (AllocSize->isOne() ? " byte " : " bytes ")
|
||||
<< "of shared memory.";
|
||||
};
|
||||
A.emitRemark<OptimizationRemark>(CB, "OMP111", Remark);
|
||||
|
|
Loading…
Reference in New Issue
Block a user