summaryrefslogtreecommitdiff
path: root/test/Transforms/GVN
diff options
context:
space:
mode:
authorDuncan Sands <baldrick@free.fr>2012-03-04 13:25:19 +0000
committerDuncan Sands <baldrick@free.fr>2012-03-04 13:25:19 +0000
commit190e5a3314808fc126f18119315ce986d0689089 (patch)
tree4e3c82a9f94f9a2f2982db16d687053759a5d9e6 /test/Transforms/GVN
parented7692a136a9bcf513b91b7b5eb33a1e2d83e7ee (diff)
downloadllvm-190e5a3314808fc126f18119315ce986d0689089.tar.gz
llvm-190e5a3314808fc126f18119315ce986d0689089.tar.bz2
llvm-190e5a3314808fc126f18119315ce986d0689089.tar.xz
Nick pointed out on IRC that GVN's propagateEquality wasn't propagating
equalities into phi node operands for which the equality is known to hold in the incoming basic block. That's because replaceAllDominatedUsesWith wasn't handling phi nodes correctly in general (that this didn't give wrong results was just luck: the specific way GVN uses replaceAllDominatedUsesWith precluded wrong changes to phi nodes). git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@152006 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/Transforms/GVN')
-rw-r--r--test/Transforms/GVN/condprop.ll17
1 files changed, 17 insertions, 0 deletions
diff --git a/test/Transforms/GVN/condprop.ll b/test/Transforms/GVN/condprop.ll
index b22675b47c..9c28955801 100644
--- a/test/Transforms/GVN/condprop.ll
+++ b/test/Transforms/GVN/condprop.ll
@@ -232,3 +232,20 @@ cond_true2:
next2:
ret i32 0
}
+
+; CHECK: @test12
+define i32 @test12(i32 %x) {
+ %cmp = icmp eq i32 %x, 0
+ br i1 %cmp, label %cond_true, label %cond_false
+
+cond_true:
+ br label %ret
+
+cond_false:
+ br label %ret
+
+ret:
+ %res = phi i32 [ %x, %cond_true ], [ %x, %cond_false ]
+; CHECK: %res = phi i32 [ 0, %cond_true ], [ %x, %cond_false ]
+ ret i32 %res
+}