blob: ad9ba5e18e1fd764389438e0d3cf4e6cf833fca0 [file] [log] [blame]
Tanya Lattnera695f012008-02-14 06:56:27 +00001; This testcase ensures that redundant loads are eliminated when they should
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002; be. All RL variables (redundant loads) should be eliminated.
3;
Tanya Lattnera695f012008-02-14 06:56:27 +00004; RUN: llvm-as < %s | opt -load-vn -gcse | llvm-dis | not grep %RL
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005;
Tanya Lattnera695f012008-02-14 06:56:27 +00006
7define i32 @test1(i32* %P) {
8 %A = load i32* %P ; <i32> [#uses=1]
9 %RL = load i32* %P ; <i32> [#uses=1]
10 %C = add i32 %A, %RL ; <i32> [#uses=1]
11 ret i32 %C
Dan Gohmanf17a25c2007-07-18 16:29:46 +000012}
13
Tanya Lattnera695f012008-02-14 06:56:27 +000014define i32 @test2(i32* %P) {
15 %A = load i32* %P ; <i32> [#uses=1]
Dan Gohmanf17a25c2007-07-18 16:29:46 +000016 br label %BB2
Dan Gohmanf17a25c2007-07-18 16:29:46 +000017
Tanya Lattnera695f012008-02-14 06:56:27 +000018BB2: ; preds = %0
19 br label %BB3
20
21BB3: ; preds = %BB2
22 %RL = load i32* %P ; <i32> [#uses=1]
23 %B = add i32 %A, %RL ; <i32> [#uses=1]
24 ret i32 %B
25}