Dan Gohman | 3c7d308 | 2009-09-11 18:01:28 +0000 | [diff] [blame] | 1 | ; RUN: opt < %s -scalarrepl -S | not grep alloca |
Chris Lattner | 71c7534 | 2009-01-07 08:11:13 +0000 | [diff] [blame] | 2 | ; PR3290 |
Kenneth Uildriks | a092c12 | 2009-11-03 15:29:06 +0000 | [diff] [blame^] | 3 | target datalayout = "E-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64" |
Chris Lattner | 71c7534 | 2009-01-07 08:11:13 +0000 | [diff] [blame] | 4 | |
| 5 | ;; Store of integer to whole alloca struct. |
| 6 | define i32 @test1(i64 %V) nounwind { |
| 7 | %X = alloca {{i32, i32}} |
| 8 | %Y = bitcast {{i32,i32}}* %X to i64* |
| 9 | store i64 %V, i64* %Y |
| 10 | |
| 11 | %A = getelementptr {{i32,i32}}* %X, i32 0, i32 0, i32 0 |
| 12 | %B = getelementptr {{i32,i32}}* %X, i32 0, i32 0, i32 1 |
| 13 | %a = load i32* %A |
| 14 | %b = load i32* %B |
| 15 | %c = add i32 %a, %b |
| 16 | ret i32 %c |
| 17 | } |
| 18 | |
| 19 | ;; Store of integer to whole struct/array alloca. |
| 20 | define float @test2(i128 %V) nounwind { |
| 21 | %X = alloca {[4 x float]} |
| 22 | %Y = bitcast {[4 x float]}* %X to i128* |
| 23 | store i128 %V, i128* %Y |
| 24 | |
| 25 | %A = getelementptr {[4 x float]}* %X, i32 0, i32 0, i32 0 |
| 26 | %B = getelementptr {[4 x float]}* %X, i32 0, i32 0, i32 3 |
| 27 | %a = load float* %A |
| 28 | %b = load float* %B |
Dan Gohman | 7ce405e | 2009-06-04 22:49:04 +0000 | [diff] [blame] | 29 | %c = fadd float %a, %b |
Chris Lattner | 71c7534 | 2009-01-07 08:11:13 +0000 | [diff] [blame] | 30 | ret float %c |
| 31 | } |
| 32 | |
Chris Lattner | 28401db | 2009-01-08 05:42:05 +0000 | [diff] [blame] | 33 | ;; Load of whole alloca struct as integer |
| 34 | define i64 @test3(i32 %a, i32 %b) nounwind { |
| 35 | %X = alloca {{i32, i32}} |
| 36 | |
| 37 | %A = getelementptr {{i32,i32}}* %X, i32 0, i32 0, i32 0 |
| 38 | %B = getelementptr {{i32,i32}}* %X, i32 0, i32 0, i32 1 |
| 39 | store i32 %a, i32* %A |
| 40 | store i32 %b, i32* %B |
| 41 | |
| 42 | %Y = bitcast {{i32,i32}}* %X to i64* |
| 43 | %Z = load i64* %Y |
| 44 | ret i64 %Z |
| 45 | } |
| 46 | |
| 47 | ;; load of integer from whole struct/array alloca. |
| 48 | define i128 @test4(float %a, float %b) nounwind { |
| 49 | %X = alloca {[4 x float]} |
| 50 | %A = getelementptr {[4 x float]}* %X, i32 0, i32 0, i32 0 |
| 51 | %B = getelementptr {[4 x float]}* %X, i32 0, i32 0, i32 3 |
| 52 | store float %a, float* %A |
| 53 | store float %b, float* %B |
| 54 | |
| 55 | %Y = bitcast {[4 x float]}* %X to i128* |
| 56 | %V = load i128* %Y |
| 57 | ret i128 %V |
| 58 | } |