xref: /llvm-project/llvm/test/Analysis/CostModel/AMDGPU/control-flow.ll (revision 68c50b111d74afb9489cf97770fa917d0a1c7f77)
1; NOTE: Assertions have been autogenerated by utils/update_analyze_test_checks.py
2; RUN: opt -passes="print<cost-model>" 2>&1 -disable-output -mtriple=amdgcn-unknown-amdhsa < %s | FileCheck  --check-prefixes=ALL %s
3; RUN: opt -passes="print<cost-model>" -cost-kind=code-size 2>&1 -disable-output -mtriple=amdgcn-unknown-amdhsa < %s | FileCheck --check-prefixes=ALL-SIZE %s
4; END.
5
6define amdgpu_kernel void @test_br_cost(ptr addrspace(1) %vaddr, i32 %b) #0 {
7; ALL-LABEL: 'test_br_cost'
8; ALL-NEXT:  Cost Model: Found an estimated cost of 7 for instruction: br i1 undef, label %bb1, label %bb2
9; ALL-NEXT:  Cost Model: Found an estimated cost of 4 for instruction: br label %bb2
10; ALL-NEXT:  Cost Model: Found an estimated cost of 1 for instruction: %phi = phi i32 [ %b, %bb0 ], [ undef, %bb1 ]
11; ALL-NEXT:  Cost Model: Found an estimated cost of 10 for instruction: ret void
12;
13; ALL-SIZE-LABEL: 'test_br_cost'
14; ALL-SIZE-NEXT:  Cost Model: Found an estimated cost of 5 for instruction: br i1 undef, label %bb1, label %bb2
15; ALL-SIZE-NEXT:  Cost Model: Found an estimated cost of 1 for instruction: br label %bb2
16; ALL-SIZE-NEXT:  Cost Model: Found an estimated cost of 0 for instruction: %phi = phi i32 [ %b, %bb0 ], [ undef, %bb1 ]
17; ALL-SIZE-NEXT:  Cost Model: Found an estimated cost of 1 for instruction: ret void
18;
19bb0:
20  br i1 undef, label %bb1, label %bb2
21
22bb1:
23  br label %bb2
24
25bb2:
26  %phi = phi i32 [ %b, %bb0 ], [ undef, %bb1 ]
27  ret void
28}
29
30define amdgpu_kernel void @test_switch_cost(i32 %a) #0 {
31; ALL-LABEL: 'test_switch_cost'
32; ALL-NEXT:  Cost Model: Found an estimated cost of 24 for instruction: switch i32 %a, label %default [
33; ALL-NEXT:    i32 0, label %case0
34; ALL-NEXT:    i32 1, label %case1
35; ALL-NEXT:    ]
36; ALL-NEXT:  Cost Model: Found an estimated cost of 10 for instruction: ret void
37; ALL-NEXT:  Cost Model: Found an estimated cost of 10 for instruction: ret void
38; ALL-NEXT:  Cost Model: Found an estimated cost of 10 for instruction: ret void
39;
40; ALL-SIZE-LABEL: 'test_switch_cost'
41; ALL-SIZE-NEXT:  Cost Model: Found an estimated cost of 18 for instruction: switch i32 %a, label %default [
42; ALL-SIZE-NEXT:    i32 0, label %case0
43; ALL-SIZE-NEXT:    i32 1, label %case1
44; ALL-SIZE-NEXT:    ]
45; ALL-SIZE-NEXT:  Cost Model: Found an estimated cost of 1 for instruction: ret void
46; ALL-SIZE-NEXT:  Cost Model: Found an estimated cost of 1 for instruction: ret void
47; ALL-SIZE-NEXT:  Cost Model: Found an estimated cost of 1 for instruction: ret void
48;
49entry:
50  switch i32 %a, label %default [
51  i32 0, label %case0
52  i32 1, label %case1
53  ]
54
55case0:
56  ret void
57
58case1:
59  ret void
60
61default:
62  ret void
63}
64