|
| 1 | +; NOTE: Assertions have been autogenerated by utils/update_analyze_test_checks.py UTC_ARGS: --version 5 |
| 2 | +; RUN: opt -passes='print<cost-model>' 2>&1 -disable-output -mtriple=amdgcn-unknown-amdhsa < %s | FileCheck -check-prefixes=ALL,UNPACKEDID %s |
| 3 | +; RUN: opt -passes='print<cost-model>' 2>&1 -disable-output -mtriple=amdgcn-unknown-amdhsa -mcpu=gfx942 < %s | FileCheck -check-prefixes=ALL,PACKEDID %s |
| 4 | + |
| 5 | +; RUN: opt -passes='print<cost-model>' -cost-kind=code-size 2>&1 -disable-output -mtriple=amdgcn-unknown-amdhsa < %s | FileCheck -check-prefixes=SIZE,SIZE-UNPACKEDID %s |
| 6 | +; RUN: opt -passes='print<cost-model>' -cost-kind=code-size 2>&1 -disable-output -mtriple=amdgcn-unknown-amdhsa -mcpu=gfx942 < %s | FileCheck -check-prefixes=SIZE,SIZE-PACKEDID %s |
| 7 | + |
| 8 | +define i32 @workitem_id_x() { |
| 9 | +; ALL-LABEL: 'workitem_id_x' |
| 10 | +; ALL-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %result = call i32 @llvm.amdgcn.workitem.id.x() |
| 11 | +; ALL-NEXT: Cost Model: Found an estimated cost of 10 for instruction: ret i32 %result |
| 12 | +; |
| 13 | +; SIZE-LABEL: 'workitem_id_x' |
| 14 | +; SIZE-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %result = call i32 @llvm.amdgcn.workitem.id.x() |
| 15 | +; SIZE-NEXT: Cost Model: Found an estimated cost of 1 for instruction: ret i32 %result |
| 16 | +; |
| 17 | + %result = call i32 @llvm.amdgcn.workitem.id.x() |
| 18 | + ret i32 %result |
| 19 | +} |
| 20 | + |
| 21 | +define amdgpu_kernel void @kernel_workitem_id_x(ptr addrspace(1) %ptr) { |
| 22 | +; ALL-LABEL: 'kernel_workitem_id_x' |
| 23 | +; ALL-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %result = call i32 @llvm.amdgcn.workitem.id.x() |
| 24 | +; ALL-NEXT: Cost Model: Found an estimated cost of 1 for instruction: store i32 %result, ptr addrspace(1) %ptr, align 4 |
| 25 | +; ALL-NEXT: Cost Model: Found an estimated cost of 10 for instruction: ret void |
| 26 | +; |
| 27 | +; SIZE-LABEL: 'kernel_workitem_id_x' |
| 28 | +; SIZE-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %result = call i32 @llvm.amdgcn.workitem.id.x() |
| 29 | +; SIZE-NEXT: Cost Model: Found an estimated cost of 1 for instruction: store i32 %result, ptr addrspace(1) %ptr, align 4 |
| 30 | +; SIZE-NEXT: Cost Model: Found an estimated cost of 1 for instruction: ret void |
| 31 | +; |
| 32 | + %result = call i32 @llvm.amdgcn.workitem.id.x() |
| 33 | + store i32 %result, ptr addrspace(1) %ptr |
| 34 | + ret void |
| 35 | +} |
| 36 | + |
| 37 | +define i32 @workitem_id_y() { |
| 38 | +; ALL-LABEL: 'workitem_id_y' |
| 39 | +; ALL-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %result = call i32 @llvm.amdgcn.workitem.id.y() |
| 40 | +; ALL-NEXT: Cost Model: Found an estimated cost of 10 for instruction: ret i32 %result |
| 41 | +; |
| 42 | +; SIZE-LABEL: 'workitem_id_y' |
| 43 | +; SIZE-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %result = call i32 @llvm.amdgcn.workitem.id.y() |
| 44 | +; SIZE-NEXT: Cost Model: Found an estimated cost of 1 for instruction: ret i32 %result |
| 45 | +; |
| 46 | + %result = call i32 @llvm.amdgcn.workitem.id.y() |
| 47 | + ret i32 %result |
| 48 | +} |
| 49 | + |
| 50 | +define amdgpu_kernel void @kernel_workitem_id_y(ptr addrspace(1) %ptr) { |
| 51 | +; ALL-LABEL: 'kernel_workitem_id_y' |
| 52 | +; ALL-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %result = call i32 @llvm.amdgcn.workitem.id.y() |
| 53 | +; ALL-NEXT: Cost Model: Found an estimated cost of 1 for instruction: store i32 %result, ptr addrspace(1) %ptr, align 4 |
| 54 | +; ALL-NEXT: Cost Model: Found an estimated cost of 10 for instruction: ret void |
| 55 | +; |
| 56 | +; SIZE-LABEL: 'kernel_workitem_id_y' |
| 57 | +; SIZE-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %result = call i32 @llvm.amdgcn.workitem.id.y() |
| 58 | +; SIZE-NEXT: Cost Model: Found an estimated cost of 1 for instruction: store i32 %result, ptr addrspace(1) %ptr, align 4 |
| 59 | +; SIZE-NEXT: Cost Model: Found an estimated cost of 1 for instruction: ret void |
| 60 | +; |
| 61 | + %result = call i32 @llvm.amdgcn.workitem.id.y() |
| 62 | + store i32 %result, ptr addrspace(1) %ptr |
| 63 | + ret void |
| 64 | +} |
| 65 | + |
| 66 | +define i32 @workitem_id_z() { |
| 67 | +; ALL-LABEL: 'workitem_id_z' |
| 68 | +; ALL-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %result = call i32 @llvm.amdgcn.workitem.id.y() |
| 69 | +; ALL-NEXT: Cost Model: Found an estimated cost of 10 for instruction: ret i32 %result |
| 70 | +; |
| 71 | +; SIZE-LABEL: 'workitem_id_z' |
| 72 | +; SIZE-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %result = call i32 @llvm.amdgcn.workitem.id.y() |
| 73 | +; SIZE-NEXT: Cost Model: Found an estimated cost of 1 for instruction: ret i32 %result |
| 74 | +; |
| 75 | + %result = call i32 @llvm.amdgcn.workitem.id.y() |
| 76 | + ret i32 %result |
| 77 | +} |
| 78 | + |
| 79 | +define amdgpu_kernel void @kernel_workitem_id_z(ptr addrspace(1) %ptr) { |
| 80 | +; ALL-LABEL: 'kernel_workitem_id_z' |
| 81 | +; ALL-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %result = call i32 @llvm.amdgcn.workitem.id.z() |
| 82 | +; ALL-NEXT: Cost Model: Found an estimated cost of 1 for instruction: store i32 %result, ptr addrspace(1) %ptr, align 4 |
| 83 | +; ALL-NEXT: Cost Model: Found an estimated cost of 10 for instruction: ret void |
| 84 | +; |
| 85 | +; SIZE-LABEL: 'kernel_workitem_id_z' |
| 86 | +; SIZE-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %result = call i32 @llvm.amdgcn.workitem.id.z() |
| 87 | +; SIZE-NEXT: Cost Model: Found an estimated cost of 1 for instruction: store i32 %result, ptr addrspace(1) %ptr, align 4 |
| 88 | +; SIZE-NEXT: Cost Model: Found an estimated cost of 1 for instruction: ret void |
| 89 | +; |
| 90 | + %result = call i32 @llvm.amdgcn.workitem.id.z() |
| 91 | + store i32 %result, ptr addrspace(1) %ptr |
| 92 | + ret void |
| 93 | +} |
| 94 | + |
| 95 | +define i32 @workgroup_id_x() { |
| 96 | +; ALL-LABEL: 'workgroup_id_x' |
| 97 | +; ALL-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %result = call i32 @llvm.amdgcn.workgroup.id.x() |
| 98 | +; ALL-NEXT: Cost Model: Found an estimated cost of 10 for instruction: ret i32 %result |
| 99 | +; |
| 100 | +; SIZE-LABEL: 'workgroup_id_x' |
| 101 | +; SIZE-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %result = call i32 @llvm.amdgcn.workgroup.id.x() |
| 102 | +; SIZE-NEXT: Cost Model: Found an estimated cost of 1 for instruction: ret i32 %result |
| 103 | +; |
| 104 | + %result = call i32 @llvm.amdgcn.workgroup.id.x() |
| 105 | + ret i32 %result |
| 106 | +} |
| 107 | + |
| 108 | +define i32 @workgroup_id_y() { |
| 109 | +; ALL-LABEL: 'workgroup_id_y' |
| 110 | +; ALL-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %result = call i32 @llvm.amdgcn.workgroup.id.y() |
| 111 | +; ALL-NEXT: Cost Model: Found an estimated cost of 10 for instruction: ret i32 %result |
| 112 | +; |
| 113 | +; SIZE-LABEL: 'workgroup_id_y' |
| 114 | +; SIZE-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %result = call i32 @llvm.amdgcn.workgroup.id.y() |
| 115 | +; SIZE-NEXT: Cost Model: Found an estimated cost of 1 for instruction: ret i32 %result |
| 116 | +; |
| 117 | + %result = call i32 @llvm.amdgcn.workgroup.id.y() |
| 118 | + ret i32 %result |
| 119 | +} |
| 120 | + |
| 121 | +define i32 @workgroup_id_z() { |
| 122 | +; ALL-LABEL: 'workgroup_id_z' |
| 123 | +; ALL-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %result = call i32 @llvm.amdgcn.workgroup.id.y() |
| 124 | +; ALL-NEXT: Cost Model: Found an estimated cost of 10 for instruction: ret i32 %result |
| 125 | +; |
| 126 | +; SIZE-LABEL: 'workgroup_id_z' |
| 127 | +; SIZE-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %result = call i32 @llvm.amdgcn.workgroup.id.y() |
| 128 | +; SIZE-NEXT: Cost Model: Found an estimated cost of 1 for instruction: ret i32 %result |
| 129 | +; |
| 130 | + %result = call i32 @llvm.amdgcn.workgroup.id.y() |
| 131 | + ret i32 %result |
| 132 | +} |
| 133 | + |
| 134 | +define i32 @lds_kernel_id() { |
| 135 | +; ALL-LABEL: 'lds_kernel_id' |
| 136 | +; ALL-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %result = call i32 @llvm.amdgcn.lds.kernel.id() |
| 137 | +; ALL-NEXT: Cost Model: Found an estimated cost of 10 for instruction: ret i32 %result |
| 138 | +; |
| 139 | +; SIZE-LABEL: 'lds_kernel_id' |
| 140 | +; SIZE-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %result = call i32 @llvm.amdgcn.lds.kernel.id() |
| 141 | +; SIZE-NEXT: Cost Model: Found an estimated cost of 1 for instruction: ret i32 %result |
| 142 | +; |
| 143 | + %result = call i32 @llvm.amdgcn.lds.kernel.id() |
| 144 | + ret i32 %result |
| 145 | +} |
| 146 | + |
| 147 | +define ptr addrspace(4) @dispatch_ptr() { |
| 148 | +; ALL-LABEL: 'dispatch_ptr' |
| 149 | +; ALL-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %result = call ptr addrspace(4) @llvm.amdgcn.dispatch.ptr() |
| 150 | +; ALL-NEXT: Cost Model: Found an estimated cost of 10 for instruction: ret ptr addrspace(4) %result |
| 151 | +; |
| 152 | +; SIZE-LABEL: 'dispatch_ptr' |
| 153 | +; SIZE-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %result = call ptr addrspace(4) @llvm.amdgcn.dispatch.ptr() |
| 154 | +; SIZE-NEXT: Cost Model: Found an estimated cost of 1 for instruction: ret ptr addrspace(4) %result |
| 155 | +; |
| 156 | + %result = call ptr addrspace(4) @llvm.amdgcn.dispatch.ptr() |
| 157 | + ret ptr addrspace(4) %result |
| 158 | +} |
| 159 | + |
| 160 | +define i64 @dispatch_id_() { |
| 161 | +; ALL-LABEL: 'dispatch_id_' |
| 162 | +; ALL-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %result = call i64 @llvm.amdgcn.dispatch.id() |
| 163 | +; ALL-NEXT: Cost Model: Found an estimated cost of 10 for instruction: ret i64 %result |
| 164 | +; |
| 165 | +; SIZE-LABEL: 'dispatch_id_' |
| 166 | +; SIZE-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %result = call i64 @llvm.amdgcn.dispatch.id() |
| 167 | +; SIZE-NEXT: Cost Model: Found an estimated cost of 1 for instruction: ret i64 %result |
| 168 | +; |
| 169 | + %result = call i64 @llvm.amdgcn.dispatch.id() |
| 170 | + ret i64 %result |
| 171 | +} |
| 172 | + |
| 173 | +define ptr addrspace(4) @implicitarg_ptr() { |
| 174 | +; ALL-LABEL: 'implicitarg_ptr' |
| 175 | +; ALL-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %result = call ptr addrspace(4) @llvm.amdgcn.implicitarg.ptr() |
| 176 | +; ALL-NEXT: Cost Model: Found an estimated cost of 10 for instruction: ret ptr addrspace(4) %result |
| 177 | +; |
| 178 | +; SIZE-LABEL: 'implicitarg_ptr' |
| 179 | +; SIZE-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %result = call ptr addrspace(4) @llvm.amdgcn.implicitarg.ptr() |
| 180 | +; SIZE-NEXT: Cost Model: Found an estimated cost of 1 for instruction: ret ptr addrspace(4) %result |
| 181 | +; |
| 182 | + %result = call ptr addrspace(4) @llvm.amdgcn.implicitarg.ptr() |
| 183 | + ret ptr addrspace(4) %result |
| 184 | +} |
| 185 | + |
| 186 | +define ptr addrspace(4) @queue_ptr() { |
| 187 | +; ALL-LABEL: 'queue_ptr' |
| 188 | +; ALL-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %result = call ptr addrspace(4) @llvm.amdgcn.queue.ptr() |
| 189 | +; ALL-NEXT: Cost Model: Found an estimated cost of 10 for instruction: ret ptr addrspace(4) %result |
| 190 | +; |
| 191 | +; SIZE-LABEL: 'queue_ptr' |
| 192 | +; SIZE-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %result = call ptr addrspace(4) @llvm.amdgcn.queue.ptr() |
| 193 | +; SIZE-NEXT: Cost Model: Found an estimated cost of 1 for instruction: ret ptr addrspace(4) %result |
| 194 | +; |
| 195 | + %result = call ptr addrspace(4) @llvm.amdgcn.queue.ptr() |
| 196 | + ret ptr addrspace(4) %result |
| 197 | +} |
| 198 | +;; NOTE: These prefixes are unused and the list is autogenerated. Do not add tests below this line: |
| 199 | +; PACKEDID: {{.*}} |
| 200 | +; SIZE-PACKEDID: {{.*}} |
| 201 | +; SIZE-UNPACKEDID: {{.*}} |
| 202 | +; UNPACKEDID: {{.*}} |
0 commit comments