1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --function-signature --scrub-attributes
2 ; RUN: opt < %s -argpromotion -S | FileCheck %s
3 ; RUN: opt < %s -passes=argpromotion -S | FileCheck %s
5 %T = type { i32, i32, i32, i32 }
6 @G = constant %T { i32 0, i32 0, i32 17, i32 25 }
8 define internal i32 @test(%T* %p) {
9 ; CHECK-LABEL: define {{[^@]+}}@test
10 ; CHECK-SAME: (i32 [[P_0_2_VAL:%.*]], i32 [[P_0_3_VAL:%.*]])
12 ; CHECK-NEXT: [[V:%.*]] = add i32 [[P_0_3_VAL]], [[P_0_2_VAL]]
13 ; CHECK-NEXT: ret i32 [[V]]
16 %a.gep = getelementptr %T, %T* %p, i64 0, i32 3
17 %b.gep = getelementptr %T, %T* %p, i64 0, i32 2
18 %a = load i32, i32* %a.gep
19 %b = load i32, i32* %b.gep
24 define i32 @caller() {
25 ; CHECK-LABEL: define {{[^@]+}}@caller()
27 ; CHECK-NEXT: [[G_IDX:%.*]] = getelementptr [[T:%.*]], %T* @G, i64 0, i32 2
28 ; CHECK-NEXT: [[G_IDX_VAL:%.*]] = load i32, i32* [[G_IDX]]
29 ; CHECK-NEXT: [[G_IDX1:%.*]] = getelementptr [[T]], %T* @G, i64 0, i32 3
30 ; CHECK-NEXT: [[G_IDX1_VAL:%.*]] = load i32, i32* [[G_IDX1]]
31 ; CHECK-NEXT: [[V:%.*]] = call i32 @test(i32 [[G_IDX_VAL]], i32 [[G_IDX1_VAL]])
32 ; CHECK-NEXT: ret i32 [[V]]
35 %v = call i32 @test(%T* @G)