[llvm] r303521 - NewGVN: Fix PR 33116, the memoryphi version of bug 32838.
Daniel Berlin via llvm-commits
llvm-commits at lists.llvm.org
Sun May 21 16:41:59 PDT 2017
Author: dannyb
Date: Sun May 21 18:41:58 2017
New Revision: 303521
URL: http://llvm.org/viewvc/llvm-project?rev=303521&view=rev
Log:
NewGVN: Fix PR 33116, the memoryphi version of bug 32838.
Added:
llvm/trunk/test/Transforms/NewGVN/pr33116.ll
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=303521&r1=303520&r2=303521&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Scalar/NewGVN.cpp (original)
+++ llvm/trunk/lib/Transforms/Scalar/NewGVN.cpp Sun May 21 18:41:58 2017
@@ -61,7 +61,6 @@
#include "llvm/ADT/STLExtras.h"
#include "llvm/ADT/SmallPtrSet.h"
#include "llvm/ADT/SmallSet.h"
-#include "llvm/ADT/SparseBitVector.h"
#include "llvm/ADT/Statistic.h"
#include "llvm/ADT/TinyPtrVector.h"
#include "llvm/Analysis/AliasAnalysis.h"
@@ -1224,7 +1223,6 @@ const Expression *NewGVN::performSymboli
// If we bypassed the use-def chains, make sure we add a use.
if (StoreRHS != StoreAccess->getDefiningAccess())
addMemoryUsers(StoreRHS, StoreAccess);
-
StoreRHS = lookupMemoryLeader(StoreRHS);
// If we are defined by ourselves, use the live on entry def.
if (StoreRHS == StoreAccess)
@@ -1596,7 +1594,7 @@ const Expression *NewGVN::performSymboli
// See if all arguments are the same.
// We track if any were undef because they need special handling.
bool HasUndef = false;
- bool CycleFree = isCycleFree(cast<PHINode>(I));
+ bool CycleFree = isCycleFree(I);
auto Filtered = make_filter_range(E->operands(), [&](Value *Arg) {
if (Arg == nullptr)
return false;
@@ -2709,11 +2707,12 @@ void NewGVN::updateProcessedCount(const
// Evaluate MemoryPhi nodes symbolically, just like PHI nodes
void NewGVN::valueNumberMemoryPhi(MemoryPhi *MP) {
// If all the arguments are the same, the MemoryPhi has the same value as the
- // argument.
- // Filter out unreachable blocks and self phis from our operands.
+ // argument. Filter out unreachable blocks and self phis from our operands.
+ // TODO: We could do cycle-checking on the memory phis to allow valueizing for
+ // self-phi checking.
const BasicBlock *PHIBlock = MP->getBlock();
auto Filtered = make_filter_range(MP->operands(), [&](const Use &U) {
- return lookupMemoryLeader(cast<MemoryAccess>(U)) != MP &&
+ return cast<MemoryAccess>(U) != MP &&
!isMemoryAccessTOP(cast<MemoryAccess>(U)) &&
ReachableEdges.count({MP->getIncomingBlock(U), PHIBlock});
});
Added: llvm/trunk/test/Transforms/NewGVN/pr33116.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/NewGVN/pr33116.ll?rev=303521&view=auto
==============================================================================
--- llvm/trunk/test/Transforms/NewGVN/pr33116.ll (added)
+++ llvm/trunk/test/Transforms/NewGVN/pr33116.ll Sun May 21 18:41:58 2017
@@ -0,0 +1,39 @@
+; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
+; RUN: opt -S -newgvn %s | FileCheck %s
+
+ at a = external global i32
+
+define void @b() {
+; CHECK-LABEL: @b(
+; CHECK-NEXT: br i1 false, label [[C:%.*]], label [[WHILE_D:%.*]]
+; CHECK: while.d:
+; CHECK-NEXT: br label [[F:%.*]]
+; CHECK: f:
+; CHECK-NEXT: br i1 undef, label [[IF_E:%.*]], label [[C]]
+; CHECK: c:
+; CHECK-NEXT: br i1 undef, label [[IF_G:%.*]], label [[IF_E]]
+; CHECK: if.g:
+; CHECK-NEXT: store i32 undef, i32* @a
+; CHECK-NEXT: br label [[WHILE_D]]
+; CHECK: if.e:
+; CHECK-NEXT: br label [[F]]
+;
+ br i1 false, label %c, label %while.d
+
+while.d: ; preds = %if.g, %0
+ br label %f
+
+f: ; preds = %if.e, %while.d
+ br i1 undef, label %if.e, label %c
+
+c: ; preds = %f, %0
+ br i1 undef, label %if.g, label %if.e
+
+if.g: ; preds = %c
+ store i32 undef, i32* @a
+ br label %while.d
+
+if.e: ; preds = %c, %f
+ br label %f
+}
+
More information about the llvm-commits
mailing list