Skip to content
Merged
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
6 changes: 3 additions & 3 deletions clang/lib/CIR/CodeGen/CIRGenBuiltin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1457,11 +1457,11 @@ RValue CIRGenFunction::emitBuiltinExpr(const GlobalDecl GD, unsigned BuiltinID,
case Builtin::BI__builtin_elementwise_exp2:
llvm_unreachable("BI__builtin_elementwise_exp2 NYI");
case Builtin::BI__builtin_elementwise_log:
llvm_unreachable("BI__builtin_elementwise_log NYI");
return emitUnaryFPBuiltin<cir::LogOp>(*this, *E);
case Builtin::BI__builtin_elementwise_log2:
llvm_unreachable("BI__builtin_elementwise_log2 NYI");
return emitUnaryFPBuiltin<cir::Log2Op>(*this, *E);
case Builtin::BI__builtin_elementwise_log10:
llvm_unreachable("BI__builtin_elementwise_log10 NYI");
return emitUnaryFPBuiltin<cir::Log10Op>(*this, *E);
case Builtin::BI__builtin_elementwise_pow:
llvm_unreachable("BI__builtin_elementwise_pow NYI");
case Builtin::BI__builtin_elementwise_bitreverse:
Expand Down
63 changes: 63 additions & 0 deletions clang/test/CIR/CodeGen/builtins-elementwise.c
Original file line number Diff line number Diff line change
Expand Up @@ -120,3 +120,66 @@ void test_builtin_elementwise_exp(float f, double d, vfloat4 vf4,
// LLVM: {{%.*}} = call <4 x double> @llvm.exp.v4f64(<4 x double> {{%.*}})
vd4 = __builtin_elementwise_exp(vd4);
}

void test_builtin_elementwise_log(float f, double d, vfloat4 vf4,
vdouble4 vd4) {
// CIR-LABEL: test_builtin_elementwise_log
// LLVM-LABEL: test_builtin_elementwise_log
// CIR: {{%.*}} = cir.log {{%.*}} : !cir.float
// LLVM: {{%.*}} = call float @llvm.log.f32(float {{%.*}})
f = __builtin_elementwise_log(f);

// CIR: {{%.*}} = cir.log {{%.*}} : !cir.double
// LLVM: {{%.*}} = call double @llvm.log.f64(double {{%.*}})
d = __builtin_elementwise_log(d);

// CIR: {{%.*}} = cir.log {{%.*}} : !cir.vector<!cir.float x 4>
// LLVM: {{%.*}} = call <4 x float> @llvm.log.v4f32(<4 x float> {{%.*}})
vf4 = __builtin_elementwise_log(vf4);

// CIR: {{%.*}} = cir.log {{%.*}} : !cir.vector<!cir.double x 4>
// LLVM: {{%.*}} = call <4 x double> @llvm.log.v4f64(<4 x double> {{%.*}})
vd4 = __builtin_elementwise_log(vd4);
}

void test_builtin_elementwise_log2(float f, double d, vfloat4 vf4,
vdouble4 vd4) {
// CIR-LABEL: test_builtin_elementwise_log2
// LLVM-LABEL: test_builtin_elementwise_log2
// CIR: {{%.*}} = cir.log2 {{%.*}} : !cir.float
// LLVM: {{%.*}} = call float @llvm.log2.f32(float {{%.*}})
f = __builtin_elementwise_log2(f);

// CIR: {{%.*}} = cir.log2 {{%.*}} : !cir.double
// LLVM: {{%.*}} = call double @llvm.log2.f64(double {{%.*}})
d = __builtin_elementwise_log2(d);

// CIR: {{%.*}} = cir.log2 {{%.*}} : !cir.vector<!cir.float x 4>
// LLVM: {{%.*}} = call <4 x float> @llvm.log2.v4f32(<4 x float> {{%.*}})
vf4 = __builtin_elementwise_log2(vf4);

// CIR: {{%.*}} = cir.log2 {{%.*}} : !cir.vector<!cir.double x 4>
// LLVM: {{%.*}} = call <4 x double> @llvm.log2.v4f64(<4 x double> {{%.*}})
vd4 = __builtin_elementwise_log2(vd4);
}

void test_builtin_elementwise_log10(float f, double d, vfloat4 vf4,
vdouble4 vd4) {
// CIR-LABEL: test_builtin_elementwise_log10
// LLVM-LABEL: test_builtin_elementwise_log10
// CIR: {{%.*}} = cir.log10 {{%.*}} : !cir.float
// LLVM: {{%.*}} = call float @llvm.log10.f32(float {{%.*}})
f = __builtin_elementwise_log10(f);

// CIR: {{%.*}} = cir.log10 {{%.*}} : !cir.double
// LLVM: {{%.*}} = call double @llvm.log10.f64(double {{%.*}})
d = __builtin_elementwise_log10(d);

// CIR: {{%.*}} = cir.log10 {{%.*}} : !cir.vector<!cir.float x 4>
// LLVM: {{%.*}} = call <4 x float> @llvm.log10.v4f32(<4 x float> {{%.*}})
vf4 = __builtin_elementwise_log10(vf4);

// CIR: {{%.*}} = cir.log10 {{%.*}} : !cir.vector<!cir.double x 4>
// LLVM: {{%.*}} = call <4 x double> @llvm.log10.v4f64(<4 x double> {{%.*}})
vd4 = __builtin_elementwise_log10(vd4);
}
Loading