1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 5
2 ; RUN: opt -S -passes=argpromotion < %s | FileCheck %s
3 define internal i32 @foo(ptr %x, i32 %n, i32 %m) {
4 ; CHECK-LABEL: define internal i32 @foo(
5 ; CHECK-SAME: i32 [[X_0_VAL:%.*]], i32 [[N:%.*]], i32 [[M:%.*]]) {
6 ; CHECK-NEXT: [[ENTRY:.*:]]
7 ; CHECK-NEXT: [[CMP:%.*]] = icmp ne i32 [[N]], 0
8 ; CHECK-NEXT: br i1 [[CMP]], label %[[COND_TRUE:.*]], label %[[COND_FALSE:.*]]
9 ; CHECK: [[COND_TRUE]]:
10 ; CHECK-NEXT: br label %[[RETURN:.*]]
11 ; CHECK: [[COND_FALSE]]:
12 ; CHECK-NEXT: [[SUBVAL:%.*]] = sub i32 [[N]], 1
13 ; CHECK-NEXT: [[CALLRET:%.*]] = call i32 @foo(i32 [[X_0_VAL]], i32 [[SUBVAL]], i32 [[X_0_VAL]])
14 ; CHECK-NEXT: [[SUBVAL2:%.*]] = sub i32 [[N]], 2
15 ; CHECK-NEXT: [[CALLRET2:%.*]] = call i32 @foo(i32 [[X_0_VAL]], i32 [[SUBVAL2]], i32 [[M]])
16 ; CHECK-NEXT: [[CMP2:%.*]] = add i32 [[CALLRET]], [[CALLRET2]]
17 ; CHECK-NEXT: br label %[[RETURN]]
18 ; CHECK: [[COND_NEXT:.*]]:
19 ; CHECK-NEXT: br label %[[RETURN]]
21 ; CHECK-NEXT: [[RETVAL_0:%.*]] = phi i32 [ [[X_0_VAL]], %[[COND_TRUE]] ], [ [[CMP2]], %[[COND_FALSE]] ], [ poison, %[[COND_NEXT]] ]
22 ; CHECK-NEXT: ret i32 [[RETVAL_0]]
25 %cmp = icmp ne i32 %n, 0
26 br i1 %cmp, label %cond_true, label %cond_false
28 cond_true: ; preds = %entry
29 %val = load i32, ptr %x, align 4
32 cond_false: ; preds = %entry
33 %val2 = load i32, ptr %x, align 4
34 %subval = sub i32 %n, 1
35 %callret = call i32 @foo(ptr %x, i32 %subval, i32 %val2)
36 %subval2 = sub i32 %n, 2
37 %callret2 = call i32 @foo(ptr %x, i32 %subval2, i32 %m)
38 %cmp2 = add i32 %callret, %callret2
41 cond_next: ; No predecessors!
44 return: ; preds = %cond_next, %cond_false, %cond_true
45 %retval.0 = phi i32 [ %val, %cond_true ], [ %cmp2, %cond_false ], [ poison, %cond_next ]
49 define i32 @bar(ptr align(4) dereferenceable(4) %x, i32 %n, i32 %m) {
50 ; CHECK-LABEL: define i32 @bar(
51 ; CHECK-SAME: ptr align 4 dereferenceable(4) [[X:%.*]], i32 [[N:%.*]], i32 [[M:%.*]]) {
52 ; CHECK-NEXT: [[ENTRY:.*:]]
53 ; CHECK-NEXT: [[X_VAL:%.*]] = load i32, ptr [[X]], align 4
54 ; CHECK-NEXT: [[CALLRET3:%.*]] = call i32 @foo(i32 [[X_VAL]], i32 [[N]], i32 [[M]])
55 ; CHECK-NEXT: br label %[[RETURN:.*]]
57 ; CHECK-NEXT: ret i32 [[CALLRET3]]
60 %callret3 = call i32 @foo(ptr %x, i32 %n, i32 %m)
63 return: ; preds = %entry