Skip to content

Commit

Permalink
[CIR][CIRGen][Builtin][Neon] Lower neon_vaddvq_u32 and neon_vaddvq_u64 (
Browse files Browse the repository at this point in the history
  • Loading branch information
ghehg authored Dec 12, 2024
1 parent 568b515 commit 177d89b
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 5 deletions.
9 changes: 4 additions & 5 deletions clang/lib/CIR/CodeGen/CIRGenBuiltinAArch64.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2656,6 +2656,7 @@ static mlir::Value emitCommonNeonSISDBuiltinExpr(
unsigned builtinID = info.BuiltinID;
clang::CIRGen::CIRGenBuilderTy &builder = cgf.getBuilder();
mlir::Type resultTy = cgf.convertType(expr->getType());
mlir::Type argTy = cgf.convertType(expr->getArg(0)->getType());
mlir::Location loc = cgf.getLoc(expr->getExprLoc());

switch (builtinID) {
Expand All @@ -2674,11 +2675,9 @@ static mlir::Value emitCommonNeonSISDBuiltinExpr(
llvm_unreachable(" neon_vaddlv_u32 NYI ");
case NEON::BI__builtin_neon_vaddlvq_s32:
llvm_unreachable(" neon_vaddlvq_s32 NYI ");
case NEON::BI__builtin_neon_vaddlvq_u32: {
mlir::Type argTy = cgf.convertType(expr->getArg(0)->getType());
case NEON::BI__builtin_neon_vaddlvq_u32:
return emitNeonCall(builder, {argTy}, ops, "aarch64.neon.uaddlv", resultTy,
loc);
}
case NEON::BI__builtin_neon_vaddv_f32:
llvm_unreachable(" neon_vaddv_f32 NYI ");
case NEON::BI__builtin_neon_vaddv_s32:
Expand All @@ -2694,9 +2693,9 @@ static mlir::Value emitCommonNeonSISDBuiltinExpr(
case NEON::BI__builtin_neon_vaddvq_s64:
llvm_unreachable(" neon_vaddvq_s64 NYI ");
case NEON::BI__builtin_neon_vaddvq_u32:
llvm_unreachable(" neon_vaddvq_u32 NYI ");
case NEON::BI__builtin_neon_vaddvq_u64:
llvm_unreachable(" neon_vaddvq_u64 NYI ");
return emitNeonCall(builder, {argTy}, ops, "aarch64.neon.uaddv", resultTy,
loc);
case NEON::BI__builtin_neon_vcaged_f64:
llvm_unreachable(" neon_vcaged_f64 NYI ");
case NEON::BI__builtin_neon_vcages_f32:
Expand Down
22 changes: 22 additions & 0 deletions clang/test/CIR/CodeGen/AArch64/neon-arith.c
Original file line number Diff line number Diff line change
Expand Up @@ -919,3 +919,25 @@ int16_t test_vaddv_s16(int16x4_t a) {
// LLVM-NEXT: [[TMP0:%.*]] = trunc i32 [[VADDV_I]] to i16
// LLVM-NEXT: ret i16 [[TMP0]]
}

uint32_t test_vaddvq_u32(uint32x4_t a) {
return vaddvq_u32(a);

// CIR-LABEL: vaddvq_u32
// CIR: cir.llvm.intrinsic "aarch64.neon.uaddv" {{%.*}} : (!cir.vector<!u32i x 4>) -> !u32i

// LLVM-LABEL: test_vaddvq_u32
// LLVM: [[VADDVQ_U32_I:%.*]] = call i32 @llvm.aarch64.neon.uaddv.i32.v4i32(<4 x i32> {{%.*}})
// LLVM: ret i32 [[VADDVQ_U32_I]]
}

uint64_t test_vaddvq_u64(uint64x2_t a) {
return vaddvq_u64(a);

// CIR-LABEL: vaddvq_u64
// CIR: cir.llvm.intrinsic "aarch64.neon.uaddv" {{%.*}} : (!cir.vector<!u64i x 2>) -> !u64i

// LLVM-LABEL: test_vaddvq_u64
// LLVM: [[VADDVQ_U64_I:%.*]] = call i64 @llvm.aarch64.neon.uaddv.i64.v2i64(<2 x i64> {{%.*}})
// LLVM: ret i64 [[VADDVQ_U64_I]]
}

0 comments on commit 177d89b

Please sign in to comment.