From d2686049b4228b6037a442f1b1eb8d13a0c2bbf4 Mon Sep 17 00:00:00 2001 From: AmrDeveloper Date: Tue, 24 Dec 2024 15:23:38 +0100 Subject: [PATCH 1/2] [CIR][CIRGen][Builtin][Neon] Lower `neon_vaddd_s64` and `neon_vaddd_u64` --- .../lib/CIR/CodeGen/CIRGenBuiltinAArch64.cpp | 2 +- clang/test/CIR/CodeGen/AArch64/neon.c | 32 ++++++++++++------- 2 files changed, 21 insertions(+), 13 deletions(-) diff --git a/clang/lib/CIR/CodeGen/CIRGenBuiltinAArch64.cpp b/clang/lib/CIR/CodeGen/CIRGenBuiltinAArch64.cpp index 83952d1dfae2..8757243f4391 100644 --- a/clang/lib/CIR/CodeGen/CIRGenBuiltinAArch64.cpp +++ b/clang/lib/CIR/CodeGen/CIRGenBuiltinAArch64.cpp @@ -3782,7 +3782,7 @@ CIRGenFunction::emitAArch64BuiltinExpr(unsigned BuiltinID, const CallExpr *E, } case NEON::BI__builtin_neon_vaddd_s64: case NEON::BI__builtin_neon_vaddd_u64: - llvm_unreachable("NEON::BI__builtin_neon_vaddd_u64 NYI"); + return builder.createAdd(Ops[0], emitScalarExpr(E->getArg(1))); case NEON::BI__builtin_neon_vsubd_s64: case NEON::BI__builtin_neon_vsubd_u64: llvm_unreachable("NEON::BI__builtin_neon_vsubd_u64 NYI"); diff --git a/clang/test/CIR/CodeGen/AArch64/neon.c b/clang/test/CIR/CodeGen/AArch64/neon.c index 1abc935f95b0..1b98fb206b59 100644 --- a/clang/test/CIR/CodeGen/AArch64/neon.c +++ b/clang/test/CIR/CodeGen/AArch64/neon.c @@ -9881,19 +9881,27 @@ poly16x8_t test_vmull_p8(poly8x8_t a, poly8x8_t b) { // return vmull_high_p8(a, b); // } -// NYI-LABEL: @test_vaddd_s64( -// NYI: [[VADDD_I:%.*]] = add i64 %a, %b -// NYI: ret i64 [[VADDD_I]] -// int64_t test_vaddd_s64(int64_t a, int64_t b) { -// return vaddd_s64(a, b); -// } +int64_t test_vaddd_s64(int64_t a, int64_t b) { + return vaddd_s64(a, b); -// NYI-LABEL: @test_vaddd_u64( -// NYI: [[VADDD_I:%.*]] = add i64 %a, %b -// NYI: ret i64 [[VADDD_I]] -// uint64_t test_vaddd_u64(uint64_t a, uint64_t b) { -// return vaddd_u64(a, b); -// } + // CIR-LABEL: vaddd_s64 + // CIR: [[v3:%.*]] = cir.binop(add, [[v1:%.*]], [[v2:%.*]]) : !s64i + + // LLVM-LABEL: @test_vaddd_s64( + // LLVM: [[VADDD_I:%.*]] = add i64 [[a:%.*]], [[b:%.*]] + // LLVM: ret i64 [[VADDD_I]] +} + +uint64_t test_vaddd_u64(uint64_t a, uint64_t b) { + return vaddd_u64(a, b); + + // CIR-LABEL: vaddd_u64 + // CIR: [[v3:%.*]] = cir.binop(add, [[v1:%.*]], [[v2:%.*]]) : !u64i + + // LLVM-LABEL: @test_vaddd_u64( + // LLVM: [[VADDD_I:%.*]] = add i64 [[a:%.*]], [[b:%.*]] + // LLVM: ret i64 [[VADDD_I]] +} // NYI-LABEL: @test_vsubd_s64( // NYI: [[VSUBD_I:%.*]] = sub i64 %a, %b From 1b51dc1a6e9afe61780efd1622a5b4ef70b34f33 Mon Sep 17 00:00:00 2001 From: AmrDeveloper Date: Thu, 2 Jan 2025 17:57:17 +0100 Subject: [PATCH 2/2] Improve testing --- clang/test/CIR/CodeGen/AArch64/neon.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/clang/test/CIR/CodeGen/AArch64/neon.c b/clang/test/CIR/CodeGen/AArch64/neon.c index 1b98fb206b59..f71a44400179 100644 --- a/clang/test/CIR/CodeGen/AArch64/neon.c +++ b/clang/test/CIR/CodeGen/AArch64/neon.c @@ -9885,10 +9885,11 @@ int64_t test_vaddd_s64(int64_t a, int64_t b) { return vaddd_s64(a, b); // CIR-LABEL: vaddd_s64 - // CIR: [[v3:%.*]] = cir.binop(add, [[v1:%.*]], [[v2:%.*]]) : !s64i + // CIR: {{%.*}} = cir.binop(add, {{%.*}}, {{%.*}}) : !s64i - // LLVM-LABEL: @test_vaddd_s64( - // LLVM: [[VADDD_I:%.*]] = add i64 [[a:%.*]], [[b:%.*]] + // LLVM-LABEL: @test_vaddd_s64 + // LLVM-SAME: (i64 [[a:%.]], i64 [[b:%.]]) + // LLVM: [[VADDD_I:%.*]] = add i64 [[a]], [[b]] // LLVM: ret i64 [[VADDD_I]] } @@ -9896,10 +9897,11 @@ uint64_t test_vaddd_u64(uint64_t a, uint64_t b) { return vaddd_u64(a, b); // CIR-LABEL: vaddd_u64 - // CIR: [[v3:%.*]] = cir.binop(add, [[v1:%.*]], [[v2:%.*]]) : !u64i + // CIR: {{%.*}} = cir.binop(add, {{%.*}}, {{%.*}}) : !u64i - // LLVM-LABEL: @test_vaddd_u64( - // LLVM: [[VADDD_I:%.*]] = add i64 [[a:%.*]], [[b:%.*]] + // LLVM-LABEL: @test_vaddd_u64 + // LLVM-SAME: (i64 [[a:%.]], i64 [[b:%.]]) + // LLVM: [[VADDD_I:%.*]] = add i64 [[a]], [[b]] // LLVM: ret i64 [[VADDD_I]] }