Rename hasNoUnsignedOverflow and hasNoSignedOverflow to hasNoUnsignedWrap

and hasNoSignedWrap, for consistency with the nuw and nsw properties.

llvm-svn: 79539
This commit is contained in:
Dan Gohman 2009-08-20 17:11:38 +00:00
parent 2de532c132
commit 16f5415f5b
11 changed files with 41 additions and 41 deletions

View File

@ -426,12 +426,12 @@ namespace llvm {
return cast<SCEVAddRecExpr>(SE.getAddExpr(this, getStepRecurrence(SE))); return cast<SCEVAddRecExpr>(SE.getAddExpr(this, getStepRecurrence(SE)));
} }
bool hasNoUnsignedOverflow() const { return SubclassData & (1 << 0); } bool hasNoUnsignedWrap() const { return SubclassData & (1 << 0); }
void setHasNoUnsignedOverflow(bool B) { void setHasNoUnsignedWrap(bool B) {
SubclassData = (SubclassData & ~(1 << 0)) | (B << 0); SubclassData = (SubclassData & ~(1 << 0)) | (B << 0);
} }
bool hasNoSignedOverflow() const { return SubclassData & (1 << 1); } bool hasNoSignedWrap() const { return SubclassData & (1 << 1); }
void setHasNoSignedOverflow(bool B) { void setHasNoSignedWrap(bool B) {
SubclassData = (SubclassData & ~(1 << 1)) | (B << 1); SubclassData = (SubclassData & ~(1 << 1)) | (B << 1);
} }

View File

