Change name of copyFlags() to copyIRFlags(). Add convenience method for logical ...
authorSanjay Patel <spatel@rotateright.com>
Wed, 3 Sep 2014 01:06:50 +0000 (01:06 +0000)
committerSanjay Patel <spatel@rotateright.com>
Wed, 3 Sep 2014 01:06:50 +0000 (01:06 +0000)
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.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@217004 91177308-0d34-0410-b5e6-96231b3b80d8

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

index 7ef245cbc46ea294aae4504c827652e4eba3fa31..83c5e5cc13f78f7d3d763eb62d5d7e54271b0b9e 100644 (file)
@@ -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) {
index b113d51d4168fdee272c8a36411775417fdd8c14..be32dee06381ea979204a9aa020296848d014017 100644 (file)
@@ -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 Value *V) {
     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
 //===----------------------------------------------------------------------===//
index ba3301287882c5468cb5169395d96e79c93acffe..f2d928ca0bb40dc9eaf3ee41d12f8a970a6c2f08 100644 (file)
@@ -3249,7 +3249,7 @@ void InnerLoopVectorizer::vectorizeBlockInLoop(BasicBlock *BB, PhiVector *PV) {
         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;
       }