summaryrefslogtreecommitdiff
path: root/test/Transforms
diff options
context:
space:
mode:
authorAditya Kumar <hiraditya@msn.com>2017-12-13 19:40:07 +0000
committerAditya Kumar <hiraditya@msn.com>2017-12-13 19:40:07 +0000
commit2bf4af887ec2aa30a4014c64ac9df026917d9e12 (patch)
tree8af82eff0b568541f31eb4a405a62c0bea8ca645 /test/Transforms
parent267645038a86f99779cfe82b230c47c494dbe4a3 (diff)
[GVNHoist] Fix: PR35222 gvn-hoist incorrectly erases load
w.r.t. the paper "A Practical Improvement to the Partial Redundancy Elimination in SSA Form" (https://sites.google.com/site/jongsoopark/home/ssapre.pdf) Proper dominance check was missing here, so having a loopinfo should not be required. Committing this diff as this fixes the bug, if there are further concerns, I'll be happy to work on them. Differential Revision: https://reviews.llvm.org/D39781 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@320607 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/Transforms')
-rw-r--r--test/Transforms/GVNHoist/pr35222-hoist-load.ll25
1 files changed, 25 insertions, 0 deletions
diff --git a/test/Transforms/GVNHoist/pr35222-hoist-load.ll b/test/Transforms/GVNHoist/pr35222-hoist-load.ll
new file mode 100644
index 00000000000..7e9c6200616
--- /dev/null
+++ b/test/Transforms/GVNHoist/pr35222-hoist-load.ll
@@ -0,0 +1,25 @@
+; RUN: opt -S -gvn-hoist < %s | FileCheck %s
+; CHECK: load
+; CHECK: load
+; Check that the load is not hoisted because the call can potentially
+; modify the global
+
+target datalayout = "e-m:e-p:32:32-i64:64-v128:64:128-a:0:32-n32-S64"
+
+@heap = external global i32, align 4
+
+define i32 @build_tree() unnamed_addr {
+entry:
+ br label %do.body
+
+do.body: ; preds = %do.body, %entry
+ %tmp9 = load i32, i32* @heap, align 4
+ %cmp = call i1 @pqdownheap(i32 %tmp9)
+ br i1 %cmp, label %do.body, label %do.end
+
+do.end: ; preds = %do.body
+ %tmp20 = load i32, i32* @heap, align 4
+ ret i32 %tmp20
+}
+
+declare i1 @pqdownheap(i32)