[CIR] Support __builtin_elementwise_ceil#204974
Open
FantasqueX wants to merge 1 commit into
Open
Conversation
|
@llvm/pr-subscribers-clang @llvm/pr-subscribers-clangir Author: Letu Ren (FantasqueX) ChangesFull diff: https://github.com/llvm/llvm-project/pull/204974.diff 2 Files Affected:
diff --git a/clang/lib/CIR/CodeGen/CIRGenBuiltin.cpp b/clang/lib/CIR/CodeGen/CIRGenBuiltin.cpp
index a483eb635f0e2..cebc4cc733ece 100644
--- a/clang/lib/CIR/CodeGen/CIRGenBuiltin.cpp
+++ b/clang/lib/CIR/CodeGen/CIRGenBuiltin.cpp
@@ -537,9 +537,8 @@ static RValue tryEmitFPMathIntrinsic(CIRGenFunction &cgf, const CallExpr *e,
case Builtin::BI__builtin_ceilf16:
case Builtin::BI__builtin_ceill:
case Builtin::BI__builtin_ceilf128:
- return emitUnaryMaybeConstrainedFPBuiltin<cir::CeilOp>(cgf, *e);
case Builtin::BI__builtin_elementwise_ceil:
- return RValue::getIgnored();
+ return emitUnaryMaybeConstrainedFPBuiltin<cir::CeilOp>(cgf, *e);
case Builtin::BIcopysign:
case Builtin::BIcopysignf:
case Builtin::BIcopysignl:
@@ -1645,6 +1644,8 @@ RValue CIRGenFunction::emitBuiltinExpr(const GlobalDecl &gd, unsigned builtinID,
return emitUnaryMaybeConstrainedFPBuiltin<cir::Log10Op>(*this, *e);
case Builtin::BI__builtin_elementwise_cos:
return emitUnaryMaybeConstrainedFPBuiltin<cir::CosOp>(*this, *e);
+ case Builtin::BI__builtin_elementwise_ceil:
+ return emitUnaryMaybeConstrainedFPBuiltin<cir::CeilOp>(*this, *e);
case Builtin::BI__builtin_elementwise_floor:
return emitUnaryMaybeConstrainedFPBuiltin<cir::FloorOp>(*this, *e);
case Builtin::BI__builtin_elementwise_round:
@@ -1664,7 +1665,6 @@ RValue CIRGenFunction::emitBuiltinExpr(const GlobalDecl &gd, unsigned builtinID,
case Builtin::BI__builtin_elementwise_fmod:
return RValue::get(
emitBinaryMaybeConstrainedFPBuiltin<cir::FModOp>(*this, *e));
- case Builtin::BI__builtin_elementwise_ceil:
case Builtin::BI__builtin_elementwise_exp10:
case Builtin::BI__builtin_elementwise_ldexp:
case Builtin::BI__builtin_elementwise_pow:
diff --git a/clang/test/CIR/CodeGenBuiltins/builtins-elementwise.c b/clang/test/CIR/CodeGenBuiltins/builtins-elementwise.c
index c04739d737632..8d14a813d61f5 100644
--- a/clang/test/CIR/CodeGenBuiltins/builtins-elementwise.c
+++ b/clang/test/CIR/CodeGenBuiltins/builtins-elementwise.c
@@ -261,6 +261,28 @@ void test_builtin_elementwise_cos(float f, double d, vfloat4 vf4,
vd4 = __builtin_elementwise_cos(vd4);
}
+void test_builtin_elementwise_ceil(float f, double d, vfloat4 vf4,
+ vdouble4 vd4) {
+ // CIR-LABEL: test_builtin_elementwise_ceil
+ // LLVM-LABEL: test_builtin_elementwise_ceil
+
+ // CIR: cir.ceil %{{.*}} : !cir.float
+ // LLVM: call float @llvm.ceil.f32(float %{{.*}})
+ f = __builtin_elementwise_ceil(f);
+
+ // CIR: cir.ceil %{{.*}} : !cir.double
+ // LLVM: call double @llvm.ceil.f64(double %{{.*}})
+ d = __builtin_elementwise_ceil(d);
+
+ // CIR: cir.ceil %{{.*}} : !cir.vector<4 x !cir.float>
+ // LLVM: call <4 x float> @llvm.ceil.v4f32(<4 x float> %{{.*}})
+ vf4 = __builtin_elementwise_ceil(vf4);
+
+ // CIR: cir.ceil %{{.*}} : !cir.vector<4 x !cir.double>
+ // LLVM: call <4 x double> @llvm.ceil.v4f64(<4 x double> %{{.*}})
+ vd4 = __builtin_elementwise_ceil(vd4);
+}
+
void test_builtin_elementwise_floor(float f, double d, vfloat4 vf4,
vdouble4 vd4) {
// CIR-LABEL: test_builtin_elementwise_floor
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.