1; RUN: opt < %s -argpromotion -S | FileCheck %s
2; RUN: opt < %s -passes=argpromotion -S | FileCheck %s
3
4%T = type { i32, i32, i32, i32 }
5@G = constant %T { i32 0, i32 0, i32 17, i32 25 }
6
7define internal i32 @test(%T* %p) {
8; CHECK-LABEL: define internal i32 @test(
9; CHECK: i32 %{{.*}}, i32 %{{.*}})
10entry:
11  %a.gep = getelementptr %T, %T* %p, i64 0, i32 3
12  %b.gep = getelementptr %T, %T* %p, i64 0, i32 2
13  %a = load i32, i32* %a.gep
14  %b = load i32, i32* %b.gep
15; CHECK-NOT: load
16  %v = add i32 %a, %b
17  ret i32 %v
18; CHECK: ret i32
19}
20
21define i32 @caller() {
22; CHECK-LABEL: define i32 @caller(
23entry:
24  %v = call i32 @test(%T* @G)
25; CHECK: %[[B_GEP:.*]] = getelementptr %T, %T* @G, i64 0, i32 2
26; CHECK: %[[B:.*]] = load i32, i32* %[[B_GEP]]
27; CHECK: %[[A_GEP:.*]] = getelementptr %T, %T* @G, i64 0, i32 3
28; CHECK: %[[A:.*]] = load i32, i32* %[[A_GEP]]
29; CHECK: call i32 @test(i32 %[[B]], i32 %[[A]])
30  ret i32 %v
31}
32