llvm.org GIT mirror llvm / dcef4a7
Merging r321789: ------------------------------------------------------------------------ r321789 | hiraditya | 2018-01-03 23:47:24 -0800 (Wed, 03 Jan 2018) | 8 lines [GVNHoist] Fix: PR35222 gvn-hoist incorrectly erases load in case of a loop Reviewers: dberlin sebpop eli.friedman Differential Revision: https://reviews.llvm.org/D41453 ------------------------------------------------------------------------ git-svn-id: https://llvm.org/svn/llvm-project/llvm/branches/release_60@322558 91177308-0d34-0410-b5e6-96231b3b80d8 Hans Wennborg 1 year, 8 months ago
2 changed file(s) with 46 addition(s) and 1 deletion(s). Raw diff Collapse all Expand all
647647 // track in a CHI. In the PDom walk, there can be values in the
648648 // stack which are not control dependent e.g., nested loop.
649649 if (si != RenameStack.end() && si->second.size() &&
650 DT->dominates(Pred, si->second.back()->getParent())) {
650 DT->properlyDominates(Pred, si->second.back()->getParent())) {
651651 C.Dest = BB; // Assign the edge
652652 C.I = si->second.pop_back_val(); // Assign the argument
653653 DEBUG(dbgs() << "\nCHI Inserted in BB: " << C.Dest->getName()
0 ; RUN: opt -S -gvn-hoist < %s | FileCheck %s
1 ; CHECK-LABEL: build_tree
12 ; CHECK: load
23 ; CHECK: load
34 ; Check that the load is not hoisted because the call can potentially
2223 }
2324
2425 declare i1 @pqdownheap(i32)
26
27 @i = external hidden unnamed_addr global i32, align 4
28 @j = external hidden unnamed_addr global [573 x i32], align 4
29 @v = external global i1
30
31 ; CHECK-LABEL: test
32 ; CHECK-LABEL: do.end
33 ; CHECK: load
34 ; Check that the load is not hoisted because the call can potentially
35 ; modify the global
36
37 define i32 @test() {
38 entry:
39 br label %for.cond
40
41 for.cond:
42 %a3 = load volatile i1, i1* @v
43 br i1 %a3, label %for.body, label %while.end
44
45 for.body:
46 br label %if.then
47
48 if.then:
49 %tmp4 = load i32, i32* @i, align 4
50 br label %for.cond
51
52 while.end:
53 br label %do.body
54
55 do.body:
56 %tmp9 = load i32, i32* getelementptr inbounds ([573 x i32], [573 x i32]* @j,
57 i32 0, i32 1), align 4
58 %tmp10 = load i32, i32* @i, align 4
59 call void @fn()
60 %a1 = load volatile i1, i1* @v
61 br i1 %a1, label %do.body, label %do.end
62
63 do.end:
64 %tmp20 = load i32, i32* getelementptr inbounds ([573 x i32], [573 x i32]* @j,
65 i32 0, i32 1), align 4
66 ret i32 %tmp20
67 }
68
69 declare void @fn()