1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --function-signature
2 ; RUN: opt -passes=argpromotion -S %s | FileCheck %s
4 define internal i32 @callee2(ptr noundef %0) {
5 ; CHECK-LABEL: define {{[^@]+}}@callee2
6 ; CHECK-SAME: (i32 [[DOT0_VAL:%.*]], i32 [[DOT4_VAL:%.*]]) {
7 ; CHECK-NEXT: [[TMP1:%.*]] = add nsw i32 [[DOT0_VAL]], [[DOT4_VAL]]
8 ; CHECK-NEXT: ret i32 [[TMP1]]
10 %2 = load i32, ptr %0, align 4
11 %3 = getelementptr inbounds i32, ptr %0, i64 1
12 %4 = load i32, ptr %3, align 4
13 %5 = add nsw i32 %2, %4
17 define i32 @caller2(i32 %0, i32 %1) {
18 ; CHECK-LABEL: define {{[^@]+}}@caller2
19 ; CHECK-SAME: (i32 [[TMP0:%.*]], i32 [[TMP1:%.*]]) {
20 ; CHECK-NEXT: [[TMP3:%.*]] = alloca [2 x i32], align 4
21 ; CHECK-NEXT: store i32 [[TMP0]], ptr [[TMP3]], align 4
22 ; CHECK-NEXT: [[TMP4:%.*]] = getelementptr inbounds i32, ptr [[TMP3]], i64 1
23 ; CHECK-NEXT: store i32 [[TMP1]], ptr [[TMP4]], align 4
24 ; CHECK-NEXT: [[DOTVAL:%.*]] = load i32, ptr [[TMP3]], align 4
25 ; CHECK-NEXT: [[TMP5:%.*]] = getelementptr i8, ptr [[TMP3]], i64 4
26 ; CHECK-NEXT: [[DOTVAL1:%.*]] = load i32, ptr [[TMP5]], align 4
27 ; CHECK-NEXT: [[TMP6:%.*]] = call i32 @callee2(i32 [[DOTVAL]], i32 [[DOTVAL1]])
28 ; CHECK-NEXT: ret i32 [[TMP6]]
30 %3 = alloca [2 x i32], align 4
31 store i32 %0, ptr %3, align 4
32 %4 = getelementptr inbounds i32, ptr %3, i64 1
33 store i32 %1, ptr %4, align 4
34 %5 = call i32 @callee2(ptr noundef %3)
38 define internal i32 @callee3(ptr noundef %0) {
39 ; CHECK-LABEL: define {{[^@]+}}@callee3
40 ; CHECK-SAME: (ptr noundef [[TMP0:%.*]]) {
41 ; CHECK-NEXT: [[TMP2:%.*]] = load i32, ptr [[TMP0]], align 4
42 ; CHECK-NEXT: [[TMP3:%.*]] = getelementptr inbounds i32, ptr [[TMP0]], i64 1
43 ; CHECK-NEXT: [[TMP4:%.*]] = load i32, ptr [[TMP3]], align 4
44 ; CHECK-NEXT: [[TMP5:%.*]] = add nsw i32 [[TMP2]], [[TMP4]]
45 ; CHECK-NEXT: [[TMP6:%.*]] = getelementptr inbounds i32, ptr [[TMP0]], i64 2
46 ; CHECK-NEXT: [[TMP7:%.*]] = load i32, ptr [[TMP6]], align 4
47 ; CHECK-NEXT: [[TMP8:%.*]] = add nsw i32 [[TMP5]], [[TMP7]]
48 ; CHECK-NEXT: ret i32 [[TMP8]]
50 %2 = load i32, ptr %0, align 4
51 %3 = getelementptr inbounds i32, ptr %0, i64 1
52 %4 = load i32, ptr %3, align 4
53 %5 = add nsw i32 %2, %4
54 %6 = getelementptr inbounds i32, ptr %0, i64 2
55 %7 = load i32, ptr %6, align 4
56 %8 = add nsw i32 %5, %7
60 define i32 @caller3(i32 %0, i32 %1, i32 %2) {
61 ; CHECK-LABEL: define {{[^@]+}}@caller3
62 ; CHECK-SAME: (i32 [[TMP0:%.*]], i32 [[TMP1:%.*]], i32 [[TMP2:%.*]]) {
63 ; CHECK-NEXT: [[TMP4:%.*]] = alloca [3 x i32], align 4
64 ; CHECK-NEXT: store i32 [[TMP0]], ptr [[TMP4]], align 4
65 ; CHECK-NEXT: [[TMP5:%.*]] = getelementptr inbounds i32, ptr [[TMP4]], i64 1
66 ; CHECK-NEXT: store i32 [[TMP1]], ptr [[TMP5]], align 4
67 ; CHECK-NEXT: [[TMP6:%.*]] = getelementptr inbounds i32, ptr [[TMP5]], i64 1
68 ; CHECK-NEXT: store i32 [[TMP2]], ptr [[TMP6]], align 4
69 ; CHECK-NEXT: [[TMP7:%.*]] = call i32 @callee3(ptr noundef [[TMP4]])
70 ; CHECK-NEXT: ret i32 [[TMP7]]
72 %4 = alloca [3 x i32], align 4
73 store i32 %0, ptr %4, align 4
74 %5 = getelementptr inbounds i32, ptr %4, i64 1
75 store i32 %1, ptr %5, align 4
76 %6 = getelementptr inbounds i32, ptr %5, i64 1
77 store i32 %2, ptr %6, align 4
78 %7 = call i32 @callee3(ptr noundef %4)