@ -180,8 +180,8 @@ namespace bitc {
/// OverflowingBinaryOperatorOptionalFlags - Flags for serializing /// OverflowingBinaryOperatorOptionalFlags - Flags for serializing
/// OverflowingBinaryOperator's SubclassOptionalData contents. /// OverflowingBinaryOperator's SubclassOptionalData contents.
enum OverflowingBinaryOperatorOptionalFlags { enum OverflowingBinaryOperatorOptionalFlags {
OBO_NO_UNSIGNED_OVERFLOW = 0, OBO_NO_UNSIGNED_WRAP = 0,
OBO_NO_SIGNED_OVERFLOW = 1 OBO_NO_SIGNED_WRAP = 1
}; };
/// SDivOperatorOptionalFlags - Flags for serializing SDivOperator's /// SDivOperatorOptionalFlags - Flags for serializing SDivOperator's

View File

@ -201,19 +201,19 @@ public:
static BinaryOperator *CreateNSWAdd(Value *V1, Value *V2, static BinaryOperator *CreateNSWAdd(Value *V1, Value *V2,
const Twine &Name = "") { const Twine &Name = "") {
BinaryOperator *BO = CreateAdd(V1, V2, Name); BinaryOperator *BO = CreateAdd(V1, V2, Name);
cast<AddOperator>(BO)->setHasNoSignedOverflow(true); cast<AddOperator>(BO)->setHasNoSignedWrap(true);
return BO; return BO;
} }
static BinaryOperator *CreateNSWAdd(Value *V1, Value *V2, static BinaryOperator *CreateNSWAdd(Value *V1, Value *V2,
const Twine &Name, BasicBlock *BB) { const Twine &Name, BasicBlock *BB) {
BinaryOperator *BO = CreateAdd(V1, V2, Name, BB); BinaryOperator *BO = CreateAdd(V1, V2, Name, BB);
cast<AddOperator>(BO)->setHasNoSignedOverflow(true); cast<AddOperator>(BO)->setHasNoSignedWrap(true);
return BO; return BO;
} }
static BinaryOperator *CreateNSWAdd(Value *V1, Value *V2, static BinaryOperator *CreateNSWAdd(Value *V1, Value *V2,
const Twine &Name, Instruction *I) { const Twine &Name, Instruction *I) {
BinaryOperator *BO = CreateAdd(V1, V2, Name, I); BinaryOperator *BO = CreateAdd(V1, V2, Name, I);
cast<AddOperator>(BO)->setHasNoSignedOverflow(true); cast<AddOperator>(BO)->setHasNoSignedWrap(true);
return BO; return BO;
} }

View File

@ -69,21 +69,21 @@ public:
class OverflowingBinaryOperator : public Operator { class OverflowingBinaryOperator : public Operator {
~OverflowingBinaryOperator(); // do not implement ~OverflowingBinaryOperator(); // do not implement
public: public:
/// hasNoUnsignedOverflow - Test whether this operation is known to never /// hasNoUnsignedWrap - Test whether this operation is known to never
/// undergo unsigned overflow. /// undergo unsigned overflow, aka the nuw property.
bool hasNoUnsignedOverflow() const { bool hasNoUnsignedWrap() const {
return SubclassOptionalData & (1 << 0); return SubclassOptionalData & (1 << 0);
} }
void setHasNoUnsignedOverflow(bool B) { void setHasNoUnsignedWrap(bool B) {
SubclassOptionalData = (SubclassOptionalData & ~(1 << 0)) | (B << 0); SubclassOptionalData = (SubclassOptionalData & ~(1 << 0)) | (B << 0);
} }
/// hasNoSignedOverflow - Test whether this operation is known to never /// hasNoSignedWrap - Test whether this operation is known to never
/// undergo signed overflow. /// undergo signed overflow, aka the nsw property.
bool hasNoSignedOverflow() const { bool hasNoSignedWrap() const {
return SubclassOptionalData & (1 << 1); return SubclassOptionalData & (1 << 1);
} }
void setHasNoSignedOverflow(bool B) { void setHasNoSignedWrap(bool B) {
SubclassOptionalData = (SubclassOptionalData & ~(1 << 1)) | (B << 1); SubclassOptionalData = (SubclassOptionalData & ~(1 << 1)) | (B << 1);
} }

View File

@ -795,7 +795,7 @@ const SCEV *ScalarEvolution::getZeroExtendExpr(const SCEV *Op,
// If we have special knowledge that this addrec won't overflow, // If we have special knowledge that this addrec won't overflow,
// we don't need to do any further analysis. // we don't need to do any further analysis.
if (AR->hasNoUnsignedOverflow()) if (AR->hasNoUnsignedWrap())
return getAddRecExpr(getZeroExtendExpr(Start, Ty), return getAddRecExpr(getZeroExtendExpr(Start, Ty),
getZeroExtendExpr(Step, Ty), getZeroExtendExpr(Step, Ty),
L); L);
@ -934,7 +934,7 @@ const SCEV *ScalarEvolution::getSignExtendExpr(const SCEV *Op,
// If we have special knowledge that this addrec won't overflow, // If we have special knowledge that this addrec won't overflow,
// we don't need to do any further analysis. // we don't need to do any further analysis.
if (AR->hasNoSignedOverflow()) if (AR->hasNoSignedWrap())
return getAddRecExpr(getSignExtendExpr(Start, Ty), return getAddRecExpr(getSignExtendExpr(Start, Ty),
getSignExtendExpr(Step, Ty), getSignExtendExpr(Step, Ty),
L); L);
@ -2497,17 +2497,17 @@ const SCEV *ScalarEvolution::createNodeForPHI(PHINode *PN) {
getSCEV(OBO->getOperand(1)) == getSCEV(OBO->getOperand(1)) ==
PHISCEV->getStepRecurrence(*this)) { PHISCEV->getStepRecurrence(*this)) {
const SCEVAddRecExpr *PostInc = PHISCEV->getPostIncExpr(*this); const SCEVAddRecExpr *PostInc = PHISCEV->getPostIncExpr(*this);
if (OBO->hasNoUnsignedOverflow()) { if (OBO->hasNoUnsignedWrap()) {
const_cast<SCEVAddRecExpr *>(PHISCEV) const_cast<SCEVAddRecExpr *>(PHISCEV)
->setHasNoUnsignedOverflow(true); ->setHasNoUnsignedWrap(true);
const_cast<SCEVAddRecExpr *>(PostInc) const_cast<SCEVAddRecExpr *>(PostInc)
->setHasNoUnsignedOverflow(true); ->setHasNoUnsignedWrap(true);
} }
if (OBO->hasNoSignedOverflow()) { if (OBO->hasNoSignedWrap()) {
const_cast<SCEVAddRecExpr *>(PHISCEV) const_cast<SCEVAddRecExpr *>(PHISCEV)
->setHasNoSignedOverflow(true); ->setHasNoSignedWrap(true);
const_cast<SCEVAddRecExpr *>(PostInc) const_cast<SCEVAddRecExpr *>(PostInc)
->setHasNoSignedOverflow(true); ->setHasNoSignedWrap(true);
} }
} }

View File

@ -2082,9 +2082,9 @@ bool LLParser::ParseValID(ValID &ID) {
return Error(ID.Loc,"constexpr requires integer, fp, or vector operands"); return Error(ID.Loc,"constexpr requires integer, fp, or vector operands");
Constant *C = ConstantExpr::get(Opc, Val0, Val1); Constant *C = ConstantExpr::get(Opc, Val0, Val1);
if (NUW) if (NUW)
cast<OverflowingBinaryOperator>(C)->setHasNoUnsignedOverflow(true); cast<OverflowingBinaryOperator>(C)->setHasNoUnsignedWrap(true);
if (NSW) if (NSW)
cast<OverflowingBinaryOperator>(C)->setHasNoSignedOverflow(true); cast<OverflowingBinaryOperator>(C)->setHasNoSignedWrap(true);
if (Exact) if (Exact)
cast<SDivOperator>(C)->setIsExact(true); cast<SDivOperator>(C)->setIsExact(true);
ID.ConstantVal = C; ID.ConstantVal = C;
@ -2665,9 +2665,9 @@ bool LLParser::ParseInstruction(Instruction *&Inst, BasicBlock *BB,
return Error(ModifierLoc, "nsw only applies to integer operations"); return Error(ModifierLoc, "nsw only applies to integer operations");
} }
if (NUW) if (NUW)
cast<OverflowingBinaryOperator>(Inst)->setHasNoUnsignedOverflow(true); cast<OverflowingBinaryOperator>(Inst)->setHasNoUnsignedWrap(true);
if (NSW) if (NSW)
cast<OverflowingBinaryOperator>(Inst)->setHasNoSignedOverflow(true); cast<OverflowingBinaryOperator>(Inst)->setHasNoSignedWrap(true);
} }
return Result; return Result;
} }

