[llvm] r217004 - Change name of copyFlags() to copyIRFlags(). Add convenience method for logical 'and' of all flags. NFC.

Sanjay Patel spatel at rotateright.com
Tue Sep 2 18:06:50 PDT 2014


Author: spatel
Date: Tue Sep  2 20:06:50 2014
New Revision: 217004

URL: http://llvm.org/viewvc/llvm-project?rev=217004&view=rev
Log:
Change name of copyFlags() to copyIRFlags(). Add convenience method for logical 'and' of all flags. NFC.

Adding 'IR' to the names in an attempt to be less ambiguous about the flags we're dealing with here.

The 'and' method is needed by the SLPVectorizer (PR20802) and possibly other passes.


Modified:
    llvm/trunk/include/llvm/IR/InstrTypes.h
    llvm/trunk/lib/IR/Instructions.cpp
    llvm/trunk/lib/Transforms/Vectorize/LoopVectorize.cpp

Modified: llvm/trunk/include/llvm/IR/InstrTypes.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/IR/InstrTypes.h?rev=217004&r1=217003&r2=217004&view=diff
==============================================================================
--- llvm/trunk/include/llvm/IR/InstrTypes.h (original)
+++ llvm/trunk/include/llvm/IR/InstrTypes.h Tue Sep  2 20:06:50 2014
@@ -360,7 +360,11 @@ public:
 
   /// Convenience method to copy supported wrapping, exact, and fast-math flags
   /// from V to this instruction.
-  void copyFlags(const Value *V);
+  void copyIRFlags(const Value *V);
+  
+  /// Logical 'and' of any supported wrapping, exact, and fast-math flags of
+  /// V and this instruction.
+  void andIRFlags(const Value *V);
 
   // Methods for support type inquiry through isa, cast, and dyn_cast:
   static inline bool classof(const Instruction *I) {

Modified: llvm/trunk/lib/IR/Instructions.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/IR/Instructions.cpp?rev=217004&r1=217003&r2=217004&view=diff
==============================================================================
--- llvm/trunk/lib/IR/Instructions.cpp (original)
+++ llvm/trunk/lib/IR/Instructions.cpp Tue Sep  2 20:06:50 2014
@@ -2030,7 +2030,7 @@ bool BinaryOperator::isExact() const {
   return cast<PossiblyExactOperator>(this)->isExact();
 }
 
-void BinaryOperator::copyFlags(const Value *V) {
+void BinaryOperator::copyIRFlags(const Value *V) {
   // Copy the wrapping flags.
   if (auto *OB = dyn_cast<OverflowingBinaryOperator>(V)) {
     setHasNoSignedWrap(OB->hasNoSignedWrap());
@@ -2046,6 +2046,23 @@ void BinaryOperator::copyFlags(const Val
     copyFastMathFlags(FP->getFastMathFlags());
 }
 
+void BinaryOperator::andIRFlags(const Value *V) {
+  if (auto *OB = dyn_cast<OverflowingBinaryOperator>(V)) {
+    setHasNoSignedWrap(hasNoSignedWrap() & OB->hasNoSignedWrap());
+    setHasNoUnsignedWrap(hasNoUnsignedWrap() & OB->hasNoUnsignedWrap());
+  }
+  
+  if (auto *PE = dyn_cast<PossiblyExactOperator>(V))
+    setIsExact(isExact() & PE->isExact());
+  
+  if (auto *FP = dyn_cast<FPMathOperator>(V)) {
+    FastMathFlags FM = getFastMathFlags();
+    FM &= FP->getFastMathFlags();
+    copyFastMathFlags(FM);
+  }
+}
+
+
 //===----------------------------------------------------------------------===//
 //                             FPMathOperator Class
 //===----------------------------------------------------------------------===//

Modified: llvm/trunk/lib/Transforms/Vectorize/LoopVectorize.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Vectorize/LoopVectorize.cpp?rev=217004&r1=217003&r2=217004&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Vectorize/LoopVectorize.cpp (original)
+++ llvm/trunk/lib/Transforms/Vectorize/LoopVectorize.cpp Tue Sep  2 20:06:50 2014
@@ -3249,7 +3249,7 @@ void InnerLoopVectorizer::vectorizeBlock
         Value *V = Builder.CreateBinOp(BinOp->getOpcode(), A[Part], B[Part]);
 
         if (BinaryOperator *VecOp = dyn_cast<BinaryOperator>(V))
-          VecOp->copyFlags(BinOp);
+          VecOp->copyIRFlags(BinOp);
         
         Entry[Part] = V;
       }





More information about the llvm-commits mailing list