llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT--> @llvm/pr-subscribers-clang Author: Andrzej Warzyński (banach-space) <details> <summary>Changes</summary> As with other NEON builtins, reuse the existing default-lowering tests to validate the CIR lowering path. --- Full diff: https://github.com/llvm/llvm-project/pull/181148.diff 3 Files Affected: - (modified) clang/lib/CIR/CodeGen/CIRGenBuiltinAArch64.cpp (+21) - (modified) clang/test/CodeGen/AArch64/neon/fullfp16.c (+10) - (modified) clang/test/CodeGen/AArch64/v8.2a-fp16-intrinsics.c (-7) ``````````diff diff --git a/clang/lib/CIR/CodeGen/CIRGenBuiltinAArch64.cpp b/clang/lib/CIR/CodeGen/CIRGenBuiltinAArch64.cpp index 71cf896aede10..0d4ed51920093 100644 --- a/clang/lib/CIR/CodeGen/CIRGenBuiltinAArch64.cpp +++ b/clang/lib/CIR/CodeGen/CIRGenBuiltinAArch64.cpp @@ -123,6 +123,17 @@ emitAArch64CompareBuiltinExpr(CIRGenFunction &cgf, CIRGenBuilderTy &builder, return builder.createCast(loc, cir::CastKind::integral, cmp, retTy); } +// Emit an intrinsic where all operands are of the same type as the result. +// Depending on mode, this may be a constrained floating-point intrinsic. +static mlir::Value +emitCallMaybeConstrainedBuiltin(CIRGenBuilderTy &builder, mlir::Location loc, + StringRef intrName, mlir::Type retTy, + llvm::SmallVector<mlir::Value> &ops) { + assert(!cir::MissingFeatures::emitConstrainedFPCall()); + + return builder.emitIntrinsicCallOp(loc, intrName, retTy, ops); +} + bool CIRGenFunction::getAArch64SVEProcessedOperands( unsigned builtinID, const CallExpr *expr, SmallVectorImpl<mlir::Value> &ops, SVETypeFlags typeFlags) { @@ -1508,7 +1519,17 @@ CIRGenFunction::emitAArch64BuiltinExpr(unsigned builtinID, const CallExpr *expr, case NEON::BI__builtin_neon_vsubh_f16: case NEON::BI__builtin_neon_vmulh_f16: case NEON::BI__builtin_neon_vdivh_f16: + cgm.errorNYI(expr->getSourceRange(), + std::string("unimplemented AArch64 builtin call: ") + + getContext().BuiltinInfo.getName(builtinID)); + return mlir::Value{}; case NEON::BI__builtin_neon_vfmah_f16: + ops.push_back(emitScalarExpr(expr->getArg(1))); + ops.push_back(emitScalarExpr(expr->getArg(2))); + ops.push_back(emitScalarExpr(expr->getArg(0))); + return emitCallMaybeConstrainedBuiltin(builder, loc, "fma", + convertType(expr->getType()), ops); + break; case NEON::BI__builtin_neon_vfmsh_f16: case NEON::BI__builtin_neon_vaddd_s64: case NEON::BI__builtin_neon_vaddd_u64: diff --git a/clang/test/CodeGen/AArch64/neon/fullfp16.c b/clang/test/CodeGen/AArch64/neon/fullfp16.c index f3268df2f4165..3a96107a3a0f6 100644 --- a/clang/test/CodeGen/AArch64/neon/fullfp16.c +++ b/clang/test/CodeGen/AArch64/neon/fullfp16.c @@ -50,3 +50,13 @@ float16_t test_vnegh_f16(float16_t a) { // LLVM: ret half [[NEG]] return vnegh_f16(a); } + +// ALL-LABEL: test_vfmah_f16 +float16_t test_vfmah_f16(float16_t a, float16_t b, float16_t c) { +// CIR: cir.call_llvm_intrinsic "fma" {{.*}} : (!cir.f16, !cir.f16, !cir.f16) -> !cir.f16 + +// LLVM-SAME: half{{.*}} [[A:%.*]], half{{.*}} [[B:%.*]], half{{.*}} [[C:%.*]]) +// LLVM: [[FMA:%.*]] = call half @llvm.fma.f16(half [[B]], half [[C]], half [[A]]) +// LLVM: ret half [[FMA]] + return vfmah_f16(a, b, c); +} diff --git a/clang/test/CodeGen/AArch64/v8.2a-fp16-intrinsics.c b/clang/test/CodeGen/AArch64/v8.2a-fp16-intrinsics.c index 353f02195721f..d6bfb1c607f81 100644 --- a/clang/test/CodeGen/AArch64/v8.2a-fp16-intrinsics.c +++ b/clang/test/CodeGen/AArch64/v8.2a-fp16-intrinsics.c @@ -620,13 +620,6 @@ float16_t test_vsubh_f16(float16_t a, float16_t b) { return vsubh_f16(a, b); } -// CHECK-LABEL: test_vfmah_f16 -// CHECK: [[FMA:%.*]] = call half @llvm.fma.f16(half %b, half %c, half %a) -// CHECK: ret half [[FMA]] -float16_t test_vfmah_f16(float16_t a, float16_t b, float16_t c) { - return vfmah_f16(a, b, c); -} - // CHECK-LABEL: test_vfmsh_f16 // CHECK: [[SUB:%.*]] = fneg half %b // CHECK: [[ADD:%.*]] = call half @llvm.fma.f16(half [[SUB]], half %c, half %a) `````````` </details> https://github.com/llvm/llvm-project/pull/181148 _______________________________________________ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
