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 @zoo(ptr %x, i32 %m) {
4 ; CHECK-LABEL: define internal i32 @zoo(
5 ; CHECK-SAME: i32 [[X_0_VAL:%.*]], i32 [[M:%.*]]) {
6 ; CHECK-NEXT: [[RESZOO:%.*]] = add i32 [[X_0_VAL]], [[M]]
7 ; CHECK-NEXT: ret i32 [[X_0_VAL]]
9 %valzoo = load i32, ptr %x, align 4
10 %reszoo = add i32 %valzoo, %m
14 define internal i32 @foo(ptr %x, ptr %y, i32 %n, i32 %m) {
15 ; CHECK-LABEL: define internal i32 @foo(
16 ; CHECK-SAME: ptr [[X:%.*]], i32 [[Y_0_VAL:%.*]], i32 [[N:%.*]], i32 [[M:%.*]]) {
17 ; CHECK-NEXT: [[ENTRY:.*:]]
18 ; CHECK-NEXT: [[CMP:%.*]] = icmp ne i32 [[N]], 0
19 ; CHECK-NEXT: br i1 [[CMP]], label %[[COND_TRUE:.*]], label %[[COND_FALSE:.*]]
20 ; CHECK: [[COND_TRUE]]:
21 ; CHECK-NEXT: [[VAL:%.*]] = load i32, ptr [[X]], align 4
22 ; CHECK-NEXT: br label %[[RETURN:.*]]
23 ; CHECK: [[COND_FALSE]]:
24 ; CHECK-NEXT: [[VAL2:%.*]] = load i32, ptr [[X]], align 4
25 ; CHECK-NEXT: [[SUBVAL:%.*]] = sub i32 [[N]], [[Y_0_VAL]]
26 ; CHECK-NEXT: [[CALLRET:%.*]] = call i32 @foo(ptr [[X]], i32 [[Y_0_VAL]], i32 [[SUBVAL]], i32 [[VAL2]])
27 ; CHECK-NEXT: [[SUBVAL2:%.*]] = sub i32 [[N]], 2
28 ; CHECK-NEXT: [[CALLRET2:%.*]] = call i32 @foo(ptr [[X]], i32 [[Y_0_VAL]], i32 [[SUBVAL2]], i32 [[M]])
29 ; CHECK-NEXT: [[CMP1:%.*]] = add i32 [[CALLRET]], [[CALLRET2]]
30 ; CHECK-NEXT: [[X_VAL:%.*]] = load i32, ptr [[X]], align 4
31 ; CHECK-NEXT: [[CALLRETFINAL:%.*]] = call i32 @zoo(i32 [[X_VAL]], i32 [[M]])
32 ; CHECK-NEXT: [[CMP2:%.*]] = add i32 [[CMP1]], [[CALLRETFINAL]]
33 ; CHECK-NEXT: br label %[[RETURN]]
34 ; CHECK: [[COND_NEXT:.*]]:
35 ; CHECK-NEXT: br label %[[RETURN]]
37 ; CHECK-NEXT: [[RETVAL_0:%.*]] = phi i32 [ [[VAL]], %[[COND_TRUE]] ], [ [[CMP2]], %[[COND_FALSE]] ], [ poison, %[[COND_NEXT]] ]
38 ; CHECK-NEXT: ret i32 [[RETVAL_0]]
41 %cmp = icmp ne i32 %n, 0
42 br i1 %cmp, label %cond_true, label %cond_false
44 cond_true: ; preds = %entry
45 %val = load i32, ptr %x, align 4
48 cond_false: ; preds = %entry
49 %val2 = load i32, ptr %x, align 4
50 %val3 = load i32, ptr %y, align 4
51 %subval = sub i32 %n, %val3
52 %callret = call i32 @foo(ptr %x, ptr %y, i32 %subval, i32 %val2)
53 %subval2 = sub i32 %n, 2
54 %callret2 = call i32 @foo(ptr %x, ptr %y, i32 %subval2, i32 %m)
55 %cmp1 = add i32 %callret, %callret2
56 %callretfinal = call i32 @zoo(ptr %x, i32 %m)
57 %cmp2 = add i32 %cmp1, %callretfinal
60 cond_next: ; No predecessors!
63 return: ; preds = %cond_next, %cond_false, %cond_true
64 %retval.0 = phi i32 [ %val, %cond_true ], [ %cmp2, %cond_false ], [ poison, %cond_next ]
68 define i32 @bar(ptr align(4) dereferenceable(4) %x, ptr align(4) dereferenceable(4) %y, i32 %n, i32 %m) {
69 ; CHECK-LABEL: define i32 @bar(
70 ; CHECK-SAME: ptr align 4 dereferenceable(4) [[X:%.*]], ptr align 4 dereferenceable(4) [[Y:%.*]], i32 [[N:%.*]], i32 [[M:%.*]]) {
71 ; CHECK-NEXT: [[ENTRY:.*:]]
72 ; CHECK-NEXT: [[Y_VAL:%.*]] = load i32, ptr [[Y]], align 4
73 ; CHECK-NEXT: [[CALLRET3:%.*]] = call i32 @foo(ptr [[X]], i32 [[Y_VAL]], i32 [[N]], i32 [[M]])
74 ; CHECK-NEXT: br label %[[RETURN:.*]]
76 ; CHECK-NEXT: ret i32 [[CALLRET3]]
79 %callret3 = call i32 @foo(ptr %x, ptr %y, i32 %n, i32 %m)
82 return: ; preds = %entry