60 lines · plain
1; RUN: opt -passes="ipsccp<func-spec>" -funcspec-min-function-size=3 -S < %s | FileCheck %s2 3define i64 @main(i64 %x, i1 %flag) {4entry:5 br i1 %flag, label %plus, label %minus6 7plus:8 %tmp0 = call i64 @compute(i64 %x, ptr @plus)9 br label %merge10 11minus:12 %tmp1 = call i64 @compute(i64 %x, ptr @minus)13 br label %merge14 15merge:16 %tmp2 = phi i64 [ %tmp0, %plus ], [ %tmp1, %minus]17 ret i64 %tmp218}19 20; CHECK-NOT: define internal i64 @compute(21;22; CHECK-LABEL: define internal i64 @compute.specialized.1(i64 %n, ptr %binop) {23; CHECK: [[TMP0:%.+]] = call i64 @plus(i64 %n)24; CHECK: [[TMP1:%.+]] = call i64 @compute.specialized.1(i64 [[TMP2:%.+]], ptr @plus)25; CHECK: add nsw i64 [[TMP1]], [[TMP0]]26;27; CHECK-LABEL: define internal i64 @compute.specialized.2(i64 %n, ptr %binop) {28; CHECK: [[TMP0:%.+]] = call i64 @minus(i64 %n)29; CHECK: [[TMP1:%.+]] = call i64 @compute.specialized.2(i64 [[TMP2:%.+]], ptr @minus)30; CHECK: add nsw i64 [[TMP1]], [[TMP0]]31;32define internal i64 @compute(i64 %n, ptr %binop) {33entry:34 %cmp = icmp sgt i64 %n, 035 br i1 %cmp, label %if.then, label %if.end36 37if.then:38 %call = call i64 %binop(i64 %n)39 %sub = add nsw i64 %n, -140 %call1 = call i64 @compute(i64 %sub, ptr %binop)41 %add2 = add nsw i64 %call1, %call42 br label %if.end43 44if.end:45 %result.0 = phi i64 [ %add2, %if.then ], [ 0, %entry ]46 ret i64 %result.047}48 49define internal i64 @plus(i64 %x) {50entry:51 %tmp0 = add i64 %x, 152 ret i64 %tmp053}54 55define internal i64 @minus(i64 %x) {56entry:57 %tmp0 = sub i64 %x, 158 ret i64 %tmp059}60