blob: f2c079488e9633ab16d4e19424cdc63481bdf1df [file] [log] [blame]
Tanya Lattnera695f012008-02-14 06:56:27 +00001; This testcase ensures that redundant loads are preserved when they are not
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002; allowed to be eliminated.
Tanya Lattnera695f012008-02-14 06:56:27 +00003; RUN: llvm-as < %s | opt -load-vn -gcse | llvm-dis | grep sub
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004;
Tanya Lattnera695f012008-02-14 06:56:27 +00005
6define i32 @test1(i32* %P) {
7 %A = load i32* %P ; <i32> [#uses=1]
8 store i32 1, i32* %P
9 %B = load i32* %P ; <i32> [#uses=1]
10 %C = sub i32 %A, %B ; <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
Tanya Lattnera695f012008-02-14 06:56:27 +000017
18BB2: ; preds = %0
19 store i32 5, i32* %P
Dan Gohmanf17a25c2007-07-18 16:29:46 +000020 br label %BB3
Tanya Lattnera695f012008-02-14 06:56:27 +000021
22BB3: ; preds = %BB2
23 %B = load i32* %P ; <i32> [#uses=1]
24 %C = sub i32 %A, %B ; <i32> [#uses=1]
25 ret i32 %C
Dan Gohmanf17a25c2007-07-18 16:29:46 +000026}