llvm.org GIT mirror llvm / cc24c88
NewGVN: Fix PR 33116, the memoryphi version of bug 32838. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@303521 91177308-0d34-0410-b5e6-96231b3b80d8 Daniel Berlin 2 years ago
2 changed file(s) with 44 addition(s) and 6 deletion(s). Raw diff Collapse all Expand all
6060 #include "llvm/ADT/STLExtras.h"
6161 #include "llvm/ADT/SmallPtrSet.h"
6262 #include "llvm/ADT/SmallSet.h"
63 #include "llvm/ADT/SparseBitVector.h"
6463 #include "llvm/ADT/Statistic.h"
6564 #include "llvm/ADT/TinyPtrVector.h"
6665 #include "llvm/Analysis/AliasAnalysis.h"
12231222 // If we bypassed the use-def chains, make sure we add a use.
12241223 if (StoreRHS != StoreAccess->getDefiningAccess())
12251224 addMemoryUsers(StoreRHS, StoreAccess);
1226
12271225 StoreRHS = lookupMemoryLeader(StoreRHS);
12281226 // If we are defined by ourselves, use the live on entry def.
12291227 if (StoreRHS == StoreAccess)
15951593 // See if all arguments are the same.
15961594 // We track if any were undef because they need special handling.
15971595 bool HasUndef = false;
1598 bool CycleFree = isCycleFree(cast(I));
1596 bool CycleFree = isCycleFree(I);
15991597 auto Filtered = make_filter_range(E->operands(), [&](Value *Arg) {
16001598 if (Arg == nullptr)
16011599 return false;
27082706 // Evaluate MemoryPhi nodes symbolically, just like PHI nodes
27092707 void NewGVN::valueNumberMemoryPhi(MemoryPhi *MP) {
27102708 // If all the arguments are the same, the MemoryPhi has the same value as the
2711 // argument.
2712 // Filter out unreachable blocks and self phis from our operands.
2709 // argument. Filter out unreachable blocks and self phis from our operands.
2710 // TODO: We could do cycle-checking on the memory phis to allow valueizing for
2711 // self-phi checking.
27132712 const BasicBlock *PHIBlock = MP->getBlock();
27142713 auto Filtered = make_filter_range(MP->operands(), [&](const Use &U) {
2715 return lookupMemoryLeader(cast(U)) != MP &&
2714 return cast(U) != MP &&
27162715 !isMemoryAccessTOP(cast(U)) &&
27172716 ReachableEdges.count({MP->getIncomingBlock(U), PHIBlock});
27182717 });
0 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
1 ; RUN: opt -S -newgvn %s | FileCheck %s
2
3 @a = external global i32
4
5 define void @b() {
6 ; CHECK-LABEL: @b(
7 ; CHECK-NEXT: br i1 false, label [[C:%.*]], label [[WHILE_D:%.*]]
8 ; CHECK: while.d:
9 ; CHECK-NEXT: br label [[F:%.*]]
10 ; CHECK: f:
11 ; CHECK-NEXT: br i1 undef, label [[IF_E:%.*]], label [[C]]
12 ; CHECK: c:
13 ; CHECK-NEXT: br i1 undef, label [[IF_G:%.*]], label [[IF_E]]
14 ; CHECK: if.g:
15 ; CHECK-NEXT: store i32 undef, i32* @a
16 ; CHECK-NEXT: br label [[WHILE_D]]
17 ; CHECK: if.e:
18 ; CHECK-NEXT: br label [[F]]
19 ;
20 br i1 false, label %c, label %while.d
21
22 while.d: ; preds = %if.g, %0
23 br label %f
24
25 f: ; preds = %if.e, %while.d
26 br i1 undef, label %if.e, label %c
27
28 c: ; preds = %f, %0
29 br i1 undef, label %if.g, label %if.e
30
31 if.g: ; preds = %c
32 store i32 undef, i32* @a
33 br label %while.d
34
35 if.e: ; preds = %c, %f
36 br label %f
37 }
38