Skip to content

Commit 5691d3c

Browse files
committed
[CIR][AMDGPU] Add lowering for amdgcn ds swizzle builtin
1 parent e0e0345 commit 5691d3c

File tree

3 files changed

+22
-0
lines changed

3 files changed

+22
-0
lines changed

clang/lib/CIR/CodeGen/CIRGenBuiltinAMDGPU.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,8 @@ mlir::Value CIRGenFunction::emitAMDGPUBuiltinExpr(unsigned builtinId,
9292
llvm_unreachable("div_fmas_* NYI");
9393
}
9494
case AMDGPU::BI__builtin_amdgcn_ds_swizzle:
95+
return emitBuiltinWithOneOverloadedType<2>(expr, "amdgcn.ds.swizzle")
96+
.getScalarVal();
9597
case AMDGPU::BI__builtin_amdgcn_mov_dpp8:
9698
case AMDGPU::BI__builtin_amdgcn_mov_dpp:
9799
case AMDGPU::BI__builtin_amdgcn_update_dpp: {

clang/test/CIR/CodeGen/HIP/builtins-amdgcn.hip

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -218,3 +218,13 @@ __device__ void test_wave_reduce_add_u32_iterative_i32(int* out, int in) {
218218
__device__ void test_wave_reduce_add_u32_dpp_i32(int* out, int in) {
219219
*out = __builtin_amdgcn_wave_reduce_add_u32(in, 2);
220220
}
221+
222+
// CIR-LABEL: @_Z19test_ds_swizzle_i32Pii
223+
// CIR: cir.llvm.intrinsic "amdgcn.ds.swizzle" {{.*}} : (!s32i, !s32i) -> !s32i
224+
// LLVM: define{{.*}} void @_Z19test_ds_swizzle_i32Pii
225+
// LLVM: call i32 @llvm.amdgcn.ds.swizzle(i32 %{{.*}}, i32 32)
226+
// OGCG: define{{.*}} void @_Z19test_ds_swizzle_i32Pii
227+
// OGCG: call i32 @llvm.amdgcn.ds.swizzle(i32 %{{.*}}, i32 32)
228+
__device__ void test_ds_swizzle_i32(int* out, int a) {
229+
*out = __builtin_amdgcn_ds_swizzle(a, 32);
230+
}

clang/test/CIR/CodeGen/OpenCL/builtins_amdgcn.cl

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -220,3 +220,13 @@ void test_wave_reduce_add_u32_iterative(global int* out, int in) {
220220
void test_wave_reduce_add_u32_dpp(global int* out, int in) {
221221
*out = __builtin_amdgcn_wave_reduce_add_u32(in, 2);
222222
}
223+
224+
// CIR-LABEL: @test_ds_swizzle
225+
// CIR: cir.llvm.intrinsic "amdgcn.ds.swizzle" {{.*}} : (!s32i, !s32i) -> !s32i
226+
// LLVM: define{{.*}} void @test_ds_swizzle
227+
// LLVM: call i32 @llvm.amdgcn.ds.swizzle(i32 %{{.*}}, i32 32)
228+
// OGCG: define{{.*}} void @test_ds_swizzle
229+
// OGCG: call i32 @llvm.amdgcn.ds.swizzle(i32 %{{.*}}, i32 32)
230+
void test_ds_swizzle(global int* out, int a) {
231+
*out = __builtin_amdgcn_ds_swizzle(a, 32);
232+
}

0 commit comments

Comments
 (0)