Skip to content

Commit a41dfe7

Browse files
ghehglanza
authored andcommitted
[CIR][CIRGen][Builtin][Neon] Lower SISD neon_vqrdmulhs_s32 (#1175)
[OG's implementation ](https://github.com/llvm/clangir/blob/aaf38b30d31251f3411790820c5e1bf914393ddc/clang/lib/CodeGen/CGBuiltin.cpp#L7527) provides one common code to handle all neon SISD intrinsics. But IMHO, it entangles different things together which hurts readability. Here, We start with simple easy-to-understand approach with specific case. And in the future, as we handle more intrinsics, we may come up with a few simple common patterns.
1 parent 8b6e586 commit a41dfe7

File tree

2 files changed

+17
-8
lines changed

2 files changed

+17
-8
lines changed

clang/lib/CIR/CodeGen/CIRGenBuiltinAArch64.cpp

+7-2
Original file line numberDiff line numberDiff line change
@@ -2611,8 +2611,12 @@ mlir::Value CIRGenFunction::emitCommonNeonBuiltinExpr(
26112611

26122612
static mlir::Value emitCommonNeonSISDBuiltinExpr(
26132613
CIRGenFunction &cgf, const ARMVectorIntrinsicInfo &info,
2614-
llvm::SmallVectorImpl<mlir::Value> &args, const CallExpr *expr) {
2614+
llvm::SmallVectorImpl<mlir::Value> &ops, const CallExpr *expr) {
26152615
unsigned builtinID = info.BuiltinID;
2616+
clang::CIRGen::CIRGenBuilderTy &builder = cgf.getBuilder();
2617+
mlir::Type resultTy = cgf.convertType(expr->getType());
2618+
mlir::Location loc = cgf.getLoc(expr->getExprLoc());
2619+
26162620
switch (builtinID) {
26172621
default:
26182622
llvm::errs() << getAArch64SIMDIntrinsicString(builtinID) << " ";
@@ -2860,7 +2864,8 @@ static mlir::Value emitCommonNeonSISDBuiltinExpr(
28602864
case NEON::BI__builtin_neon_vqrdmulhh_s16:
28612865
llvm_unreachable(" neon_vqrdmulhh_s16 NYI ");
28622866
case NEON::BI__builtin_neon_vqrdmulhs_s32:
2863-
llvm_unreachable(" neon_vqrdmulhs_s32 NYI ");
2867+
return emitNeonCall(builder, {resultTy, resultTy}, ops,
2868+
"aarch64.neon.sqrdmulh", resultTy, loc);
28642869
case NEON::BI__builtin_neon_vqrshlb_s8:
28652870
llvm_unreachable(" neon_vqrshlb_s8 NYI ");
28662871
case NEON::BI__builtin_neon_vqrshlb_u8:

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

+10-6
Original file line numberDiff line numberDiff line change
@@ -10005,12 +10005,16 @@ poly16x8_t test_vmull_p8(poly8x8_t a, poly8x8_t b) {
1000510005
// return vqrdmulhh_s16(a, b);
1000610006
// }
1000710007

10008-
// NYI-LABEL: @test_vqrdmulhs_s32(
10009-
// NYI: [[VQRDMULHS_S32_I:%.*]] = call i32 @llvm.aarch64.neon.sqrdmulh.i32(i32 %a, i32 %b)
10010-
// NYI: ret i32 [[VQRDMULHS_S32_I]]
10011-
// int32_t test_vqrdmulhs_s32(int32_t a, int32_t b) {
10012-
// return vqrdmulhs_s32(a, b);
10013-
// }
10008+
int32_t test_vqrdmulhs_s32(int32_t a, int32_t b) {
10009+
return vqrdmulhs_s32(a, b);
10010+
10011+
// CIR-LABEL: vqrdmulhs_s32
10012+
// CIR: cir.llvm.intrinsic "aarch64.neon.sqrdmulh" {{%.*}}, {{%.*}} : (!s32i, !s32i) -> !s32i
10013+
10014+
// LLVM: {{.*}}test_vqrdmulhs_s32(i32{{.*}}[[a:%.*]], i32{{.*}}[[b:%.*]])
10015+
// LLVM: [[VQRDMULHS_S32_I:%.*]] = call i32 @llvm.aarch64.neon.sqrdmulh.i32(i32 [[a]], i32 [[b]])
10016+
// LLVM: ret i32 [[VQRDMULHS_S32_I]]
10017+
}
1001410018

1001510019
// NYI-LABEL: @test_vmulxs_f32(
1001610020
// NYI: [[VMULXS_F32_I:%.*]] = call float @llvm.aarch64.neon.fmulx.f32(float %a, float %b)

0 commit comments

Comments
 (0)