1 ; This test makes sure that these instructions are properly eliminated. 2 ; 3 ; RUN: opt < %s -instcombine -S | not grep load 4 5 @X = constant i32 42 ; <i32*> [#uses=2] 6 @X2 = constant i32 47 ; <i32*> [#uses=1] 7 @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] 8 @Z = constant [2 x { i32, float }] zeroinitializer ; <[2 x { i32, float }]*> [#uses=1] 9 10 @GLOBAL = internal constant [4 x i32] zeroinitializer 11 12 13 define i32 @test1() { 14 %B = load i32* @X ; <i32> [#uses=1] 15 ret i32 %B 16 } 17 18 define float @test2() { 19 %A = getelementptr [2 x { i32, float }]* @Y, i64 0, i64 1, i32 1 ; <float*> [#uses=1] 20 %B = load float* %A ; <float> [#uses=1] 21 ret float %B 22 } 23 24 define i32 @test3() { 25 %A = getelementptr [2 x { i32, float }]* @Y, i64 0, i64 0, i32 0 ; <i32*> [#uses=1] 26 %B = load i32* %A ; <i32> [#uses=1] 27 ret i32 %B 28 } 29 30 define i32 @test4() { 31 %A = getelementptr [2 x { i32, float }]* @Z, i64 0, i64 1, i32 0 ; <i32*> [#uses=1] 32 %B = load i32* %A ; <i32> [#uses=1] 33 ret i32 %B 34 } 35 36 define i32 @test5(i1 %C) { 37 %Y = select i1 %C, i32* @X, i32* @X2 ; <i32*> [#uses=1] 38 %Z = load i32* %Y ; <i32> [#uses=1] 39 ret i32 %Z 40 } 41 42 define i32 @test7(i32 %X) { 43 %V = getelementptr i32* null, i32 %X ; <i32*> [#uses=1] 44 %R = load i32* %V ; <i32> [#uses=1] 45 ret i32 %R 46 } 47 48 define i32 @test8(i32* %P) { 49 store i32 1, i32* %P 50 %X = load i32* %P ; <i32> [#uses=1] 51 ret i32 %X 52 } 53 54 define i32 @test9(i32* %P) { 55 %X = load i32* %P ; <i32> [#uses=1] 56 %Y = load i32* %P ; <i32> [#uses=1] 57 %Z = sub i32 %X, %Y ; <i32> [#uses=1] 58 ret i32 %Z 59 } 60 61 define i32 @test10(i1 %C.upgrd.1, i32* %P, i32* %Q) { 62 br i1 %C.upgrd.1, label %T, label %F 63 T: ; preds = %0 64 store i32 1, i32* %Q 65 store i32 0, i32* %P 66 br label %C 67 F: ; preds = %0 68 store i32 0, i32* %P 69 br label %C 70 C: ; preds = %F, %T 71 %V = load i32* %P ; <i32> [#uses=1] 72 ret i32 %V 73 } 74 75 define double @test11(double* %p) { 76 %t0 = getelementptr double* %p, i32 1 77 store double 2.0, double* %t0 78 %t1 = getelementptr double* %p, i32 1 79 %x = load double* %t1 80 ret double %x 81 } 82 83 define i32 @test12(i32* %P) { 84 %A = alloca i32 85 store i32 123, i32* %A 86 ; Cast the result of the load not the source 87 %Q = bitcast i32* %A to i32* 88 %V = load i32* %Q 89 ret i32 %V 90 } 91 92 define <16 x i8> @test13(<2 x i64> %x) { 93 entry: 94 %tmp = load <16 x i8> * bitcast ([4 x i32]* @GLOBAL to <16 x i8>*) 95 ret <16 x i8> %tmp 96 } 97 98 99