For the NSWSub support in the builder to actually be useable,
authorDuncan Sands <baldrick@free.fr>
Sat, 26 Sep 2009 15:35:35 +0000 (15:35 +0000)
committerDuncan Sands <baldrick@free.fr>
Sat, 26 Sep 2009 15:35:35 +0000 (15:35 +0000)
there need to be corresponding changes to the constant folders,
done in this patch.

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

include/llvm/Constants.h
include/llvm/Support/ConstantFolder.h
include/llvm/Support/NoFolder.h
include/llvm/Support/TargetFolder.h
lib/VMCore/Constants.cpp

index 4999998078b0fbbf5f56924595f7920b4b3ada03..260a89a2d38da107ee08419618e5c7d2e7cf5859 100644 (file)
@@ -654,6 +654,7 @@ public:
   static Constant *getBitCast (Constant *C, const Type *Ty);
 
   static Constant* getNSWAdd(Constant* C1, Constant* C2);
+  static Constant* getNSWSub(Constant* C1, Constant* C2);
   static Constant* getExactSDiv(Constant* C1, Constant* C2);
 
   /// Transparently provide more efficient getOperand methods.
index 3c9278aaa7a1e9747bcd9830711e8cec39b726a2..99cb92078f3679626fdd1e56adef3e5f131ec857 100644 (file)
@@ -44,6 +44,9 @@ public:
   Constant *CreateSub(Constant *LHS, Constant *RHS) const {
     return ConstantExpr::getSub(LHS, RHS);
   }
+  Constant *CreateNSWSub(Constant *LHS, Constant *RHS) const {
+    return ConstantExpr::getNSWSub(LHS, RHS);
+  }
   Constant *CreateFSub(Constant *LHS, Constant *RHS) const {
     return ConstantExpr::getFSub(LHS, RHS);
   }
index 4540f028cee732da2ddb4c91d86638149a49acaa..1f671c19250d2e640f4d8a8b279c851e194ec0f3 100644 (file)
@@ -51,6 +51,9 @@ public:
   Value *CreateSub(Constant *LHS, Constant *RHS) const {
     return BinaryOperator::CreateSub(LHS, RHS);
   }
+  Value *CreateNSWSub(Constant *LHS, Constant *RHS) const {
+    return BinaryOperator::CreateNSWSub(LHS, RHS);
+  }
   Value *CreateFSub(Constant *LHS, Constant *RHS) const {
     return BinaryOperator::CreateFSub(LHS, RHS);
   }
index 77533c00b13589de4597b08f4ac0f752d8bbcbd8..8e28632b7eb82a3591d9faf25d2b52f254b926a9 100644 (file)
@@ -60,6 +60,9 @@ public:
   Constant *CreateSub(Constant *LHS, Constant *RHS) const {
     return Fold(ConstantExpr::getSub(LHS, RHS));
   }
+  Constant *CreateNSWSub(Constant *LHS, Constant *RHS) const {
+    return Fold(ConstantExpr::getNSWSub(LHS, RHS));
+  }
   Constant *CreateFSub(Constant *LHS, Constant *RHS) const {
     return Fold(ConstantExpr::getFSub(LHS, RHS));
   }
index ecaf9ab1633a3865df840979cc85779d22f2bf58..eb7e7c05fbf7fa89b4e3d47bbdac004fd8e2ffeb 100644 (file)
@@ -643,6 +643,11 @@ Constant* ConstantExpr::getNSWAdd(Constant* C1, Constant* C2) {
                OverflowingBinaryOperator::NoSignedWrap);
 }
 
+Constant* ConstantExpr::getNSWSub(Constant* C1, Constant* C2) {
+  return getTy(C1->getType(), Instruction::Sub, C1, C2,
+               OverflowingBinaryOperator::NoSignedWrap);
+}
+
 Constant* ConstantExpr::getExactSDiv(Constant* C1, Constant* C2) {
   return getTy(C1->getType(), Instruction::SDiv, C1, C2,
                SDivOperator::IsExact);