1; REQUIRES: asserts
2; RUN: opt -S -debug-counter=partially-inline-libcalls-transform-skip=1,partially-inline-libcalls-transform-count=1 \
3; RUN:     -partially-inline-libcalls -mtriple=x86_64-unknown-linux-gnu < %s | FileCheck %s
4;; Test that, with debug counters on, we will skip the first optimization opportunity, perform next 1,
5;; and ignore all the others left.
6
7define float @f1(float %val) {
8; CHECK-LABEL: @f1(
9; CHECK-NEXT:  entry:
10; CHECK-NEXT:    [[RES:%.*]] = tail call float @sqrtf(float [[VAL:%.*]])
11; CHECK-NEXT:    ret float [[RES:%.*]]
12entry:
13  %res = tail call float @sqrtf(float %val)
14  ret float %res
15}
16
17define float @f2(float %val) {
18; CHECK-LABEL: @f2(
19; CHECK-NEXT:  entry:
20; CHECK-NEXT:    [[RES:%.*]] = tail call float @sqrtf(float [[VAL:%.*]]) #0
21; CHECK-NEXT:    [[TMP0:%.*]] = fcmp oge float [[VAL]], 0.000000e+00
22; CHECK-NEXT:    br i1 [[TMP0]], label [[ENTRY_SPLIT:%.*]], label [[CALL_SQRT:%.*]]
23; CHECK:       call.sqrt:
24; CHECK-NEXT:    [[TMP1:%.*]] = tail call float @sqrtf(float [[VAL]])
25; CHECK-NEXT:    br label [[ENTRY_SPLIT]]
26; CHECK:       entry.split:
27; CHECK-NEXT:    [[TMP2:%.*]] = phi float [ [[RES]], [[ENTRY:%.*]] ], [ [[TMP1]], [[CALL_SQRT]] ]
28; CHECK-NEXT:    ret float [[TMP2]]
29entry:
30  %res = tail call float @sqrtf(float %val)
31  ret float %res
32}
33
34define float @f3(float %val) {
35; CHECK-LABEL: @f3(
36; CHECK-NEXT:  entry:
37; CHECK-NEXT:    [[RES:%.*]] = tail call float @sqrtf(float [[VAL:%.*]])
38; CHECK-NEXT:    ret float [[RES:%.*]]
39entry:
40  %res = tail call float @sqrtf(float %val)
41  ret float %res
42}
43
44declare float @sqrtf(float)
45