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, ptr %y, i32 %n, i32 %m) {
4 ; CHECK-LABEL: define internal i32 @foo(
5 ; CHECK-SAME: ptr [[X:%.*]], ptr [[Y:%.*]], 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: [[VAL:%.*]] = load i32, ptr [[X]], align 4
11 ; CHECK-NEXT: br label %[[RETURN:.*]]
12 ; CHECK: [[COND_FALSE]]:
13 ; CHECK-NEXT: [[VAL2:%.*]] = load i32, ptr [[X]], align 4
14 ; CHECK-NEXT: [[VAL3:%.*]] = load i32, ptr [[Y]], align 4
15 ; CHECK-NEXT: [[SUBVAL:%.*]] = sub i32 [[N]], [[VAL3]]
16 ; CHECK-NEXT: [[CALLRET:%.*]] = call i32 @foo(ptr [[X]], ptr [[Y]], i32 [[SUBVAL]], i32 [[VAL2]])
17 ; CHECK-NEXT: [[SUBVAL2:%.*]] = sub i32 [[N]], 2
18 ; CHECK-NEXT: [[CALLRET2:%.*]] = call i32 @foo(ptr [[Y]], ptr [[X]], i32 [[SUBVAL2]], i32 [[M]])
19 ; CHECK-NEXT: [[CMP2:%.*]] = add i32 [[CALLRET]], [[CALLRET2]]
20 ; CHECK-NEXT: br label %[[RETURN]]
21 ; CHECK: [[COND_NEXT:.*]]:
22 ; CHECK-NEXT: br label %[[RETURN]]
24 ; CHECK-NEXT: [[RETVAL_0:%.*]] = phi i32 [ [[VAL]], %[[COND_TRUE]] ], [ [[CMP2]], %[[COND_FALSE]] ], [ poison, %[[COND_NEXT]] ]
25 ; CHECK-NEXT: ret i32 [[RETVAL_0]]
28 %cmp = icmp ne i32 %n, 0
29 br i1 %cmp, label %cond_true, label %cond_false
31 cond_true: ; preds = %entry
32 %val = load i32, ptr %x, align 4
35 cond_false: ; preds = %entry
36 %val2 = load i32, ptr %x, align 4
37 %val3 = load i32, ptr %y, align 4
38 %subval = sub i32 %n, %val3
39 %callret = call i32 @foo(ptr %x, ptr %y, i32 %subval, i32 %val2)
40 %subval2 = sub i32 %n, 2
41 %callret2 = call i32 @foo(ptr %y, ptr %x, i32 %subval2, i32 %m)
42 %cmp2 = add i32 %callret, %callret2
45 cond_next: ; No predecessors!
48 return: ; preds = %cond_next, %cond_false, %cond_true
49 %retval.0 = phi i32 [ %val, %cond_true ], [ %cmp2, %cond_false ], [ poison, %cond_next ]
53 define i32 @bar(ptr align(4) dereferenceable(4) %x, ptr align(4) dereferenceable(4) %y, i32 %n, i32 %m) {
54 ; CHECK-LABEL: define i32 @bar(
55 ; CHECK-SAME: ptr align 4 dereferenceable(4) [[X:%.*]], ptr align 4 dereferenceable(4) [[Y:%.*]], i32 [[N:%.*]], i32 [[M:%.*]]) {
56 ; CHECK-NEXT: [[ENTRY:.*:]]
57 ; CHECK-NEXT: [[CALLRET3:%.*]] = call i32 @foo(ptr [[X]], ptr [[Y]], i32 [[N]], i32 [[M]])
58 ; CHECK-NEXT: br label %[[RETURN:.*]]
60 ; CHECK-NEXT: ret i32 [[CALLRET3]]
63 %callret3 = call i32 @foo(ptr %x, ptr %y, i32 %n, i32 %m)
66 return: ; preds = %entry