Skip to content

Commit e8f6d60

Browse files
committed
[CIR][AArch64] Implement NEON builtin vaddvq_s16
Implement vaddvq_s16 (add across vector, signed 16-bit quadword) using the generic vector.reduce.add intrinsic to match OG codegen. Test includes CIR, LLVM, and OGCG check patterns.
1 parent 93b466e commit e8f6d60

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

clang/lib/CIR/CodeGen/CIRGenBuiltinAArch64.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4318,7 +4318,8 @@ CIRGenFunction::emitAArch64BuiltinExpr(unsigned BuiltinID, const CallExpr *E,
43184318
llvm_unreachable("NEON::BI__builtin_neon_vaddvq_u16 NYI");
43194319
[[fallthrough]];
43204320
case NEON::BI__builtin_neon_vaddvq_s16: {
4321-
llvm_unreachable("NEON::BI__builtin_neon_vaddvq_s16 NYI");
4321+
return emitCommonNeonVecAcrossCall(*this, "vector.reduce.add", SInt16Ty, 8,
4322+
E);
43224323
}
43234324
case NEON::BI__builtin_neon_vmaxv_u8: {
43244325
return emitCommonNeonVecAcrossCall(*this, "aarch64.neon.umaxv", UInt8Ty, 8,

clang/test/CIR/CodeGen/AArch64/neon.c

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18803,6 +18803,22 @@ int8_t test_vminvq_s8(int8x16_t a) {
1880318803
// OGCG: ret i8
1880418804
}
1880518805

18806+
int16_t test_vaddvq_s16(int16x8_t a) {
18807+
return vaddvq_s16(a);
18808+
18809+
// CIR-LABEL: vaddvq_s16
18810+
// CIR: cir.llvm.intrinsic "vector.reduce.add" {{%.*}} : (!cir.vector<!s16i x 8>) -> !s16i
18811+
18812+
// LLVM-LABEL: @test_vaddvq_s16
18813+
// LLVM-SAME: (<8 x i16> [[a:%.*]])
18814+
// LLVM: [[VADDVQ_S16_I:%.*]] = call i16 @llvm.vector.reduce.add.v8i16(<8 x i16> {{.*}})
18815+
// LLVM: ret i16 [[VADDVQ_S16_I]]
18816+
18817+
// OGCG-LABEL: @test_vaddvq_s16
18818+
// OGCG: {{%.*}} = call i16 @llvm.vector.reduce.add.v8i16(<8 x i16> {{%.*}})
18819+
// OGCG: ret i16
18820+
}
18821+
1880618822

1880718823
int32_t test_vaddv_s32(int32x2_t a) {
1880818824
return vaddv_s32(a);

0 commit comments

Comments
 (0)