[llvm] r312508 - NewGVN: Detect copies through predicateinfo

Daniel Berlin via llvm-commits llvm-commits at lists.llvm.org
Mon Sep 4 19:17:41 PDT 2017


Author: dannyb
Date: Mon Sep  4 19:17:41 2017
New Revision: 312508

URL: http://llvm.org/viewvc/llvm-project?rev=312508&view=rev
Log:
NewGVN: Detect copies through predicateinfo

Modified:
    llvm/trunk/lib/Transforms/Scalar/NewGVN.cpp

Modified: llvm/trunk/lib/Transforms/Scalar/NewGVN.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/NewGVN.cpp?rev=312508&r1=312507&r2=312508&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Scalar/NewGVN.cpp (original)
+++ llvm/trunk/lib/Transforms/Scalar/NewGVN.cpp Mon Sep  4 19:17:41 2017
@@ -850,6 +850,17 @@ void NewGVN::deleteExpression(const Expr
   const_cast<BasicExpression *>(BE)->deallocateOperands(ArgRecycler);
   ExpressionAllocator.Deallocate(E);
 }
+
+// Return true if V is really PN, even accounting for predicateinfo copies.
+static bool isCopyOfSelf(const Value *V, const PHINode *PN) {
+  if (V == PN)
+    return V;
+  if (auto *II = dyn_cast<IntrinsicInst>(V))
+    if (II->getIntrinsicID() == Intrinsic::ssa_copy && II->getOperand(0) == PN)
+      return true;
+  return false;
+}
+
 PHIExpression *NewGVN::createPHIExpression(Instruction *I, bool &HasBackedge,
                                            bool &OriginalOpsConstant) const {
   BasicBlock *PHIBlock = getBlockForValue(I);
@@ -879,7 +890,7 @@ PHIExpression *NewGVN::createPHIExpressi
 
   // Filter out unreachable phi operands.
   auto Filtered = make_filter_range(PHIOperands, [&](const Use *U) {
-    if (*U == PN)
+    if (isCopyOfSelf(*U, PN))
       return false;
     if (!ReachableEdges.count({PN->getIncomingBlock(*U), PHIBlock}))
       return false;




More information about the llvm-commits mailing list