summaryrefslogtreecommitdiffstats
path: root/llvm/lib/IR/Instructions.cpp
diff options
context:
space:
mode:
authorSanjay Patel <spatel@rotateright.com>2014-09-01 18:44:57 +0000
committerSanjay Patel <spatel@rotateright.com>2014-09-01 18:44:57 +0000
commit5ad239e15a3cd609b86dc6ca06c2928f7a9c1aae (patch)
tree413882d4635e36fa60f23a0c987bc1e94cbe8c86 /llvm/lib/IR/Instructions.cpp
parent3ae91933713b20c6f6831b579811acad95560c2b (diff)
downloadbcm5719-llvm-5ad239e15a3cd609b86dc6ca06c2928f7a9c1aae.tar.gz
bcm5719-llvm-5ad239e15a3cd609b86dc6ca06c2928f7a9c1aae.zip
Add a convenience method to copy wrapping, exact, and fast-math flags (NFC).
The loop vectorizer preserves wrapping, exact, and fast-math properties of scalar instructions. This patch adds a convenience method to make that operation easier because we need to do this in the loop vectorizer, SLP vectorizer, and possibly other places. Although this is a 'no functional change' patch, I've added a testcase to verify that the exact flag is preserved by the loop vectorizer. The wrapping and fast-math flags are already checked in existing testcases. Differential Revision: http://reviews.llvm.org/D5138 llvm-svn: 216886
Diffstat (limited to 'llvm/lib/IR/Instructions.cpp')
-rw-r--r--llvm/lib/IR/Instructions.cpp16
1 files changed, 16 insertions, 0 deletions
diff --git a/llvm/lib/IR/Instructions.cpp b/llvm/lib/IR/Instructions.cpp
index 9553252f4e9..16993f1bba5 100644
--- a/llvm/lib/IR/Instructions.cpp
+++ b/llvm/lib/IR/Instructions.cpp
@@ -2030,6 +2030,22 @@ bool BinaryOperator::isExact() const {
return cast<PossiblyExactOperator>(this)->isExact();
}
+void BinaryOperator::copyFlags(const Value *V) {
+ // Copy the wrapping flags.
+ if (auto *OB = dyn_cast<OverflowingBinaryOperator>(V)) {
+ setHasNoSignedWrap(OB->hasNoSignedWrap());
+ setHasNoUnsignedWrap(OB->hasNoUnsignedWrap());
+ }
+
+ // Copy the exact flag.
+ if (auto *PE = dyn_cast<PossiblyExactOperator>(V))
+ setIsExact(PE->isExact());
+
+ // Copy the fast-math flags.
+ if (auto *FP = dyn_cast<FPMathOperator>(V))
+ setFastMathFlags(FP->getFastMathFlags());
+}
+
//===----------------------------------------------------------------------===//
// FPMathOperator Class
//===----------------------------------------------------------------------===//
OpenPOWER on IntegriCloud