summaryrefslogtreecommitdiffstats
path: root/llvm/lib
diff options
context:
space:
mode:
authorDaniel Berlin <dberlin@dberlin.org>2017-09-05 02:17:41 +0000
committerDaniel Berlin <dberlin@dberlin.org>2017-09-05 02:17:41 +0000
commit1a582582324bf0039da4cb0db8dbe827deda66c8 (patch)
tree023f4f231fc30de0c2e922f6e4af2ba61c28539b /llvm/lib
parent4ad7e8d2633f303fe51f14ae6a69dfe84c7ec818 (diff)
downloadbcm5719-llvm-1a582582324bf0039da4cb0db8dbe827deda66c8.tar.gz
bcm5719-llvm-1a582582324bf0039da4cb0db8dbe827deda66c8.zip
NewGVN: Detect copies through predicateinfo
llvm-svn: 312508
Diffstat (limited to 'llvm/lib')
-rw-r--r--llvm/lib/Transforms/Scalar/NewGVN.cpp13
1 files changed, 12 insertions, 1 deletions
diff --git a/llvm/lib/Transforms/Scalar/NewGVN.cpp b/llvm/lib/Transforms/Scalar/NewGVN.cpp
index e9046d9af05..a2f008e70e3 100644
--- a/llvm/lib/Transforms/Scalar/NewGVN.cpp
+++ b/llvm/lib/Transforms/Scalar/NewGVN.cpp
@@ -850,6 +850,17 @@ void NewGVN::deleteExpression(const Expression *E) const {
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::createPHIExpression(Instruction *I, bool &HasBackedge,
// 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;
OpenPOWER on IntegriCloud