[PATCH] add a convenience method to copy wrapping, exact, and fast-math flags (NFC)
David Majnemer
david.majnemer at gmail.com
Sun Aug 31 19:53:38 PDT 2014
================
Comment at: lib/IR/Instructions.cpp:2033-2049
@@ -2032,1 +2032,19 @@
+void BinaryOperator::copyFlags(const Value *V) {
+ // Copy the wrapping flags.
+ const OverflowingBinaryOperator *OB = dyn_cast<OverflowingBinaryOperator>(V);
+ if (OB) {
+ setHasNoSignedWrap(OB->hasNoSignedWrap());
+ setHasNoUnsignedWrap(OB->hasNoUnsignedWrap());
+ }
+ // Copy the exact flag.
+ const PossiblyExactOperator *PE = dyn_cast<PossiblyExactOperator>(V);
+ if (PE)
+ setIsExact(PE->isExact());
+
+ // Copy the fast-math flags.
+ const FPMathOperator *FP = dyn_cast<FPMathOperator>(V);
+ if (FP)
+ setFastMathFlags(FP->getFastMathFlags());
+}
+
----------------
You could shorten this a bit by doing two things:
# Folding the dyn_cast into the if
# Using auto for the type of the variables, the dyn_cast makes unambiguous.
================
Comment at: test/Transforms/LoopVectorize/exact.ll:3-4
@@ +2,4 @@
+
+;CHECK-LABEL: @lshr_exact(
+;CHECK: lshr exact <4 x i32>
+target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128"
----------------
Space between ; and CHECK.
http://reviews.llvm.org/D5138
More information about the llvm-commits
mailing list