diff options
author | Dan Gohman <gohman@apple.com> | 2009-12-18 02:58:50 +0000 |
---|---|---|
committer | Dan Gohman <gohman@apple.com> | 2009-12-18 02:58:50 +0000 |
commit | 4ab4420d7a402c8ecd02540c0bb5a50073dcf8c8 (patch) | |
tree | 19e630984b07ac5633d77a180c58cbdbe0835798 /llvm/lib/VMCore/Instructions.cpp | |
parent | 24c7f5efc5c13519ac9d2ada4930f07cfa65b4d0 (diff) | |
download | bcm5719-llvm-4ab4420d7a402c8ecd02540c0bb5a50073dcf8c8.tar.gz bcm5719-llvm-4ab4420d7a402c8ecd02540c0bb5a50073dcf8c8.zip |
Add utility routines for creating integer negation operators with NSW set.
Integer negation only overflows with INT_MIN, but that's an important case.
llvm-svn: 91662
Diffstat (limited to 'llvm/lib/VMCore/Instructions.cpp')
-rw-r--r-- | llvm/lib/VMCore/Instructions.cpp | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/llvm/lib/VMCore/Instructions.cpp b/llvm/lib/VMCore/Instructions.cpp index b03ee93dbe7..97fec399e48 100644 --- a/llvm/lib/VMCore/Instructions.cpp +++ b/llvm/lib/VMCore/Instructions.cpp @@ -1772,6 +1772,18 @@ BinaryOperator *BinaryOperator::CreateNeg(Value *Op, const Twine &Name, Op->getType(), Name, InsertAtEnd); } +BinaryOperator *BinaryOperator::CreateNSWNeg(Value *Op, const Twine &Name, + Instruction *InsertBefore) { + Value *zero = ConstantFP::getZeroValueForNegation(Op->getType()); + return BinaryOperator::CreateNSWSub(zero, Op, Name, InsertBefore); +} + +BinaryOperator *BinaryOperator::CreateNSWNeg(Value *Op, const Twine &Name, + BasicBlock *InsertAtEnd) { + Value *zero = ConstantFP::getZeroValueForNegation(Op->getType()); + return BinaryOperator::CreateNSWSub(zero, Op, Name, InsertAtEnd); +} + BinaryOperator *BinaryOperator::CreateFNeg(Value *Op, const Twine &Name, Instruction *InsertBefore) { Value *zero = ConstantFP::getZeroValueForNegation(Op->getType()); |