102 lines · plain
1// REQUIRES: amdgpu-registered-target2// RUN: %clang_cc1 -triple amdgcn-unknown-unknown -target-cpu gfx1010 -emit-llvm -o - %s | FileCheck %s3// RUN: %clang_cc1 -triple amdgcn-unknown-unknown -target-cpu gfx1011 -emit-llvm -o - %s | FileCheck %s4// RUN: %clang_cc1 -triple amdgcn-unknown-unknown -target-cpu gfx1012 -emit-llvm -o - %s | FileCheck %s5// RUN: %clang_cc1 -triple spirv64-amd-amdhsa -emit-llvm -o - %s | FileCheck %s6 7#pragma OPENCL EXTENSION cl_khr_fp16 : enable8 9typedef unsigned int uint;10typedef unsigned long ulong;11 12// CHECK-LABEL: @test_permlane16(13// CHECK: {{.*}}call{{.*}} i32 @llvm.amdgcn.permlane16.i32(i32 %a, i32 %b, i32 %c, i32 %d, i1 false, i1 false)14void test_permlane16(global uint* out, uint a, uint b, uint c, uint d) {15 *out = __builtin_amdgcn_permlane16(a, b, c, d, 0, 0);16}17 18// CHECK-LABEL: @test_permlanex16(19// CHECK: {{.*}}call{{.*}} i32 @llvm.amdgcn.permlanex16.i32(i32 %a, i32 %b, i32 %c, i32 %d, i1 false, i1 false)20void test_permlanex16(global uint* out, uint a, uint b, uint c, uint d) {21 *out = __builtin_amdgcn_permlanex16(a, b, c, d, 0, 0);22}23 24// CHECK-LABEL: @test_mov_dpp8_uint(25// CHECK: {{.*}}call{{.*}} i32 @llvm.amdgcn.mov.dpp8.i32(i32 %a, i32 1)26// CHECK-NEXT: store i32 %0,27void test_mov_dpp8_uint(global uint* out, uint a) {28 *out = __builtin_amdgcn_mov_dpp8(a, 1);29}30 31// CHECK-LABEL: @test_mov_dpp8_long(32// CHECK: {{.*}}call{{.*}} i64 @llvm.amdgcn.mov.dpp8.i64(i64 %a, i32 1)33// CHECK-NEXT: store i64 %0,34void test_mov_dpp8_long(global long* out, long a) {35 *out = __builtin_amdgcn_mov_dpp8(a, 1);36}37 38// CHECK-LABEL: @test_mov_dpp8_float(39// CHECK: %0 = bitcast float %a to i3240// CHECK-NEXT: %1 = tail call{{.*}} i32 @llvm.amdgcn.mov.dpp8.i32(i32 %0, i32 1)41// CHECK-NEXT: store i32 %1,42void test_mov_dpp8_float(global float* out, float a) {43 *out = __builtin_amdgcn_mov_dpp8(a, 1);44}45 46// CHECK-LABEL: @test_mov_dpp8_double47// CHECK: %0 = bitcast double %x to i6448// CHECK-NEXT: %1 = tail call{{.*}} i64 @llvm.amdgcn.mov.dpp8.i64(i64 %0, i32 1)49// CHECK-NEXT: store i64 %1,50void test_mov_dpp8_double(double x, global double *p) {51 *p = __builtin_amdgcn_mov_dpp8(x, 1);52}53 54// CHECK-LABEL: @test_mov_dpp8_short55// CHECK: %0 = zext i16 %x to i3256// CHECK-NEXT: %1 = tail call{{.*}} i32 @llvm.amdgcn.mov.dpp8.i32(i32 %0, i32 1)57// CHECK-NEXT: %2 = trunc i32 %1 to i1658// CHECK-NEXT: store i16 %2,59void test_mov_dpp8_short(short x, global short *p) {60 *p = __builtin_amdgcn_mov_dpp8(x, 1);61}62 63// CHECK-LABEL: @test_mov_dpp8_char64// CHECK: %0 = zext i8 %x to i3265// CHECK-NEXT: %1 = tail call{{.*}} i32 @llvm.amdgcn.mov.dpp8.i32(i32 %0, i32 1)66// CHECK-NEXT: %2 = trunc i32 %1 to i867// CHECK-NEXT: store i8 %2,68void test_mov_dpp8_char(char x, global char *p) {69 *p = __builtin_amdgcn_mov_dpp8(x, 1);70}71 72// CHECK-LABEL: @test_mov_dpp8_half73// CHECK: %0 = load i16,74// CHECK: %1 = zext i16 %0 to i3275// CHECK-NEXT: %2 = tail call{{.*}} i32 @llvm.amdgcn.mov.dpp8.i32(i32 %1, i32 1)76// CHECK-NEXT: %3 = trunc i32 %2 to i1677// CHECK-NEXT: store i16 %3,78void test_mov_dpp8_half(half *x, global half *p) {79 *p = __builtin_amdgcn_mov_dpp8(*x, 1);80}81 82// CHECK-LABEL: @test_s_memtime83// CHECK: {{.*}}call{{.*}} i64 @llvm.amdgcn.s.memtime()84void test_s_memtime(global ulong* out)85{86 *out = __builtin_amdgcn_s_memtime();87}88 89// CHECK-LABEL: @test_groupstaticsize90// CHECK: {{.*}}call{{.*}} i32 @llvm.amdgcn.groupstaticsize()91void test_groupstaticsize(global uint* out)92{93 *out = __builtin_amdgcn_groupstaticsize();94}95 96// CHECK-LABEL: @test_ballot_wave32(97// CHECK: {{.*}}call{{.*}} i32 @llvm.amdgcn.ballot.i32(i1 %{{.+}})98void test_ballot_wave32(global uint* out, int a, int b)99{100 *out = __builtin_amdgcn_ballot_w32(a == b);101}102