xref: /llvm-project/llvm/test/Transforms/FunctionSpecialization/maxgrowth.ll (revision e19a5fc6d306a81d181a9597a8b25c444c08d722)
1; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --include-generated-funcs --version 5
2; RUN: opt -passes="ipsccp<func-spec>" -funcspec-min-function-size=1       \
3; RUN:                                 -funcspec-for-literal-constant=true \
4; RUN:                                 -funcspec-min-codesize-savings=50   \
5; RUN:                                 -funcspec-min-latency-savings=50    \
6; RUN:                                 -funcspec-max-codesize-growth=1     \
7; RUN:                                 -S < %s | FileCheck %s
8
9; Verify that we are able to specialize a function successfully after analysis
10; of other specializations that are found to not be profitable.
11define void @test_specialize_after_failed_analysis(i32 %n) {
12entry:
13  %notspec0 = call i32 @add(i32 0, i32 %n)
14  %notspec1 = call i32 @add(i32 1, i32 %n)
15  %spec = call i32 @add(i32 1, i32 1)
16  ret void
17}
18
19define i32 @add(i32 %x, i32 %y) {
20entry:
21  %res = add i32 %x, %y
22  ret i32 %res
23}
24; CHECK-LABEL: define void @test_specialize_after_failed_analysis(
25; CHECK-SAME: i32 [[N:%.*]]) {
26; CHECK-NEXT:  [[ENTRY:.*:]]
27; CHECK-NEXT:    [[NOTSPEC0:%.*]] = call i32 @add(i32 0, i32 [[N]])
28; CHECK-NEXT:    [[NOTSPEC1:%.*]] = call i32 @add(i32 1, i32 [[N]])
29; CHECK-NEXT:    [[SPEC:%.*]] = call i32 @add.specialized.1(i32 1, i32 1)
30; CHECK-NEXT:    ret void
31;
32;
33; CHECK-LABEL: define i32 @add(
34; CHECK-SAME: i32 [[X:%.*]], i32 [[Y:%.*]]) {
35; CHECK-NEXT:  [[ENTRY:.*:]]
36; CHECK-NEXT:    [[RES:%.*]] = add i32 [[X]], [[Y]]
37; CHECK-NEXT:    ret i32 [[RES]]
38;
39;
40; CHECK-LABEL: define internal i32 @add.specialized.1(
41; CHECK-SAME: i32 [[X:%.*]], i32 [[Y:%.*]]) {
42; CHECK-NEXT:  [[ENTRY:.*:]]
43; CHECK-NEXT:    ret i32 poison
44;
45