From 16f5415f5b843a43c5cafc66111c1941ae34d083 Mon Sep 17 00:00:00 2001 From: Dan Gohman Date: Thu, 20 Aug 2009 17:11:38 +0000 Subject: [PATCH] Rename hasNoUnsignedOverflow and hasNoSignedOverflow to hasNoUnsignedWrap and hasNoSignedWrap, for consistency with the nuw and nsw properties. llvm-svn: 79539 --- .../llvm/Analysis/ScalarEvolutionExpressions.h | 8 ++++---- llvm/include/llvm/Bitcode/LLVMBitCodes.h | 4 ++-- llvm/include/llvm/InstrTypes.h | 6 +++--- llvm/include/llvm/Operator.h | 16 ++++++++-------- llvm/lib/Analysis/ScalarEvolution.cpp | 16 ++++++++-------- llvm/lib/AsmParser/LLParser.cpp | 8 ++++---- llvm/lib/Bitcode/Reader/BitcodeReader.cpp | 8 ++++---- llvm/lib/Bitcode/Writer/BitcodeWriter.cpp | 8 ++++---- .../Transforms/Scalar/InstructionCombining.cpp | 2 +- llvm/lib/VMCore/AsmWriter.cpp | 4 ++-- llvm/lib/VMCore/Constants.cpp | 2 +- 11 files changed, 41 insertions(+), 41 deletions(-) diff --git a/llvm/include/llvm/Analysis/ScalarEvolutionExpressions.h b/llvm/include/llvm/Analysis/ScalarEvolutionExpressions.h index 35372be126d6..447be0c5e1ef 100644 --- a/llvm/include/llvm/Analysis/ScalarEvolutionExpressions.h +++ b/llvm/include/llvm/Analysis/ScalarEvolutionExpressions.h @@ -426,12 +426,12 @@ namespace llvm { return cast(SE.getAddExpr(this, getStepRecurrence(SE))); } - bool hasNoUnsignedOverflow() const { return SubclassData & (1 << 0); } - void setHasNoUnsignedOverflow(bool B) { + bool hasNoUnsignedWrap() const { return SubclassData & (1 << 0); } + void setHasNoUnsignedWrap(bool B) { SubclassData = (SubclassData & ~(1 << 0)) | (B << 0); } - bool hasNoSignedOverflow() const { return SubclassData & (1 << 1); } - void setHasNoSignedOverflow(bool B) { + bool hasNoSignedWrap() const { return SubclassData & (1 << 1); } + void setHasNoSignedWrap(bool B) { SubclassData = (SubclassData & ~(1 << 1)) | (B << 1); } diff --git a/llvm/include/llvm/Bitcode/LLVMBitCodes.h b/llvm/include/llvm/Bitcode/LLVMBitCodes.h index a1c8cb040130..2f967d6c9ad0 100644 --- a/llvm/include/llvm/Bitcode/LLVMBitCodes.h +++ b/llvm/include/llvm/Bitcode/LLVMBitCodes.h @@ -180,8 +180,8 @@ namespace bitc { /// OverflowingBinaryOperatorOptionalFlags - Flags for serializing /// OverflowingBinaryOperator's SubclassOptionalData contents. enum OverflowingBinaryOperatorOptionalFlags { - OBO_NO_UNSIGNED_OVERFLOW = 0, - OBO_NO_SIGNED_OVERFLOW = 1 + OBO_NO_UNSIGNED_WRAP = 0, + OBO_NO_SIGNED_WRAP = 1 }; /// SDivOperatorOptionalFlags - Flags for serializing SDivOperator's diff --git a/llvm/include/llvm/InstrTypes.h b/llvm/include/llvm/InstrTypes.h index 560c32b73aec..35fec63ddfe8 100644 --- a/llvm/include/llvm/InstrTypes.h +++ b/llvm/include/llvm/InstrTypes.h @@ -201,19 +201,19 @@ public: static BinaryOperator *CreateNSWAdd(Value *V1, Value *V2, const Twine &Name = "") { BinaryOperator *BO = CreateAdd(V1, V2, Name); - cast(BO)->setHasNoSignedOverflow(true); + cast(BO)->setHasNoSignedWrap(true); return BO; } static BinaryOperator *CreateNSWAdd(Value *V1, Value *V2, const Twine &Name, BasicBlock *BB) { BinaryOperator *BO = CreateAdd(V1, V2, Name, BB); - cast(BO)->setHasNoSignedOverflow(true); + cast(BO)->setHasNoSignedWrap(true); return BO; } static BinaryOperator *CreateNSWAdd(Value *V1, Value *V2, const Twine &Name, Instruction *I) { BinaryOperator *BO = CreateAdd(V1, V2, Name, I); - cast(BO)->setHasNoSignedOverflow(true); + cast(BO)->setHasNoSignedWrap(true); return BO; } diff --git a/llvm/include/llvm/Operator.h b/llvm/include/llvm/Operator.h index 285c585db6a9..48ac09d54fc4 100644 --- a/llvm/include/llvm/Operator.h +++ b/llvm/include/llvm/Operator.h @@ -69,21 +69,21 @@ public: class OverflowingBinaryOperator : public Operator { ~OverflowingBinaryOperator(); // do not implement public: - /// hasNoUnsignedOverflow - Test whether this operation is known to never - /// undergo unsigned overflow. - bool hasNoUnsignedOverflow() const { + /// hasNoUnsignedWrap - Test whether this operation is known to never + /// undergo unsigned overflow, aka the nuw property. + bool hasNoUnsignedWrap() const { return SubclassOptionalData & (1 << 0); } - void setHasNoUnsignedOverflow(bool B) { + void setHasNoUnsignedWrap(bool B) { SubclassOptionalData = (SubclassOptionalData & ~(1 << 0)) | (B << 0); } - /// hasNoSignedOverflow - Test whether this operation is known to never - /// undergo signed overflow. - bool hasNoSignedOverflow() const { + /// hasNoSignedWrap - Test whether this operation is known to never + /// undergo signed overflow, aka the nsw property. + bool hasNoSignedWrap() const { return SubclassOptionalData & (1 << 1); } - void setHasNoSignedOverflow(bool B) { + void setHasNoSignedWrap(bool B) { SubclassOptionalData = (SubclassOptionalData & ~(1 << 1)) | (B << 1); } diff --git a/llvm/lib/Analysis/ScalarEvolution.cpp b/llvm/lib/Analysis/ScalarEvolution.cpp index 5c223a3a6031..d2c3f58e9cfd 100644 --- a/llvm/lib/Analysis/ScalarEvolution.cpp +++ b/llvm/lib/Analysis/ScalarEvolution.cpp @@ -795,7 +795,7 @@ const SCEV *ScalarEvolution::getZeroExtendExpr(const SCEV *Op, // If we have special knowledge that this addrec won't overflow, // we don't need to do any further analysis. - if (AR->hasNoUnsignedOverflow()) + if (AR->hasNoUnsignedWrap()) return getAddRecExpr(getZeroExtendExpr(Start, Ty), getZeroExtendExpr(Step, Ty), L); @@ -934,7 +934,7 @@ const SCEV *ScalarEvolution::getSignExtendExpr(const SCEV *Op, // If we have special knowledge that this addrec won't overflow, // we don't need to do any further analysis. - if (AR->hasNoSignedOverflow()) + if (AR->hasNoSignedWrap()) return getAddRecExpr(getSignExtendExpr(Start, Ty), getSignExtendExpr(Step, Ty), L); @@ -2497,17 +2497,17 @@ const SCEV *ScalarEvolution::createNodeForPHI(PHINode *PN) { getSCEV(OBO->getOperand(1)) == PHISCEV->getStepRecurrence(*this)) { const SCEVAddRecExpr *PostInc = PHISCEV->getPostIncExpr(*this); - if (OBO->hasNoUnsignedOverflow()) { + if (OBO->hasNoUnsignedWrap()) { const_cast(PHISCEV) - ->setHasNoUnsignedOverflow(true); + ->setHasNoUnsignedWrap(true); const_cast(PostInc) - ->setHasNoUnsignedOverflow(true); + ->setHasNoUnsignedWrap(true); } - if (OBO->hasNoSignedOverflow()) { + if (OBO->hasNoSignedWrap()) { const_cast(PHISCEV) - ->setHasNoSignedOverflow(true); + ->setHasNoSignedWrap(true); const_cast(PostInc) - ->setHasNoSignedOverflow(true); + ->setHasNoSignedWrap(true); } } diff --git a/llvm/lib/AsmParser/LLParser.cpp b/llvm/lib/AsmParser/LLParser.cpp index ec7bc650c45e..0b35335965ba 100644 --- a/llvm/lib/AsmParser/LLParser.cpp +++ b/llvm/lib/AsmParser/LLParser.cpp @@ -2082,9 +2082,9 @@ bool LLParser::ParseValID(ValID &ID) { return Error(ID.Loc,"constexpr requires integer, fp, or vector operands"); Constant *C = ConstantExpr::get(Opc, Val0, Val1); if (NUW) - cast(C)->setHasNoUnsignedOverflow(true); + cast(C)->setHasNoUnsignedWrap(true); if (NSW) - cast(C)->setHasNoSignedOverflow(true); + cast(C)->setHasNoSignedWrap(true); if (Exact) cast(C)->setIsExact(true); ID.ConstantVal = C; @@ -2665,9 +2665,9 @@ bool LLParser::ParseInstruction(Instruction *&Inst, BasicBlock *BB, return Error(ModifierLoc, "nsw only applies to integer operations"); } if (NUW) - cast(Inst)->setHasNoUnsignedOverflow(true); + cast(Inst)->setHasNoUnsignedWrap(true); if (NSW) - cast(Inst)->setHasNoSignedOverflow(true); + cast(Inst)->setHasNoSignedWrap(true); } return Result; } diff --git a/llvm/lib/Bitcode/Reader/BitcodeReader.cpp b/llvm/lib/Bitcode/Reader/BitcodeReader.cpp index ab560e786d63..df171c55e759 100644 --- a/llvm/lib/Bitcode/Reader/BitcodeReader.cpp +++ b/llvm/lib/Bitcode/Reader/BitcodeReader.cpp @@ -883,10 +883,10 @@ bool BitcodeReader::ResolveGlobalAndAliasInits() { static void SetOptimizationFlags(Value *V, uint64_t Flags) { if (OverflowingBinaryOperator *OBO = dyn_cast(V)) { - if (Flags & (1 << bitc::OBO_NO_SIGNED_OVERFLOW)) - OBO->setHasNoSignedOverflow(true); - if (Flags & (1 << bitc::OBO_NO_UNSIGNED_OVERFLOW)) - OBO->setHasNoUnsignedOverflow(true); + if (Flags & (1 << bitc::OBO_NO_SIGNED_WRAP)) + OBO->setHasNoSignedWrap(true); + if (Flags & (1 << bitc::OBO_NO_UNSIGNED_WRAP)) + OBO->setHasNoUnsignedWrap(true); } else if (SDivOperator *Div = dyn_cast(V)) { if (Flags & (1 << bitc::SDIV_EXACT)) Div->setIsExact(true); diff --git a/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp b/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp index 07566a71c3f5..6a14cb3bbd12 100644 --- a/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp +++ b/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp @@ -461,10 +461,10 @@ static uint64_t GetOptimizationFlags(const Value *V) { if (const OverflowingBinaryOperator *OBO = dyn_cast(V)) { - if (OBO->hasNoSignedOverflow()) - Flags |= 1 << bitc::OBO_NO_SIGNED_OVERFLOW; - if (OBO->hasNoUnsignedOverflow()) - Flags |= 1 << bitc::OBO_NO_UNSIGNED_OVERFLOW; + if (OBO->hasNoSignedWrap()) + Flags |= 1 << bitc::OBO_NO_SIGNED_WRAP; + if (OBO->hasNoUnsignedWrap()) + Flags |= 1 << bitc::OBO_NO_UNSIGNED_WRAP; } else if (const SDivOperator *Div = dyn_cast(V)) { if (Div->isExact()) Flags |= 1 << bitc::SDIV_EXACT; diff --git a/llvm/lib/Transforms/Scalar/InstructionCombining.cpp b/llvm/lib/Transforms/Scalar/InstructionCombining.cpp index 5fe8ee876c34..cd901c0b14fe 100644 --- a/llvm/lib/Transforms/Scalar/InstructionCombining.cpp +++ b/llvm/lib/Transforms/Scalar/InstructionCombining.cpp @@ -3084,7 +3084,7 @@ Instruction *InstCombiner::visitSDiv(BinaryOperator &I) { if (SubOperator *Sub = dyn_cast(Op0)) if (isa(Sub->getOperand(0)) && cast(Sub->getOperand(0))->isNullValue() && - Sub->hasNoSignedOverflow()) + Sub->hasNoSignedWrap()) return BinaryOperator::CreateSDiv(Sub->getOperand(1), ConstantExpr::getNeg(RHS)); } diff --git a/llvm/lib/VMCore/AsmWriter.cpp b/llvm/lib/VMCore/AsmWriter.cpp index c79c427ba875..9c3f76f0d027 100644 --- a/llvm/lib/VMCore/AsmWriter.cpp +++ b/llvm/lib/VMCore/AsmWriter.cpp @@ -895,9 +895,9 @@ static void WriteMDNodes(formatted_raw_ostream &Out, TypePrinting &TypePrinter, static void WriteOptimizationInfo(raw_ostream &Out, const User *U) { if (const OverflowingBinaryOperator *OBO = dyn_cast(U)) { - if (OBO->hasNoUnsignedOverflow()) + if (OBO->hasNoUnsignedWrap()) Out << " nuw"; - if (OBO->hasNoSignedOverflow()) + if (OBO->hasNoSignedWrap()) Out << " nsw"; } else if (const SDivOperator *Div = dyn_cast(U)) { if (Div->isExact()) diff --git a/llvm/lib/VMCore/Constants.cpp b/llvm/lib/VMCore/Constants.cpp index 12483cd9c997..7490b27729b5 100644 --- a/llvm/lib/VMCore/Constants.cpp +++ b/llvm/lib/VMCore/Constants.cpp @@ -634,7 +634,7 @@ Constant* ConstantExpr::getNSWAdd(Constant* C1, Constant* C2) { // Set nsw attribute, assuming constant folding didn't eliminate the // Add. if (AddOperator *Add = dyn_cast(C)) - Add->setHasNoSignedOverflow(true); + Add->setHasNoSignedWrap(true); return C; }