diff options
author | Chris Lattner <sabre@nondot.org> | 2011-01-03 03:18:43 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2011-01-03 03:18:43 +0000 |
commit | 8e7f0d70c7dd3864126c746378a7b928d57f971f (patch) | |
tree | 869b2b51e3648bedb947e5093c660db2a9097144 /test | |
parent | 152096275ad45bb13d5652f7019f48be5ccd67f8 (diff) | |
download | external_llvm-8e7f0d70c7dd3864126c746378a7b928d57f971f.zip external_llvm-8e7f0d70c7dd3864126c746378a7b928d57f971f.tar.gz external_llvm-8e7f0d70c7dd3864126c746378a7b928d57f971f.tar.bz2 |
Teach EarlyCSE to do trivial CSE of loads and read-only calls.
On 176.gcc, this catches 13090 loads and calls, and increases the
number of simple instructions CSE'd from 29658 to 36208.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@122727 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test')
-rw-r--r-- | test/Transforms/EarlyCSE/basic.ll | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/test/Transforms/EarlyCSE/basic.ll b/test/Transforms/EarlyCSE/basic.ll index 6cfd0a9..a761ef7 100644 --- a/test/Transforms/EarlyCSE/basic.ll +++ b/test/Transforms/EarlyCSE/basic.ll @@ -30,3 +30,48 @@ define void @test1(i8 %V, i32 *%P) { ; CHECK-NEXT: volatile store i32 %G ret void } + + +;; Simple load value numbering. +; CHECK: @test2 +define i32 @test2(i32 *%P) { + %V1 = load i32* %P + %V2 = load i32* %P + %Diff = sub i32 %V1, %V2 + ret i32 %Diff + ; CHECK: ret i32 0 +} + +;; Cross block load value numbering. +; CHECK: @test3 +define i32 @test3(i32 *%P, i1 %Cond) { + %V1 = load i32* %P + br i1 %Cond, label %T, label %F +T: + store i32 4, i32* %P + ret i32 42 +F: + %V2 = load i32* %P + %Diff = sub i32 %V1, %V2 + ret i32 %Diff + ; CHECK: F: + ; CHECK: ret i32 0 +} + +;; Cross block load value numbering stops when stores happen. +; CHECK: @test4 +define i32 @test4(i32 *%P, i1 %Cond) { + %V1 = load i32* %P + br i1 %Cond, label %T, label %F +T: + ret i32 42 +F: + ; Clobbers V1 + store i32 42, i32* %P + + %V2 = load i32* %P + %Diff = sub i32 %V1, %V2 + ret i32 %Diff + ; CHECK: F: + ; CHECK: ret i32 %Diff +} |