diff options
author | Rafael Espindola <rafael.espindola@gmail.com> | 2012-08-16 15:09:43 +0000 |
---|---|---|
committer | Rafael Espindola <rafael.espindola@gmail.com> | 2012-08-16 15:09:43 +0000 |
commit | 05130597262f3ed00dc4881d64795d117c76e3fc (patch) | |
tree | e2ce3458ce795313234a1bde18158542a0907a44 /test | |
parent | 52b7ec68d221d65aacbe9b55de325c9b7370b59d (diff) | |
download | external_llvm-05130597262f3ed00dc4881d64795d117c76e3fc.zip external_llvm-05130597262f3ed00dc4881d64795d117c76e3fc.tar.gz external_llvm-05130597262f3ed00dc4881d64795d117c76e3fc.tar.bz2 |
Teach GVN to reason about edges dominating uses. This allows it to handle cases
where some fact lake a=b dominates a use in a phi, but doesn't dominate the
basic block itself.
This feature could also be implemented by splitting critical edges, but at least
with the current algorithm reasoning about the dominance directly is faster.
The time for running "opt -O2" in the testcase in pr10584 is 1.003 times slower
and on gcc as a single file it is 1.0007 times faster.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@162023 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test')
-rw-r--r-- | test/Transforms/GVN/edge.ll | 60 |
1 files changed, 60 insertions, 0 deletions
diff --git a/test/Transforms/GVN/edge.ll b/test/Transforms/GVN/edge.ll new file mode 100644 index 0000000..32392f3 --- /dev/null +++ b/test/Transforms/GVN/edge.ll @@ -0,0 +1,60 @@ +; RUN: opt %s -gvn -S -o - | FileCheck %s + +define i32 @f1(i32 %x) { + ; CHECK: define i32 @f1( +bb0: + %cmp = icmp eq i32 %x, 0 + br i1 %cmp, label %bb2, label %bb1 +bb1: + br label %bb2 +bb2: + %cond = phi i32 [ %x, %bb0 ], [ 0, %bb1 ] + %foo = add i32 %cond, %x + ret i32 %foo + ; CHECK: bb2: + ; CHECK: ret i32 %x +} + +define i32 @f2(i32 %x) { + ; CHECK: define i32 @f2( +bb0: + %cmp = icmp ne i32 %x, 0 + br i1 %cmp, label %bb1, label %bb2 +bb1: + br label %bb2 +bb2: + %cond = phi i32 [ %x, %bb0 ], [ 0, %bb1 ] + %foo = add i32 %cond, %x + ret i32 %foo + ; CHECK: bb2: + ; CHECK: ret i32 %x +} + +define i32 @f3(i32 %x) { + ; CHECK: define i32 @f3( +bb0: + switch i32 %x, label %bb1 [ i32 0, label %bb2] +bb1: + br label %bb2 +bb2: + %cond = phi i32 [ %x, %bb0 ], [ 0, %bb1 ] + %foo = add i32 %cond, %x + ret i32 %foo + ; CHECK: bb2: + ; CHECK: ret i32 %x +} + +declare void @g(i1) +define void @f4(i8 * %x) { +; CHECK: define void @f4( +bb0: + %y = icmp eq i8* null, %x + br i1 %y, label %bb2, label %bb1 +bb1: + br label %bb2 +bb2: + %zed = icmp eq i8* null, %x + call void @g(i1 %zed) +; CHECK: call void @g(i1 %y) + ret void +} |