diff --git a/clang/lib/CIR/CodeGen/CIRGenBuiltin.cpp b/clang/lib/CIR/CodeGen/CIRGenBuiltin.cpp index 83134995967f..a5696b6c1f07 100644 --- a/clang/lib/CIR/CodeGen/CIRGenBuiltin.cpp +++ b/clang/lib/CIR/CodeGen/CIRGenBuiltin.cpp @@ -1505,7 +1505,7 @@ RValue CIRGenFunction::emitBuiltinExpr(const GlobalDecl GD, unsigned BuiltinID, case Builtin::BI__builtin_elementwise_exp: return emitUnaryFPBuiltin(*this, *E); case Builtin::BI__builtin_elementwise_exp2: - llvm_unreachable("BI__builtin_elementwise_exp2 NYI"); + return emitUnaryFPBuiltin(*this, *E); case Builtin::BI__builtin_elementwise_log: return emitUnaryFPBuiltin(*this, *E); case Builtin::BI__builtin_elementwise_log2: diff --git a/clang/test/CIR/CodeGen/builtins-elementwise.c b/clang/test/CIR/CodeGen/builtins-elementwise.c index f00573f05619..85584a63b2ce 100644 --- a/clang/test/CIR/CodeGen/builtins-elementwise.c +++ b/clang/test/CIR/CodeGen/builtins-elementwise.c @@ -121,6 +121,27 @@ void test_builtin_elementwise_exp(float f, double d, vfloat4 vf4, vd4 = __builtin_elementwise_exp(vd4); } +void test_builtin_elementwise_exp2(float f, double d, vfloat4 vf4, + vdouble4 vd4) { + // CIR-LABEL: test_builtin_elementwise_exp + // LLVM-LABEL: test_builtin_elementwise_exp + // CIR: {{%.*}} = cir.exp2 {{%.*}} : !cir.float + // LLVM: {{%.*}} = call float @llvm.exp2.f32(float {{%.*}}) + f = __builtin_elementwise_exp2(f); + + // CIR: {{%.*}} = cir.exp2 {{%.*}} : !cir.double + // LLVM: {{%.*}} = call double @llvm.exp2.f64(double {{%.*}}) + d = __builtin_elementwise_exp2(d); + + // CIR: {{%.*}} = cir.exp2 {{%.*}} : !cir.vector + // LLVM: {{%.*}} = call <4 x float> @llvm.exp2.v4f32(<4 x float> {{%.*}}) + vf4 = __builtin_elementwise_exp2(vf4); + + // CIR: {{%.*}} = cir.exp2 {{%.*}} : !cir.vector + // LLVM: {{%.*}} = call <4 x double> @llvm.exp2.v4f64(<4 x double> {{%.*}}) + vd4 = __builtin_elementwise_exp2(vd4); +} + void test_builtin_elementwise_log(float f, double d, vfloat4 vf4, vdouble4 vd4) { // CIR-LABEL: test_builtin_elementwise_log