From 8e7f0d70c7dd3864126c746378a7b928d57f971f Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Mon, 3 Jan 2011 03:18:43 +0000 Subject: 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 --- test/Transforms/EarlyCSE/basic.ll | 45 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) (limited to 'test') 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 +} -- cgit v1.1