1; RUN: llc -march=amdgcn -mcpu=gfx906 -verify-machineinstrs < %s | FileCheck %s --check-prefixes=GCN,GFX9
2; RUN: llc -march=amdgcn -mcpu=gfx940 -verify-machineinstrs < %s | FileCheck %s --check-prefixes=GCN,GFX9
3; RUN: llc -march=amdgcn -mcpu=gfx1011 -verify-machineinstrs < %s | FileCheck %s --check-prefixes=GCN,GFX10
4; RUN: llc -march=amdgcn -mcpu=gfx1012 -verify-machineinstrs < %s | FileCheck %s --check-prefixes=GCN,GFX10
5
6declare i32 @llvm.amdgcn.udot8(i32 %a, i32 %b, i32 %c, i1 %clamp)
7
8; GCN-LABEL: {{^}}test_llvm_amdgcn_udot8_clamp
9; GFX9:   v_dot8_u32_u4 v{{[0-9]+}}, s{{[0-9]+}}, v{{[0-9]+}}, v{{[0-9]+}} clamp{{$}}
10; GFX10:  v_dot8_u32_u4 v{{[0-9]+}}, s{{[0-9]+}}, s{{[0-9]+}}, v{{[0-9]+}} clamp{{$}}
11define amdgpu_kernel void @test_llvm_amdgcn_udot8_clamp(
12    i32 addrspace(1)* %r,
13    <8 x i4> addrspace(1)* %a,
14    <8 x i4> addrspace(1)* %b,
15    i32 addrspace(1)* %c) {
16entry:
17  %a.val = load <8 x i4>, <8 x i4> addrspace(1)* %a
18  %b.val = load <8 x i4>, <8 x i4> addrspace(1)* %b
19  %a.val.cast = bitcast <8 x i4> %a.val to i32
20  %b.val.cast = bitcast <8 x i4> %b.val to i32
21  %c.val = load i32, i32 addrspace(1)* %c
22  %r.val = call i32 @llvm.amdgcn.udot8(i32 %a.val.cast, i32 %b.val.cast, i32 %c.val, i1 1)
23  store i32 %r.val, i32 addrspace(1)* %r
24  ret void
25}
26
27; GCN-LABEL: {{^}}test_llvm_amdgcn_udot8_no_clamp
28; GFX9:   v_dot8_u32_u4 v{{[0-9]+}}, s{{[0-9]+}}, v{{[0-9]+}}, v{{[0-9]+}}{{$}}
29; GFX10:  v_dot8_u32_u4 v{{[0-9]+}}, s{{[0-9]+}}, s{{[0-9]+}}, v{{[0-9]+}}{{$}}
30define amdgpu_kernel void @test_llvm_amdgcn_udot8_no_clamp(
31    i32 addrspace(1)* %r,
32    <8 x i4> addrspace(1)* %a,
33    <8 x i4> addrspace(1)* %b,
34    i32 addrspace(1)* %c) {
35entry:
36  %a.val = load <8 x i4>, <8 x i4> addrspace(1)* %a
37  %b.val = load <8 x i4>, <8 x i4> addrspace(1)* %b
38  %a.val.cast = bitcast <8 x i4> %a.val to i32
39  %b.val.cast = bitcast <8 x i4> %b.val to i32
40  %c.val = load i32, i32 addrspace(1)* %c
41  %r.val = call i32 @llvm.amdgcn.udot8(i32 %a.val.cast, i32 %b.val.cast, i32 %c.val, i1 0)
42  store i32 %r.val, i32 addrspace(1)* %r
43  ret void
44}
45