From 6fd5a6e86f5358f2f3d0c3f13b5754e91e8f61e9 Mon Sep 17 00:00:00 2001 From: AmrDeveloper Date: Fri, 21 Feb 2025 22:44:20 +0100 Subject: [PATCH] [CIR][CIRGen][Builtin][Neon] Lower builtin_neon_vqshlud_n_s64 --- clang/lib/CIR/CodeGen/CIRGenBuiltinAArch64.cpp | 10 +++++++++- clang/test/CIR/CodeGen/AArch64/neon.c | 16 ++++++++++------ 2 files changed, 19 insertions(+), 7 deletions(-) diff --git a/clang/lib/CIR/CodeGen/CIRGenBuiltinAArch64.cpp b/clang/lib/CIR/CodeGen/CIRGenBuiltinAArch64.cpp index 7f27edca2224..cd5196376c21 100644 --- a/clang/lib/CIR/CodeGen/CIRGenBuiltinAArch64.cpp +++ b/clang/lib/CIR/CodeGen/CIRGenBuiltinAArch64.cpp @@ -3828,7 +3828,15 @@ CIRGenFunction::emitAArch64BuiltinExpr(unsigned BuiltinID, const CallExpr *E, llvm_unreachable("NEON::BI__builtin_neon_vqdmlslh_s16 NYI"); } case NEON::BI__builtin_neon_vqshlud_n_s64: { - llvm_unreachable("NEON::BI__builtin_neon_vqshlud_n_s64 NYI"); + const cir::IntType IntType = builder.getSInt64Ty(); + Ops.push_back(emitScalarExpr(E->getArg(1))); + std::optional APSInt = + E->getArg(1)->getIntegerConstantExpr(getContext()); + assert(APSInt && "Expected argument to be a constant"); + Ops[1] = builder.getSInt64(APSInt->getZExtValue(), getLoc(E->getExprLoc())); + const StringRef Intrinsic = "aarch64.neon.sqshlu"; + return emitNeonCall(builder, {IntType, IntType}, Ops, Intrinsic, IntType, + getLoc(E->getExprLoc())); } case NEON::BI__builtin_neon_vqshld_n_u64: case NEON::BI__builtin_neon_vqshld_n_s64: { diff --git a/clang/test/CIR/CodeGen/AArch64/neon.c b/clang/test/CIR/CodeGen/AArch64/neon.c index aa6dca77e7df..d169be7712cd 100644 --- a/clang/test/CIR/CodeGen/AArch64/neon.c +++ b/clang/test/CIR/CodeGen/AArch64/neon.c @@ -15680,12 +15680,16 @@ uint64_t test_vqshld_n_u64(uint64_t a) { // return (int32_t)vqshlus_n_s32(a, 31); // } -// NYI-LABEL: @test_vqshlud_n_s64( -// NYI: [[VQSHLU_N:%.*]] = call i64 @llvm.aarch64.neon.sqshlu.i64(i64 %a, i64 63) -// NYI: ret i64 [[VQSHLU_N]] -// int64_t test_vqshlud_n_s64(int64_t a) { -// return (int64_t)vqshlud_n_s64(a, 63); -// } +int64_t test_vqshlud_n_s64(int64_t a) { + return (int64_t)vqshlud_n_s64(a, 63); + + // CIR-LABEL: vqshlud_n_s64 + // CIR: [[TMP0:%.*]] = cir.llvm.intrinsic "aarch64.neon.sqshlu" {{.*}}, {{.*}} : (!s64i, !s64i) -> !s64i + + // LLVM-LABEL: @test_vqshlud_n_s64( + // LLVM: [[VQSHLU_N:%.*]] = call i64 @llvm.aarch64.neon.sqshlu.i64(i64 %0, i64 63) + // LLVM: ret i64 [[VQSHLU_N]] +} // NYI-LABEL: @test_vqshlu_n_s64( // NYI: [[TMP0:%.*]] = bitcast <1 x i64> %a to <8 x i8>