Rename hasNoUnsignedOverflow and hasNoSignedOverflow to hasNoUnsignedWrap
authorDan Gohman <gohman@apple.com>
Thu, 20 Aug 2009 17:11:38 +0000 (17:11 +0000)
committerDan Gohman <gohman@apple.com>
Thu, 20 Aug 2009 17:11:38 +0000 (17:11 +0000)
and hasNoSignedWrap, for consistency with the nuw and nsw properties.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@79539 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/Analysis/ScalarEvolutionExpressions.h
include/llvm/Bitcode/LLVMBitCodes.h
include/llvm/InstrTypes.h
include/llvm/Operator.h
lib/Analysis/ScalarEvolution.cpp
lib/AsmParser/LLParser.cpp
lib/Bitcode/Reader/BitcodeReader.cpp
lib/Bitcode/Writer/BitcodeWriter.cpp
lib/Transforms/Scalar/InstructionCombining.cpp
lib/VMCore/AsmWriter.cpp
lib/VMCore/Constants.cpp

index 35372be126d6edb398da1bea698f0e6686cc6cb2..447be0c5e1ef75a054b1c8824d2be724afd83ab8 100644 (file)
@@ -426,12 +426,12 @@ namespace llvm {
       return cast<SCEVAddRecExpr>(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);
     }
 
index a1c8cb0401309bc0208560b9e9a643e874cb3d49..2f967d6c9ad0779cef51758e51cec3dff7fcfede 100644 (file)
@@ -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
index 560c32b73aecdb95ebc4b125a3ad3cd522790ebc..35fec63ddfe868392fa64796ce4a16231a88a0f2 100644 (file)
@@ -201,19 +201,19 @@ public:
   static BinaryOperator *CreateNSWAdd(Value *V1, Value *V2,
                                       const Twine &Name = "") {
     BinaryOperator *BO = CreateAdd(V1, V2, Name);
-    cast<AddOperator>(BO)->setHasNoSignedOverflow(true);
+    cast<AddOperator>(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<AddOperator>(BO)->setHasNoSignedOverflow(true);
+    cast<AddOperator>(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<AddOperator>(BO)->setHasNoSignedOverflow(true);
+    cast<AddOperator>(BO)->setHasNoSignedWrap(true);
     return BO;
   }
 
index 285c585db6a9dfe2c0b07e5f4c94fb8fa8802b45..48ac09d54fc401a2a5e1aa36411c1305aea00ec6 100644 (file)
@@ -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);
   }
 
index 5c223a3a6031366475d7c067952262622e334735..d2c3f58e9cfd40e6b5f6f6f0d66e6e426852fdd0 100644 (file)
@@ -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<SCEVAddRecExpr *>(PHISCEV)
-                      ->setHasNoUnsignedOverflow(true);
+                      ->setHasNoUnsignedWrap(true);
                     const_cast<SCEVAddRecExpr *>(PostInc)
-                      ->setHasNoUnsignedOverflow(true);
+                      ->setHasNoUnsignedWrap(true);
                   }
-                  if (OBO->hasNoSignedOverflow()) {
+                  if (OBO->hasNoSignedWrap()) {
                     const_cast<SCEVAddRecExpr *>(PHISCEV)
-                      ->setHasNoSignedOverflow(true);
+                      ->setHasNoSignedWrap(true);
                     const_cast<SCEVAddRecExpr *>(PostInc)
-                      ->setHasNoSignedOverflow(true);
+                      ->setHasNoSignedWrap(true);
                   }
                 }
 
index ec7bc650c45e5b5cdf7d21ff18f7cddec09e8104..0b35335965bab56eb12886f76b27fd4621506773 100644 (file)
@@ -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<OverflowingBinaryOperator>(C)->setHasNoUnsignedOverflow(true);
+      cast<OverflowingBinaryOperator>(C)->setHasNoUnsignedWrap(true);
     if (NSW)
-      cast<OverflowingBinaryOperator>(C)->setHasNoSignedOverflow(true);
+      cast<OverflowingBinaryOperator>(C)->setHasNoSignedWrap(true);
     if (Exact)
       cast<SDivOperator>(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<OverflowingBinaryOperator>(Inst)->setHasNoUnsignedOverflow(true);
+        cast<OverflowingBinaryOperator>(Inst)->setHasNoUnsignedWrap(true);
       if (NSW)
-        cast<OverflowingBinaryOperator>(Inst)->setHasNoSignedOverflow(true);
+        cast<OverflowingBinaryOperator>(Inst)->setHasNoSignedWrap(true);
     }
     return Result;
   }
index ab560e786d63157067641b46711d0439ea872cbe..df171c55e7593c0f0951ffd222a7817bfdece319 100644 (file)
@@ -883,10 +883,10 @@ bool BitcodeReader::ResolveGlobalAndAliasInits() {
 static void SetOptimizationFlags(Value *V, uint64_t Flags) {
   if (OverflowingBinaryOperator *OBO =
         dyn_cast<OverflowingBinaryOperator>(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<SDivOperator>(V)) {
     if (Flags & (1 << bitc::SDIV_EXACT))
       Div->setIsExact(true);
index 07566a71c3f5e602a9ff5431c394cd5f9c91aebf..6a14cb3bbd12a729666404f56611d8acdf31bf22 100644 (file)
@@ -461,10 +461,10 @@ static uint64_t GetOptimizationFlags(const Value *V) {
 
   if (const OverflowingBinaryOperator *OBO =
         dyn_cast<OverflowingBinaryOperator>(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<SDivOperator>(V)) {
     if (Div->isExact())
       Flags |= 1 << bitc::SDIV_EXACT;
index 5fe8ee876c345a42671c05ff232b949fbf9f9ee7..cd901c0b14fe17c4333423cbab7c46825e4cbd11 100644 (file)
@@ -3084,7 +3084,7 @@ Instruction *InstCombiner::visitSDiv(BinaryOperator &I) {
     if (SubOperator *Sub = dyn_cast<SubOperator>(Op0))
       if (isa<Constant>(Sub->getOperand(0)) &&
           cast<Constant>(Sub->getOperand(0))->isNullValue() &&
-          Sub->hasNoSignedOverflow())
+          Sub->hasNoSignedWrap())
         return BinaryOperator::CreateSDiv(Sub->getOperand(1),
                                           ConstantExpr::getNeg(RHS));
   }
index c79c427ba875a99c31a3f6215a939ee34edbcaf3..9c3f76f0d02789ec1f6592a2ed2a1b238fcc370b 100644 (file)
@@ -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<OverflowingBinaryOperator>(U)) {
-    if (OBO->hasNoUnsignedOverflow())
+    if (OBO->hasNoUnsignedWrap())
       Out << " nuw";
-    if (OBO->hasNoSignedOverflow())
+    if (OBO->hasNoSignedWrap())
       Out << " nsw";
   } else if (const SDivOperator *Div = dyn_cast<SDivOperator>(U)) {
     if (Div->isExact())
index 12483cd9c99782491d5cb418b1520fe1bff45b41..7490b27729b533d077aaf4796dddfe09c4f620ef 100644 (file)
@@ -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<AddOperator>(C))
-    Add->setHasNoSignedOverflow(true);
+    Add->setHasNoSignedWrap(true);
   return C;
 }