blob: add2af483f56040142f5cda03b4f1173d5f05ed1 [file] [log] [blame]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001; This test makes sure that these instructions are properly constant propagated.
Chris Lattner0148bb22009-11-02 06:06:14 +00002
3target datalayout = "e-p:32:32"
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004
Dan Gohman5bb7c7c2009-09-08 22:34:10 +00005; RUN: opt < %s -sccp -S | not grep load
Dan Gohmanf17a25c2007-07-18 16:29:46 +00006
Tanya Lattnerba93e2d2008-03-19 04:14:49 +00007
8@X = constant i32 42 ; <i32*> [#uses=1]
9@Y = constant [2 x { i32, float }] [ { i32, float } { i32 12, float 1.000000e+00 }, { i32, float } { i32 37, float 0x3FF3B2FEC0000000 } ] ; <[2 x { i32, float }]*> [#uses=2]
10
11define i32 @test1() {
12 %B = load i32* @X ; <i32> [#uses=1]
13 ret i32 %B
Dan Gohmanf17a25c2007-07-18 16:29:46 +000014}
15
Tanya Lattnerba93e2d2008-03-19 04:14:49 +000016define float @test2() {
17 %A = getelementptr [2 x { i32, float }]* @Y, i64 0, i64 1, i32 1 ; <float*> [#uses=1]
18 %B = load float* %A ; <float> [#uses=1]
Dan Gohmanf17a25c2007-07-18 16:29:46 +000019 ret float %B
20}
21
Tanya Lattnerba93e2d2008-03-19 04:14:49 +000022define i32 @test3() {
23 %A = getelementptr [2 x { i32, float }]* @Y, i64 0, i64 0, i32 0 ; <i32*> [#uses=1]
Chris Lattner0148bb22009-11-02 06:06:14 +000024 %B = load i32* %A
Tanya Lattnerba93e2d2008-03-19 04:14:49 +000025 ret i32 %B
Dan Gohmanf17a25c2007-07-18 16:29:46 +000026}
27
Chris Lattner0148bb22009-11-02 06:06:14 +000028define i8 @test4() {
29 %A = bitcast i32* @X to i8*
30 %B = load i8* %A
31 ret i8 %B
32}
33