[PATCH] D35292: [SLPVectorizer] Add propagateIRFlagsWithOp() function to propagate IRFlags for specific Operation

Dinar Temirbulatov via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Jul 13 12:57:57 PDT 2017


dtemirbulatov updated this revision to Diff 106497.
dtemirbulatov added a comment.

Fixed issue with test/Transforms/SLPVectorizer/X86/horizontal-list.ll, Merged two versions of propagateIRFlags into one.


https://reviews.llvm.org/D35292

Files:
  include/llvm/Transforms/Utils/LoopUtils.h
  lib/Transforms/Utils/LoopUtils.cpp


Index: lib/Transforms/Utils/LoopUtils.cpp
===================================================================
--- lib/Transforms/Utils/LoopUtils.cpp
+++ lib/Transforms/Utils/LoopUtils.cpp
@@ -1376,16 +1376,21 @@
   }
 }
 
-void llvm::propagateIRFlags(Value *I, ArrayRef<Value *> VL) {
-  if (auto *VecOp = dyn_cast<Instruction>(I)) {
-    if (auto *I0 = dyn_cast<Instruction>(VL[0])) {
-      // VecOVp is initialized to the 0th scalar, so start counting from index
-      // '1'.
-      VecOp->copyIRFlags(I0);
-      for (int i = 1, e = VL.size(); i < e; ++i) {
-        if (auto *Scalar = dyn_cast<Instruction>(VL[i]))
-          VecOp->andIRFlags(Scalar);
-      }
-    }
+void llvm::propagateIRFlags(Value *I, ArrayRef<Value *> VL, Value *OpValue) {
+  auto *VecOp = dyn_cast<Instruction>(I);
+  if (!VecOp) return;
+  auto *Intersection = (OpValue == nullptr) ? cast<Instruction>(VL[0]) :
+                                      cast<Instruction>(OpValue);
+  const unsigned Opcode = Intersection->getOpcode();
+  VecOp->copyIRFlags(Intersection);
+  for (auto *V : VL) {
+    auto *Instr = dyn_cast<Instruction>(V);
+    if (!Instr)
+       continue;
+    if (OpValue == nullptr)
+            VecOp->andIRFlags(V);
+      else
+    if (Opcode == Instr->getOpcode())
+                       VecOp->andIRFlags(V);
   }
 }
Index: include/llvm/Transforms/Utils/LoopUtils.h
===================================================================
--- include/llvm/Transforms/Utils/LoopUtils.h
+++ include/llvm/Transforms/Utils/LoopUtils.h
@@ -531,8 +531,10 @@
 
 /// Get the intersection (logical and) of all of the potential IR flags
 /// of each scalar operation (VL) that will be converted into a vector (I).
+/// If OpValue is set then we consider only similar operation to OpValue in
+/// the intersection.
 /// Flag set: NSW, NUW, exact, and all of fast-math.
-void propagateIRFlags(Value *I, ArrayRef<Value *> VL);
+void propagateIRFlags(Value *I, ArrayRef<Value *> VL, Value *OpValue = nullptr);
 
 } // end namespace llvm
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D35292.106497.patch
Type: text/x-patch
Size: 2029 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170713/f5bf9683/attachment.bin>


More information about the llvm-commits mailing list