1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt -passes="ipsccp<func-spec>" -force-specialization -S < %s | FileCheck %s
4 define i64 @main(i64 %x, i64 %y, i1 %flag) {
7 ; CHECK-NEXT: br i1 [[FLAG:%.*]], label [[PLUS:%.*]], label [[MINUS:%.*]]
9 ; CHECK-NEXT: [[CMP0:%.*]] = call i64 @compute.specialized.2(i64 [[X:%.*]], i64 [[Y:%.*]], ptr @plus, ptr @minus)
10 ; CHECK-NEXT: br label [[MERGE:%.*]]
12 ; CHECK-NEXT: [[CMP1:%.*]] = call i64 @compute.specialized.3(i64 [[X]], i64 [[Y]], ptr @minus, ptr @plus)
13 ; CHECK-NEXT: br label [[MERGE]]
15 ; CHECK-NEXT: [[PH:%.*]] = phi i64 [ [[CMP0]], [[PLUS]] ], [ [[CMP1]], [[MINUS]] ]
16 ; CHECK-NEXT: [[CMP2:%.*]] = call i64 @compute.specialized.2(i64 [[PH]], i64 42, ptr @plus, ptr @minus)
17 ; CHECK-NEXT: ret i64 [[CMP2]]
20 br i1 %flag, label %plus, label %minus
23 %cmp0 = call i64 @compute(i64 %x, i64 %y, ptr @plus, ptr @minus)
27 %cmp1 = call i64 @compute(i64 %x, i64 %y, ptr @minus, ptr @plus)
31 %ph = phi i64 [ %cmp0, %plus ], [ %cmp1, %minus]
32 %cmp2 = call i64 @compute(i64 %ph, i64 42, ptr @plus, ptr @minus)
36 define internal i64 @compute(i64 %x, i64 %y, ptr %binop1, ptr %binop2) {
38 %op0 = call i64 %binop1(i64 %x, i64 %y)
39 %op1 = call i64 %binop2(i64 %x, i64 %y)
40 %op2 = call i64 @compute(i64 %x, i64 %y, ptr %binop1, ptr @plus)
41 %add0 = add i64 %op0, %op1
42 %add1 = add i64 %add0, %op2
43 %div = sdiv i64 %add1, %x
44 %sub = sub i64 %div, %y
45 %mul = mul i64 %sub, 2
49 define internal i64 @plus(i64 %x, i64 %y) {
56 define internal i64 @minus(i64 %x, i64 %y) {
57 ; CHECK-LABEL: @minus(
63 ; CHECK-LABEL: @compute.specialized.1
65 ; CHECK-NEXT: [[CMP0:%.*]] = call i64 %binop1(i64 [[X:%.*]], i64 [[Y:%.*]])
66 ; CHECK-NEXT: [[CMP1:%.*]] = call i64 @plus(i64 [[X]], i64 [[Y]])
67 ; CHECK-NEXT: [[CMP2:%.*]] = call i64 @compute.specialized.1(i64 [[X]], i64 [[Y]], ptr %binop1, ptr @plus)
69 ; CHECK-LABEL: @compute.specialized.2
71 ; CHECK-NEXT: [[CMP0:%.*]] = call i64 @plus(i64 [[X:%.*]], i64 [[Y:%.*]])
72 ; CHECK-NEXT: [[CMP1:%.*]] = call i64 @minus(i64 [[X]], i64 [[Y]])
73 ; CHECK-NEXT: [[CMP2:%.*]] = call i64 @compute.specialized.1(i64 [[X]], i64 [[Y]], ptr @plus, ptr @plus)
75 ; CHECK-LABEL: @compute.specialized.3
77 ; CHECK-NEXT: [[CMP0:%.*]] = call i64 @minus(i64 [[X:%.*]], i64 [[Y:%.*]])
78 ; CHECK-NEXT: [[CMP1:%.*]] = call i64 @plus(i64 [[X]], i64 [[Y]])
79 ; CHECK-NEXT: [[CMP2:%.*]] = call i64 @compute.specialized.3(i64 [[X]], i64 [[Y]], ptr @minus, ptr @plus)