summaryrefslogtreecommitdiffstats
path: root/llvm/lib/VMCore/Constants.cpp
diff options
context:
space:
mode:
authorDan Gohman <gohman@apple.com>2009-08-11 20:20:39 +0000
committerDan Gohman <gohman@apple.com>2009-08-11 20:20:39 +0000
commit77ad32ab0e2a7acc7b64a435d64d8d3475b64e1b (patch)
tree77237d60ac5dc6f6eaeea7a3956e85faceb36838 /llvm/lib/VMCore/Constants.cpp
parent34c8791ff0dd95dc60a94d75a9553d3923110928 (diff)
downloadbcm5719-llvm-77ad32ab0e2a7acc7b64a435d64d8d3475b64e1b.tar.gz
bcm5719-llvm-77ad32ab0e2a7acc7b64a435d64d8d3475b64e1b.zip
Add convenience functions for creating nsw add operators.
llvm-svn: 78707
Diffstat (limited to 'llvm/lib/VMCore/Constants.cpp')
-rw-r--r--llvm/lib/VMCore/Constants.cpp9
1 files changed, 9 insertions, 0 deletions
diff --git a/llvm/lib/VMCore/Constants.cpp b/llvm/lib/VMCore/Constants.cpp
index d71dc2cf710..0bff5786b83 100644
--- a/llvm/lib/VMCore/Constants.cpp
+++ b/llvm/lib/VMCore/Constants.cpp
@@ -605,6 +605,15 @@ Constant* ConstantVector::get(Constant* const* Vals, unsigned NumVals) {
return get(std::vector<Constant*>(Vals, Vals+NumVals));
}
+Constant* ConstantExpr::getNSWAdd(Constant* C1, Constant* C2) {
+ Constant *C = getAdd(C1, C2);
+ // Set nsw attribute, assuming constant folding didn't eliminate the
+ // Add.
+ if (AddOperator *Add = dyn_cast<AddOperator>(C))
+ Add->setHasNoSignedOverflow(true);
+ return C;
+}
+
Constant* ConstantExpr::getExactSDiv(Constant* C1, Constant* C2) {
Constant *C = getSDiv(C1, C2);
// Set exact attribute, assuming constant folding didn't eliminate the
OpenPOWER on IntegriCloud