[PATCH] D13150: Ignore dbg intrinsics in loop-reroll

Weiming Zhao via llvm-commits llvm-commits at lists.llvm.org
Thu Sep 24 16:29:47 PDT 2015


weimingz created this revision.
weimingz added a subscriber: llvm-commits.
weimingz set the repository for this revision to rL LLVM.

Currently, we get different code with and without -g. This patch marks debug inst and a few other LLVM intrinsics as ignorable for loop-reroll

Repository:
  rL LLVM

http://reviews.llvm.org/D13150

Files:
  lib/Transforms/Scalar/LoopRerollPass.cpp

Index: lib/Transforms/Scalar/LoopRerollPass.cpp
===================================================================
--- lib/Transforms/Scalar/LoopRerollPass.cpp
+++ lib/Transforms/Scalar/LoopRerollPass.cpp
@@ -993,6 +993,23 @@
   return false;
 }
 
+static bool isIgnorableInst(const Instruction *I) {
+  if (isa<DbgInfoIntrinsic>(I))
+    return true;
+  const IntrinsicInst* II = dyn_cast<IntrinsicInst>(I);
+  if (!II)
+    return false;
+  switch (II->getIntrinsicID()) {
+    default:
+      return false;
+    case llvm::Intrinsic::annotation:
+    case llvm::Intrinsic::lifetime_start:
+    case llvm::Intrinsic::lifetime_end:
+      return true;
+  }
+  return false;
+}
+
 bool LoopReroll::DAGRootTracker::validate(ReductionTracker &Reductions) {
   // We now need to check for equivalence of the use graph of each root with
   // that of the primary induction variable (excluding the roots). Our goal
@@ -1026,7 +1043,7 @@
   // Make sure all instructions in the loop are in one and only one
   // set.
   for (auto &KV : Uses) {
-    if (KV.second.count() != 1) {
+    if (KV.second.count() != 1 && !isIgnorableInst(KV.first)) {
       DEBUG(dbgs() << "LRR: Aborting - instruction is not used in 1 iteration: "
             << *KV.first << " (#uses=" << KV.second.count() << ")\n");
       return false;


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D13150.35686.patch
Type: text/x-patch
Size: 1315 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20150924/ee2578c5/attachment.bin>


More information about the llvm-commits mailing list