blob: 86b017c9cb34d0bf5ba384028cbf83c0db0e8686 [file] [log] [blame]
Chris Lattner58601062004-10-07 19:16:26 +00001; Test that PHI nodes and select instructions do not necessarily make stuff
2; non-constant.
3
Justin Bogner6f6c5f22016-04-25 23:36:50 +00004; RUN: opt < %s -globalopt -S | FileCheck %s
5; CHECK-NOT: global
Chris Lattner58601062004-10-07 19:16:26 +00006
Tanya Lattner5640bd12008-03-01 09:15:35 +00007@X = internal global i32 4 ; <i32*> [#uses=2]
8@Y = internal global i32 5 ; <i32*> [#uses=2]
Chris Lattner58601062004-10-07 19:16:26 +00009
Tanya Lattner5640bd12008-03-01 09:15:35 +000010define i32 @test1(i1 %C) {
11 %P = select i1 %C, i32* @X, i32* @Y ; <i32*> [#uses=1]
David Blaikiea79ac142015-02-27 21:17:42 +000012 %V = load i32, i32* %P ; <i32> [#uses=1]
Tanya Lattner5640bd12008-03-01 09:15:35 +000013 ret i32 %V
Chris Lattner58601062004-10-07 19:16:26 +000014}
15
Tanya Lattner5640bd12008-03-01 09:15:35 +000016define i32 @test2(i1 %C) {
17; <label>:0
18 br i1 %C, label %T, label %Cont
Chris Lattner58601062004-10-07 19:16:26 +000019
Tanya Lattner5640bd12008-03-01 09:15:35 +000020T: ; preds = %0
21 br label %Cont
22
23Cont: ; preds = %T, %0
24 %P = phi i32* [ @X, %0 ], [ @Y, %T ] ; <i32*> [#uses=1]
David Blaikiea79ac142015-02-27 21:17:42 +000025 %V = load i32, i32* %P ; <i32> [#uses=1]
Tanya Lattner5640bd12008-03-01 09:15:35 +000026 ret i32 %V
Chris Lattner58601062004-10-07 19:16:26 +000027}