diff --git a/llvm/lib/Analysis/TypeMetadataUtils.cpp b/llvm/lib/Analysis/TypeMetadataUtils.cpp index ad300cb24509..19fea0263051 100644 --- a/llvm/lib/Analysis/TypeMetadataUtils.cpp +++ b/llvm/lib/Analysis/TypeMetadataUtils.cpp @@ -175,7 +175,7 @@ Constant *llvm::getPointerAtOffset(Constant *I, uint64_t Offset, Module &M, // Relative-pointer support starts here. if (auto *CI = dyn_cast(I)) { - if (Offset == 0 && CI->getZExtValue() == 0) { + if (Offset == 0 && CI->isZero()) { return I; } } diff --git a/llvm/lib/CodeGen/GlobalISel/IRTranslator.cpp b/llvm/lib/CodeGen/GlobalISel/IRTranslator.cpp index fffbb862d390..3df83251cb44 100644 --- a/llvm/lib/CodeGen/GlobalISel/IRTranslator.cpp +++ b/llvm/lib/CodeGen/GlobalISel/IRTranslator.cpp @@ -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); diff --git a/llvm/lib/IR/IRBuilder.cpp b/llvm/lib/IR/IRBuilder.cpp index 3ebd40a86219..f3d5a6099cd6 100644 --- a/llvm/lib/IR/IRBuilder.cpp +++ b/llvm/lib/IR/IRBuilder.cpp @@ -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(Scaling)->getSExtValue() == 1 - ? CI - : CreateMul(CI, Scaling); + return cast(Scaling)->isOne() ? CI : CreateMul(CI, Scaling); } Value *IRBuilderBase::CreateElementCount(Type *DstType, ElementCount EC) { diff --git a/llvm/lib/Target/AArch64/AArch64ISelLowering.cpp b/llvm/lib/Target/AArch64/AArch64ISelLowering.cpp index 0d3857743cb3..0612304fb8fa 100644 --- a/llvm/lib/Target/AArch64/AArch64ISelLowering.cpp +++ b/llvm/lib/Target/AArch64/AArch64ISelLowering.cpp @@ -13953,7 +13953,7 @@ bool AArch64TargetLowering::shouldSinkOperands( ConstantInt *ElementConstant = dyn_cast(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(); diff --git a/llvm/lib/Target/AArch64/GISel/AArch64InstructionSelector.cpp b/llvm/lib/Target/AArch64/GISel/AArch64InstructionSelector.cpp index ce12b59aa4ed..5273beedcb83 100644 --- a/llvm/lib/Target/AArch64/GISel/AArch64InstructionSelector.cpp +++ b/llvm/lib/Target/AArch64/GISel/AArch64InstructionSelector.cpp @@ -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; diff --git a/llvm/lib/Target/ARM/ARMAsmPrinter.cpp b/llvm/lib/Target/ARM/ARMAsmPrinter.cpp index 5ed8f900fb88..d8c02e5b7392 100644 --- a/llvm/lib/Target/ARM/ARMAsmPrinter.cpp +++ b/llvm/lib/Target/ARM/ARMAsmPrinter.cpp @@ -762,7 +762,7 @@ void ARMAsmPrinter::emitAttributes() { auto *PACValue = mdconst::extract_or_null( 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( 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(). diff --git a/llvm/lib/Target/Hexagon/HexagonLoopIdiomRecognition.cpp b/llvm/lib/Target/Hexagon/HexagonLoopIdiomRecognition.cpp index a7887712c29a..d3d12664228b 100644 --- a/llvm/lib/Target/Hexagon/HexagonLoopIdiomRecognition.cpp +++ b/llvm/lib/Target/Hexagon/HexagonLoopIdiomRecognition.cpp @@ -664,7 +664,7 @@ Value *PolynomialMultiplyRecognize::getCountIV(BasicBlock *BB) { continue; if (auto *T = dyn_cast(IncV)) - if (T->getZExtValue() == 1) + if (T->isOne()) return PN; } return nullptr; diff --git a/llvm/lib/Target/NVPTX/NVPTXAsmPrinter.cpp b/llvm/lib/Target/NVPTX/NVPTXAsmPrinter.cpp index b2db77a53110..d4173ac010ca 100644 --- a/llvm/lib/Target/NVPTX/NVPTXAsmPrinter.cpp +++ b/llvm/lib/Target/NVPTX/NVPTXAsmPrinter.cpp @@ -429,7 +429,7 @@ bool NVPTXAsmPrinter::isLoopHeaderOfNoUnroll( if (MDNode *UnrollCountMD = GetUnrollMetadata(LoopID, "llvm.loop.unroll.count")) { if (mdconst::extract(UnrollCountMD->getOperand(1)) - ->getZExtValue() == 1) + ->isOne()) return true; } } diff --git a/llvm/lib/Transforms/IPO/GlobalDCE.cpp b/llvm/lib/Transforms/IPO/GlobalDCE.cpp index 4aa5ae8f6a03..e26f8663b0ce 100644 --- a/llvm/lib/Transforms/IPO/GlobalDCE.cpp +++ b/llvm/lib/Transforms/IPO/GlobalDCE.cpp @@ -125,8 +125,7 @@ void GlobalDCEPass::ScanVTables(Module &M) { auto *LTOPostLinkMD = cast_or_null(M.getModuleFlag("LTOPostLink")); bool LTOPostLink = - LTOPostLinkMD && - (cast(LTOPostLinkMD->getValue())->getZExtValue() != 0); + LTOPostLinkMD && !cast(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( M.getModuleFlag("Virtual Function Elim")); - if (!Val || Val->getZExtValue() == 0) + if (!Val || Val->isZero()) return; ScanVTables(M); diff --git a/llvm/lib/Transforms/IPO/LowerTypeTests.cpp b/llvm/lib/Transforms/IPO/LowerTypeTests.cpp index 8380afaaaf98..1280c421195d 100644 --- a/llvm/lib/Transforms/IPO/LowerTypeTests.cpp +++ b/llvm/lib/Transforms/IPO/LowerTypeTests.cpp @@ -244,7 +244,7 @@ bool lowertypetests::isJumpTableCanonical(Function *F) { return false; auto *CI = mdconst::extract_or_null( 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( 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"; diff --git a/llvm/lib/Transforms/IPO/OpenMPOpt.cpp b/llvm/lib/Transforms/IPO/OpenMPOpt.cpp index bf525a7dcc48..1a3c692e628e 100644 --- a/llvm/lib/Transforms/IPO/OpenMPOpt.cpp +++ b/llvm/lib/Transforms/IPO/OpenMPOpt.cpp @@ -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(CB, "OMP111", Remark);