Hal Finkel | 9caa8f7 | 2013-07-16 17:10:55 +0000 | [diff] [blame] | 1 | ; RUN: opt < %s -inline -S | FileCheck %s |
| 2 | |
| 3 | target datalayout = "E-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-f128:128:128-v128:128:128-n32:64" |
| 4 | target triple = "powerpc64-unknown-linux-gnu" |
| 5 | |
| 6 | %struct.s = type { i32, i32 } |
| 7 | |
| 8 | define void @foo(%struct.s* byval nocapture readonly %a) { |
| 9 | entry: |
| 10 | %x = alloca [2 x i32], align 4 |
David Blaikie | 79e6c74 | 2015-02-27 19:29:02 +0000 | [diff] [blame] | 11 | %a1 = getelementptr inbounds %struct.s, %struct.s* %a, i64 0, i32 0 |
David Blaikie | a79ac14 | 2015-02-27 21:17:42 +0000 | [diff] [blame] | 12 | %0 = load i32, i32* %a1, align 4 |
David Blaikie | 79e6c74 | 2015-02-27 19:29:02 +0000 | [diff] [blame] | 13 | %arrayidx = getelementptr inbounds [2 x i32], [2 x i32]* %x, i64 0, i64 0 |
Manman Ren | 1047fe4 | 2013-09-30 18:17:35 +0000 | [diff] [blame] | 14 | store i32 %0, i32* %arrayidx, align 4 |
David Blaikie | 79e6c74 | 2015-02-27 19:29:02 +0000 | [diff] [blame] | 15 | %b = getelementptr inbounds %struct.s, %struct.s* %a, i64 0, i32 1 |
David Blaikie | a79ac14 | 2015-02-27 21:17:42 +0000 | [diff] [blame] | 16 | %1 = load i32, i32* %b, align 4 |
David Blaikie | 79e6c74 | 2015-02-27 19:29:02 +0000 | [diff] [blame] | 17 | %arrayidx2 = getelementptr inbounds [2 x i32], [2 x i32]* %x, i64 0, i64 1 |
Manman Ren | 1047fe4 | 2013-09-30 18:17:35 +0000 | [diff] [blame] | 18 | store i32 %1, i32* %arrayidx2, align 4 |
Hal Finkel | 9caa8f7 | 2013-07-16 17:10:55 +0000 | [diff] [blame] | 19 | call void @bar(i32* %arrayidx) #2 |
| 20 | ret void |
| 21 | } |
| 22 | |
| 23 | define void @foo0(%struct.s* byval nocapture readonly %a) { |
| 24 | entry: |
| 25 | %x = alloca [2 x i32] |
David Blaikie | 79e6c74 | 2015-02-27 19:29:02 +0000 | [diff] [blame] | 26 | %a1 = getelementptr inbounds %struct.s, %struct.s* %a, i64 0, i32 0 |
David Blaikie | a79ac14 | 2015-02-27 21:17:42 +0000 | [diff] [blame] | 27 | %0 = load i32, i32* %a1, align 4 |
David Blaikie | 79e6c74 | 2015-02-27 19:29:02 +0000 | [diff] [blame] | 28 | %arrayidx = getelementptr inbounds [2 x i32], [2 x i32]* %x, i64 0, i64 0 |
Manman Ren | 1047fe4 | 2013-09-30 18:17:35 +0000 | [diff] [blame] | 29 | store i32 %0, i32* %arrayidx, align 4 |
David Blaikie | 79e6c74 | 2015-02-27 19:29:02 +0000 | [diff] [blame] | 30 | %b = getelementptr inbounds %struct.s, %struct.s* %a, i64 0, i32 1 |
David Blaikie | a79ac14 | 2015-02-27 21:17:42 +0000 | [diff] [blame] | 31 | %1 = load i32, i32* %b, align 4 |
David Blaikie | 79e6c74 | 2015-02-27 19:29:02 +0000 | [diff] [blame] | 32 | %arrayidx2 = getelementptr inbounds [2 x i32], [2 x i32]* %x, i64 0, i64 1 |
Manman Ren | 1047fe4 | 2013-09-30 18:17:35 +0000 | [diff] [blame] | 33 | store i32 %1, i32* %arrayidx2, align 4 |
Hal Finkel | 9caa8f7 | 2013-07-16 17:10:55 +0000 | [diff] [blame] | 34 | call void @bar(i32* %arrayidx) #2 |
| 35 | ret void |
| 36 | } |
| 37 | |
Hal Finkel | ec7cd26 | 2013-07-17 14:32:41 +0000 | [diff] [blame] | 38 | define void @foo1(%struct.s* byval nocapture readonly %a) { |
| 39 | entry: |
| 40 | %x = alloca [2 x i32], align 1 |
David Blaikie | 79e6c74 | 2015-02-27 19:29:02 +0000 | [diff] [blame] | 41 | %a1 = getelementptr inbounds %struct.s, %struct.s* %a, i64 0, i32 0 |
David Blaikie | a79ac14 | 2015-02-27 21:17:42 +0000 | [diff] [blame] | 42 | %0 = load i32, i32* %a1, align 4 |
David Blaikie | 79e6c74 | 2015-02-27 19:29:02 +0000 | [diff] [blame] | 43 | %arrayidx = getelementptr inbounds [2 x i32], [2 x i32]* %x, i64 0, i64 0 |
Manman Ren | 1047fe4 | 2013-09-30 18:17:35 +0000 | [diff] [blame] | 44 | store i32 %0, i32* %arrayidx, align 4 |
David Blaikie | 79e6c74 | 2015-02-27 19:29:02 +0000 | [diff] [blame] | 45 | %b = getelementptr inbounds %struct.s, %struct.s* %a, i64 0, i32 1 |
David Blaikie | a79ac14 | 2015-02-27 21:17:42 +0000 | [diff] [blame] | 46 | %1 = load i32, i32* %b, align 4 |
David Blaikie | 79e6c74 | 2015-02-27 19:29:02 +0000 | [diff] [blame] | 47 | %arrayidx2 = getelementptr inbounds [2 x i32], [2 x i32]* %x, i64 0, i64 1 |
Manman Ren | 1047fe4 | 2013-09-30 18:17:35 +0000 | [diff] [blame] | 48 | store i32 %1, i32* %arrayidx2, align 4 |
Hal Finkel | ec7cd26 | 2013-07-17 14:32:41 +0000 | [diff] [blame] | 49 | call void @bar(i32* %arrayidx) #2 |
| 50 | ret void |
| 51 | } |
| 52 | |
Hal Finkel | 9caa8f7 | 2013-07-16 17:10:55 +0000 | [diff] [blame] | 53 | declare void @bar(i32*) #1 |
| 54 | |
| 55 | define void @goo(%struct.s* byval nocapture readonly %a) { |
| 56 | entry: |
| 57 | %x = alloca [2 x i32], align 32 |
David Blaikie | 79e6c74 | 2015-02-27 19:29:02 +0000 | [diff] [blame] | 58 | %a1 = getelementptr inbounds %struct.s, %struct.s* %a, i64 0, i32 0 |
David Blaikie | a79ac14 | 2015-02-27 21:17:42 +0000 | [diff] [blame] | 59 | %0 = load i32, i32* %a1, align 4 |
David Blaikie | 79e6c74 | 2015-02-27 19:29:02 +0000 | [diff] [blame] | 60 | %arrayidx = getelementptr inbounds [2 x i32], [2 x i32]* %x, i64 0, i64 0 |
Manman Ren | 1047fe4 | 2013-09-30 18:17:35 +0000 | [diff] [blame] | 61 | store i32 %0, i32* %arrayidx, align 32 |
David Blaikie | 79e6c74 | 2015-02-27 19:29:02 +0000 | [diff] [blame] | 62 | %b = getelementptr inbounds %struct.s, %struct.s* %a, i64 0, i32 1 |
David Blaikie | a79ac14 | 2015-02-27 21:17:42 +0000 | [diff] [blame] | 63 | %1 = load i32, i32* %b, align 4 |
David Blaikie | 79e6c74 | 2015-02-27 19:29:02 +0000 | [diff] [blame] | 64 | %arrayidx2 = getelementptr inbounds [2 x i32], [2 x i32]* %x, i64 0, i64 1 |
Manman Ren | 1047fe4 | 2013-09-30 18:17:35 +0000 | [diff] [blame] | 65 | store i32 %1, i32* %arrayidx2, align 4 |
Hal Finkel | 9caa8f7 | 2013-07-16 17:10:55 +0000 | [diff] [blame] | 66 | call void @bar(i32* %arrayidx) #2 |
| 67 | ret void |
| 68 | } |
| 69 | |
| 70 | ; CHECK-LABEL: @main |
| 71 | ; CHECK: alloca [2 x i32], align 32 |
| 72 | ; CHECK-NOT: alloca [2 x i32] |
| 73 | ; CHECK: ret i32 0 |
| 74 | |
| 75 | define signext i32 @main() { |
| 76 | entry: |
| 77 | %a = alloca i64, align 8 |
| 78 | %tmpcast = bitcast i64* %a to %struct.s* |
| 79 | store i64 0, i64* %a, align 8 |
| 80 | %a1 = bitcast i64* %a to i32* |
Manman Ren | 1047fe4 | 2013-09-30 18:17:35 +0000 | [diff] [blame] | 81 | store i32 1, i32* %a1, align 8 |
Hal Finkel | 9caa8f7 | 2013-07-16 17:10:55 +0000 | [diff] [blame] | 82 | call void @foo(%struct.s* byval %tmpcast) |
Manman Ren | 1047fe4 | 2013-09-30 18:17:35 +0000 | [diff] [blame] | 83 | store i32 2, i32* %a1, align 8 |
Hal Finkel | 9caa8f7 | 2013-07-16 17:10:55 +0000 | [diff] [blame] | 84 | call void @goo(%struct.s* byval %tmpcast) |
| 85 | ret i32 0 |
| 86 | } |
| 87 | |
| 88 | ; CHECK-LABEL: @test0 |
| 89 | ; CHECK: alloca [2 x i32], align 32 |
| 90 | ; CHECK-NOT: alloca [2 x i32] |
| 91 | ; CHECK: ret i32 0 |
| 92 | |
| 93 | define signext i32 @test0() { |
| 94 | entry: |
| 95 | %a = alloca i64, align 8 |
| 96 | %tmpcast = bitcast i64* %a to %struct.s* |
| 97 | store i64 0, i64* %a, align 8 |
| 98 | %a1 = bitcast i64* %a to i32* |
Manman Ren | 1047fe4 | 2013-09-30 18:17:35 +0000 | [diff] [blame] | 99 | store i32 1, i32* %a1, align 8 |
Hal Finkel | 9caa8f7 | 2013-07-16 17:10:55 +0000 | [diff] [blame] | 100 | call void @foo0(%struct.s* byval %tmpcast) |
Manman Ren | 1047fe4 | 2013-09-30 18:17:35 +0000 | [diff] [blame] | 101 | store i32 2, i32* %a1, align 8 |
Hal Finkel | 9caa8f7 | 2013-07-16 17:10:55 +0000 | [diff] [blame] | 102 | call void @goo(%struct.s* byval %tmpcast) |
| 103 | ret i32 0 |
| 104 | } |