1 // RUN: %clang_cc1 %s -ffreestanding -triple=x86_64-unknown-unknown -target-feature +avx512f -target-feature +amx-int8 \
2 // RUN: -target-feature +amx-bf16 -emit-llvm -o - -Werror -pedantic | FileCheck %s --check-prefixes=CHECK
3
4 #include <immintrin.h>
5
6 char buf[1024];
7 #define STRIDE 32
8
9 char buf2[1024];
10
11 // This is an example code and integration test.
test_api(int cond,short row,short col)12 void test_api(int cond, short row, short col) {
13 //CHECK-LABEL: @test_api
14 //CHECK: call x86_amx @llvm.x86.tileloadd64.internal
15 //CHECK: call x86_amx @llvm.x86.tdpbssd.internal
16 //CHECK: call void @llvm.x86.tilestored64.internal
17 __tile1024i a = {row, 8};
18 __tile1024i b = {8, col};
19 __tile1024i c = {row, col};
20
21 if (cond) {
22 __tile_loadd(&a, buf, STRIDE);
23 __tile_loadd(&b, buf, STRIDE);
24 __tile_loadd(&c, buf, STRIDE);
25 } else {
26 __tile_loadd(&a, buf2, STRIDE);
27 __tile_loadd(&b, buf2, STRIDE);
28 __tile_loadd(&c, buf2, STRIDE);
29 }
30 __tile_dpbssd(&c, a, b);
31 __tile_stored(buf, STRIDE, c);
32 }
33
test_tile_loadd(short row,short col)34 void test_tile_loadd(short row, short col) {
35 //CHECK-LABEL: @test_tile_loadd
36 //CHECK: call x86_amx @llvm.x86.tileloadd64.internal
37 //CHECK-NEXT: {{%.*}} = bitcast x86_amx {{%.*}} to <256 x i32>
38 __tile1024i a = {row, col};
39 __tile_loadd(&a, buf, STRIDE);
40 }
41
test_tile_dpbssd(__tile1024i a,__tile1024i b,__tile1024i c)42 void test_tile_dpbssd(__tile1024i a, __tile1024i b, __tile1024i c) {
43 //CHECK-LABEL: @test_tile_dpbssd
44 //CHECK: call x86_amx @llvm.x86.tdpbssd.internal
45 //CHECK-NEXT: {{%.*}} = bitcast x86_amx {{%.*}} to <256 x i32>
46 __tile_dpbssd(&c, a, b);
47 }
48
test_tile_stored(__tile1024i c)49 void test_tile_stored(__tile1024i c) {
50 //CHECK-LABEL: @test_tile_stored
51 //CHECK: {{%.*}} = bitcast <256 x i32> {{%.*}} to x86_amx
52 //CHECK-NEXT: call void @llvm.x86.tilestored64.internal
53 __tile_stored(buf, STRIDE, c);
54 }
55
test_tile_zero(__tile1024i c)56 void test_tile_zero(__tile1024i c) {
57 //CHECK-LABEL: @test_tile_zero
58 //CHECK: call x86_amx @llvm.x86.tilezero.internal
59 //CHECK-NEXT bitcast x86_amx {{%.*}} to <256 x i32>
60 __tile_zero(&c);
61 }
62