|
| 1 | +; RUN: llc < %s -mtriple=amdgcn -mcpu=gfx908 -verify-machineinstrs -amdgpu-atomic-optimizer-strategy=DPP | FileCheck %s -check-prefix=GCN |
| 2 | +; RUN: llc < %s -mtriple=amdgcn -mcpu=gfx90a -verify-machineinstrs -amdgpu-atomic-optimizer-strategy=DPP | FileCheck %s -check-prefix=GCN |
| 3 | + |
| 4 | +declare float @llvm.amdgcn.global.atomic.fadd.f32.p1.f32(ptr addrspace(1), float) |
| 5 | +declare <2 x half> @llvm.amdgcn.global.atomic.fadd.v2f16.p1.v2f16(ptr addrspace(1), <2 x half>) |
| 6 | +declare float @llvm.amdgcn.flat.atomic.fadd.f32.p0.f32(ptr, float) |
| 7 | + |
| 8 | +; GCN-LABEL: {{^}}global_atomic_add_f32: |
| 9 | +; GCN: global_atomic_add_f32 v{{[0-9]+}}, v{{[0-9]+}}, s{{\[[0-9]+:[0-9]+\]}} |
| 10 | +define amdgpu_kernel void @global_atomic_add_f32(ptr addrspace(1) %ptr, float %data) { |
| 11 | +main_body: |
| 12 | + %ret = call float @llvm.amdgcn.global.atomic.fadd.f32.p1.f32(ptr addrspace(1) %ptr, float %data) |
| 13 | + ret void |
| 14 | +} |
| 15 | + |
| 16 | +; GCN-LABEL: {{^}}global_atomic_add_f32_off4: |
| 17 | +; GCN: global_atomic_add_f32 v{{[0-9]+}}, v{{[0-9]+}}, s{{\[[0-9]+:[0-9]+\]}} offset:4 |
| 18 | +define amdgpu_kernel void @global_atomic_add_f32_off4(ptr addrspace(1) %ptr, float %data) { |
| 19 | +main_body: |
| 20 | + %p = getelementptr float, ptr addrspace(1) %ptr, i64 1 |
| 21 | + %ret = call float @llvm.amdgcn.global.atomic.fadd.f32.p1.f32(ptr addrspace(1) %p, float %data) |
| 22 | + ret void |
| 23 | +} |
| 24 | + |
| 25 | +; GCN-LABEL: {{^}}global_atomic_add_f32_offneg4: |
| 26 | +; GCN: global_atomic_add_f32 v{{[0-9]+}}, v{{[0-9]+}}, s{{\[[0-9]+:[0-9]+\]}} offset:-4 |
| 27 | +define amdgpu_kernel void @global_atomic_add_f32_offneg4(ptr addrspace(1) %ptr, float %data) { |
| 28 | +main_body: |
| 29 | + %p = getelementptr float, ptr addrspace(1) %ptr, i64 -1 |
| 30 | + %ret = call float @llvm.amdgcn.global.atomic.fadd.f32.p1.f32(ptr addrspace(1) %p, float %data) |
| 31 | + ret void |
| 32 | +} |
| 33 | + |
| 34 | +; GCN-LABEL: {{^}}global_atomic_pk_add_v2f16: |
| 35 | +; GCN: global_atomic_pk_add_f16 v{{[0-9]+}}, v{{[0-9]+}}, s{{\[[0-9]+:[0-9]+\]$}} |
| 36 | +define amdgpu_kernel void @global_atomic_pk_add_v2f16(ptr addrspace(1) %ptr, <2 x half> %data) { |
| 37 | +main_body: |
| 38 | + %ret = call <2 x half> @llvm.amdgcn.global.atomic.fadd.v2f16.p1.v2f16(ptr addrspace(1) %ptr, <2 x half> %data) |
| 39 | + ret void |
| 40 | +} |
| 41 | + |
| 42 | +; GCN-LABEL: {{^}}global_atomic_pk_add_v2f16_off4: |
| 43 | +; GCN: global_atomic_pk_add_f16 v{{[0-9]+}}, v{{[0-9]+}}, s{{\[[0-9]+:[0-9]+\]}} offset:4 |
| 44 | +define amdgpu_kernel void @global_atomic_pk_add_v2f16_off4(ptr addrspace(1) %ptr, <2 x half> %data) { |
| 45 | +main_body: |
| 46 | + %p = getelementptr <2 x half>, ptr addrspace(1) %ptr, i64 1 |
| 47 | + %ret = call <2 x half> @llvm.amdgcn.global.atomic.fadd.v2f16.p1.v2f16(ptr addrspace(1) %p, <2 x half> %data) |
| 48 | + ret void |
| 49 | +} |
| 50 | + |
| 51 | +; GCN-LABEL: {{^}}global_atomic_pk_add_v2f16_offneg4: |
| 52 | +; GCN: global_atomic_pk_add_f16 v{{[0-9]+}}, v{{[0-9]+}}, s{{\[[0-9]+:[0-9]+\]}} offset:-4{{$}} |
| 53 | +define amdgpu_kernel void @global_atomic_pk_add_v2f16_offneg4(ptr addrspace(1) %ptr, <2 x half> %data) { |
| 54 | +main_body: |
| 55 | + %p = getelementptr <2 x half>, ptr addrspace(1) %ptr, i64 -1 |
| 56 | + %ret = call <2 x half> @llvm.amdgcn.global.atomic.fadd.v2f16.p1.v2f16(ptr addrspace(1) %p, <2 x half> %data) |
| 57 | + ret void |
| 58 | +} |
| 59 | + |
| 60 | +; Make sure this artificially selects with an incorrect subtarget, but |
| 61 | +; the feature set. |
| 62 | +; GCN-LABEL: {{^}}global_atomic_fadd_f32_wrong_subtarget: |
| 63 | +; GCN: global_atomic_add_f32 v{{[0-9]+}}, v{{[0-9]+}}, s{{\[[0-9]+:[0-9]+\]$}} |
| 64 | +define amdgpu_kernel void @global_atomic_fadd_f32_wrong_subtarget(ptr addrspace(1) %ptr, float %data) #0 { |
| 65 | + %ret = call float @llvm.amdgcn.global.atomic.fadd.f32.p1.f32(ptr addrspace(1) %ptr, float %data) |
| 66 | + ret void |
| 67 | +} |
| 68 | + |
| 69 | +; GCN-LABEL: {{^}}flat_atomic_fadd_f32_wrong_subtarget: |
| 70 | +; GCN: flat_atomic_add_f32 v{{\[[0-9]+:[0-9]+\]}}, v{{[0-9]+}} |
| 71 | +define amdgpu_kernel void @flat_atomic_fadd_f32_wrong_subtarget(ptr %ptr, float %data) #1 { |
| 72 | + %ret = call float @llvm.amdgcn.flat.atomic.fadd.f32.p0.f32(ptr %ptr, float %data) |
| 73 | + ret void |
| 74 | +} |
| 75 | + |
| 76 | +attributes #0 = { "target-cpu"="gfx803" "target-features"="+atomic-fadd-no-rtn-insts"} |
| 77 | +attributes #1 = { "target-cpu"="gfx803" "target-features"="+flat-atomic-fadd-f32-inst"} |
0 commit comments