Index: include/clang/Basic/BuiltinsAMDGPU.def =================================================================== --- include/clang/Basic/BuiltinsAMDGPU.def +++ include/clang/Basic/BuiltinsAMDGPU.def @@ -34,6 +34,10 @@ BUILTIN(__builtin_amdgcn_log_clampf, "ff", "nc") BUILTIN(__builtin_amdgcn_ldexp, "ddi", "nc") BUILTIN(__builtin_amdgcn_ldexpf, "ffi", "nc") +BUILTIN(__builtin_amdgcn_frexp_mant, "dd", "nc") +BUILTIN(__builtin_amdgcn_frexp_mantf, "ff", "nc") +BUILTIN(__builtin_amdgcn_frexp_exp, "id", "nc") +BUILTIN(__builtin_amdgcn_frexp_expf, "if", "nc") BUILTIN(__builtin_amdgcn_class, "bdi", "nc") BUILTIN(__builtin_amdgcn_classf, "bfi", "nc") BUILTIN(__builtin_amdgcn_cubeid, "ffff", "nc") Index: lib/CodeGen/CGBuiltin.cpp =================================================================== --- lib/CodeGen/CGBuiltin.cpp +++ lib/CodeGen/CGBuiltin.cpp @@ -7104,6 +7104,14 @@ case AMDGPU::BI__builtin_amdgcn_ldexp: case AMDGPU::BI__builtin_amdgcn_ldexpf: return emitFPIntBuiltin(*this, E, Intrinsic::amdgcn_ldexp); + case AMDGPU::BI__builtin_amdgcn_frexp_mant: + case AMDGPU::BI__builtin_amdgcn_frexp_mantf: { + return emitUnaryBuiltin(*this, E, Intrinsic::amdgcn_frexp_mant); + } + case AMDGPU::BI__builtin_amdgcn_frexp_exp: + case AMDGPU::BI__builtin_amdgcn_frexp_expf: { + return emitUnaryBuiltin(*this, E, Intrinsic::amdgcn_frexp_exp); + } case AMDGPU::BI__builtin_amdgcn_class: case AMDGPU::BI__builtin_amdgcn_classf: return emitFPIntBuiltin(*this, E, Intrinsic::amdgcn_class); Index: test/CodeGenOpenCL/builtins-amdgcn.cl =================================================================== --- test/CodeGenOpenCL/builtins-amdgcn.cl +++ test/CodeGenOpenCL/builtins-amdgcn.cl @@ -150,6 +150,34 @@ *out = __builtin_amdgcn_ldexp(a, b); } +// CHECK-LABEL: @test_frexp_mant_f32 +// CHECK: call float @llvm.amdgcn.frexp.mant.f32 +void test_frexp_mant_f32(global float* out, float a) +{ + *out = __builtin_amdgcn_frexp_mantf(a); +} + +// CHECK-LABEL: @test_frexp_mant_f64 +// CHECK: call double @llvm.amdgcn.frexp.mant.f64 +void test_frexp_mant_f64(global double* out, double a) +{ + *out = __builtin_amdgcn_frexp_mant(a); +} + +// CHECK-LABEL: @test_frexp_exp_f32 +// CHECK: call i32 @llvm.amdgcn.frexp.exp.f32 +void test_frexp_exp_f32(global int* out, float a) +{ + *out = __builtin_amdgcn_frexp_expf(a); +} + +// CHECK-LABEL: @test_frexp_exp_f64 +// CHECK: call i32 @llvm.amdgcn.frexp.exp.f64 +void test_frexp_exp_f64(global int* out, double a) +{ + *out = __builtin_amdgcn_frexp_exp(a); +} + // CHECK-LABEL: @test_class_f32 // CHECK: call i1 @llvm.amdgcn.class.f32 void test_class_f32(global float* out, float a, int b)