View File

@ -883,10 +883,10 @@ bool BitcodeReader::ResolveGlobalAndAliasInits() {
static void SetOptimizationFlags(Value *V, uint64_t Flags) { static void SetOptimizationFlags(Value *V, uint64_t Flags) {
if (OverflowingBinaryOperator *OBO = if (OverflowingBinaryOperator *OBO =
dyn_cast<OverflowingBinaryOperator>(V)) { dyn_cast<OverflowingBinaryOperator>(V)) {
if (Flags & (1 << bitc::OBO_NO_SIGNED_OVERFLOW)) if (Flags & (1 << bitc::OBO_NO_SIGNED_WRAP))
OBO->setHasNoSignedOverflow(true); OBO->setHasNoSignedWrap(true);
if (Flags & (1 << bitc::OBO_NO_UNSIGNED_OVERFLOW)) if (Flags & (1 << bitc::OBO_NO_UNSIGNED_WRAP))
OBO->setHasNoUnsignedOverflow(true); OBO->setHasNoUnsignedWrap(true);
} else if (SDivOperator *Div = dyn_cast<SDivOperator>(V)) { } else if (SDivOperator *Div = dyn_cast<SDivOperator>(V)) {
if (Flags & (1 << bitc::SDIV_EXACT)) if (Flags & (1 << bitc::SDIV_EXACT))
Div->setIsExact(true); Div->setIsExact(true);

View File

@ -461,10 +461,10 @@ static uint64_t GetOptimizationFlags(const Value *V) {
if (const OverflowingBinaryOperator *OBO = if (const OverflowingBinaryOperator *OBO =
dyn_cast<OverflowingBinaryOperator>(V)) { dyn_cast<OverflowingBinaryOperator>(V)) {
if (OBO->hasNoSignedOverflow()) if (OBO->hasNoSignedWrap())
Flags |= 1 << bitc::OBO_NO_SIGNED_OVERFLOW; Flags |= 1 << bitc::OBO_NO_SIGNED_WRAP;
if (OBO->hasNoUnsignedOverflow()) if (OBO->hasNoUnsignedWrap())
Flags |= 1 << bitc::OBO_NO_UNSIGNED_OVERFLOW; Flags |= 1 << bitc::OBO_NO_UNSIGNED_WRAP;
} else if (const SDivOperator *Div = dyn_cast<SDivOperator>(V)) { } else if (const SDivOperator *Div = dyn_cast<SDivOperator>(V)) {
if (Div->isExact()) if (Div->isExact())
Flags |= 1 << bitc::SDIV_EXACT; Flags |= 1 << bitc::SDIV_EXACT;

View File

@ -3084,7 +3084,7 @@ Instruction *InstCombiner::visitSDiv(BinaryOperator &I) {
if (SubOperator *Sub = dyn_cast<SubOperator>(Op0)) if (SubOperator *Sub = dyn_cast<SubOperator>(Op0))
if (isa<Constant>(Sub->getOperand(0)) && if (isa<Constant>(Sub->getOperand(0)) &&
cast<Constant>(Sub->getOperand(0))->isNullValue() && cast<Constant>(Sub->getOperand(0))->isNullValue() &&
Sub->hasNoSignedOverflow()) Sub->hasNoSignedWrap())
return BinaryOperator::CreateSDiv(Sub->getOperand(1), return BinaryOperator::CreateSDiv(Sub->getOperand(1),
ConstantExpr::getNeg(RHS)); ConstantExpr::getNeg(RHS));
} }

View File

@ -895,9 +895,9 @@ static void WriteMDNodes(formatted_raw_ostream &Out, TypePrinting &TypePrinter,
static void WriteOptimizationInfo(raw_ostream &Out, const User *U) { static void WriteOptimizationInfo(raw_ostream &Out, const User *U) {
if (const OverflowingBinaryOperator *OBO = if (const OverflowingBinaryOperator *OBO =
dyn_cast<OverflowingBinaryOperator>(U)) { dyn_cast<OverflowingBinaryOperator>(U)) {
if (OBO->hasNoUnsignedOverflow()) if (OBO->hasNoUnsignedWrap())
Out << " nuw"; Out << " nuw";
if (OBO->hasNoSignedOverflow()) if (OBO->hasNoSignedWrap())
Out << " nsw"; Out << " nsw";
} else if (const SDivOperator *Div = dyn_cast<SDivOperator>(U)) { } else if (const SDivOperator *Div = dyn_cast<SDivOperator>(U)) {
if (Div->isExact()) if (Div->isExact())

View File

@ -634,7 +634,7 @@ Constant* ConstantExpr::getNSWAdd(Constant* C1, Constant* C2) {
// Set nsw attribute, assuming constant folding didn't eliminate the // Set nsw attribute, assuming constant folding didn't eliminate the
// Add. // Add.
if (AddOperator *Add = dyn_cast<AddOperator>(C)) if (AddOperator *Add = dyn_cast<AddOperator>(C))
Add->setHasNoSignedOverflow(true); Add->setHasNoSignedWrap(true);
return C; return C;
} }