Index: include/clang/Basic/BuiltinsAMDGPU.def =================================================================== --- include/clang/Basic/BuiltinsAMDGPU.def +++ include/clang/Basic/BuiltinsAMDGPU.def @@ -76,6 +76,7 @@ BUILTIN(__builtin_amdgcn_sicmpl, "LUiLiLiIi", "nc") BUILTIN(__builtin_amdgcn_fcmp, "LUiddIi", "nc") BUILTIN(__builtin_amdgcn_fcmpf, "LUiffIi", "nc") +BUILTIN(__builtin_amdgcn_ds_swizzle, "iii", "nc") //===----------------------------------------------------------------------===// // VI+ only builtins. Index: lib/CodeGen/CGBuiltin.cpp =================================================================== --- lib/CodeGen/CGBuiltin.cpp +++ lib/CodeGen/CGBuiltin.cpp @@ -7652,6 +7652,9 @@ llvm::Value *Src3ToBool = Builder.CreateIsNotNull(Src3); return Builder.CreateCall(F, {Src0, Src1, Src2, Src3ToBool}); } + + case AMDGPU::BI__builtin_amdgcn_ds_swizzle: + return emitBinaryBuiltin(*this, E, Intrinsic::amdgcn_ds_swizzle); case AMDGPU::BI__builtin_amdgcn_div_fixup: case AMDGPU::BI__builtin_amdgcn_div_fixupf: return emitTernaryBuiltin(*this, E, Intrinsic::amdgcn_div_fixup); Index: test/CodeGenOpenCL/builtins-amdgcn.cl =================================================================== --- test/CodeGenOpenCL/builtins-amdgcn.cl +++ test/CodeGenOpenCL/builtins-amdgcn.cl @@ -228,6 +228,13 @@ *out = __builtin_amdgcn_uicmpl(a, b, 30+5); } +// CHECK-LABEL: @test_ds_swizzle +// CHECK: call i32 @llvm.amdgcn.ds.swizzle(i32 %a, i32 32) +void test_ds_swizzle(global int* out, int a) +{ + *out = __builtin_amdgcn_ds_swizzle(a, 32); +} + // CHECK-LABEL: @test_fcmp_f32 // CHECK: call i64 @llvm.amdgcn.fcmp.f32(float %a, float %b, i32 5) void test_fcmp_f32(global ulong* out, float a, float b)