Skip to content

[CIR][CIRGen] Support for __builtin_elementwise_exp2 #1656

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion clang/lib/CIR/CodeGen/CIRGenBuiltin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1505,7 +1505,7 @@ RValue CIRGenFunction::emitBuiltinExpr(const GlobalDecl GD, unsigned BuiltinID,
case Builtin::BI__builtin_elementwise_exp:
return emitUnaryFPBuiltin<cir::ExpOp>(*this, *E);
case Builtin::BI__builtin_elementwise_exp2:
llvm_unreachable("BI__builtin_elementwise_exp2 NYI");
return emitUnaryFPBuiltin<cir::Exp2Op>(*this, *E);
case Builtin::BI__builtin_elementwise_log:
return emitUnaryFPBuiltin<cir::LogOp>(*this, *E);
case Builtin::BI__builtin_elementwise_log2:
Expand Down
21 changes: 21 additions & 0 deletions clang/test/CIR/CodeGen/builtins-elementwise.c
Original file line number Diff line number Diff line change
Expand Up @@ -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<!cir.float x 4>
// LLVM: {{%.*}} = call <4 x float> @llvm.exp2.v4f32(<4 x float> {{%.*}})
vf4 = __builtin_elementwise_exp2(vf4);

// CIR: {{%.*}} = cir.exp2 {{%.*}} : !cir.vector<!cir.double x 4>
// 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
Expand Down
Loading