blob: 1734752dcdeb6e4695f104b8556434fcfdfef8ae [file] [log] [blame]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001; Test that PHI nodes and select instructions do not necessarily make stuff
2; non-constant.
3
Dan Gohman5bb7c7c2009-09-08 22:34:10 +00004; RUN: opt %s -globalopt -S | not grep global
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005
Tanya Lattner4c4d0b82008-03-01 09:15:35 +00006@X = internal global i32 4 ; <i32*> [#uses=2]
7@Y = internal global i32 5 ; <i32*> [#uses=2]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00008
Tanya Lattner4c4d0b82008-03-01 09:15:35 +00009define i32 @test1(i1 %C) {
10 %P = select i1 %C, i32* @X, i32* @Y ; <i32*> [#uses=1]
11 %V = load i32* %P ; <i32> [#uses=1]
12 ret i32 %V
Dan Gohmanf17a25c2007-07-18 16:29:46 +000013}
14
Tanya Lattner4c4d0b82008-03-01 09:15:35 +000015define i32 @test2(i1 %C) {
16; <label>:0
17 br i1 %C, label %T, label %Cont
Dan Gohmanf17a25c2007-07-18 16:29:46 +000018
Tanya Lattner4c4d0b82008-03-01 09:15:35 +000019T: ; preds = %0
20 br label %Cont
21
22Cont: ; preds = %T, %0
23 %P = phi i32* [ @X, %0 ], [ @Y, %T ] ; <i32*> [#uses=1]
24 %V = load i32* %P ; <i32> [#uses=1]
25 ret i32 %V
Dan Gohmanf17a25c2007-07-18 16:29:46 +000026}
27
28
29
30
31