Skip to content

[CIR][CIRGen][Builtin][Neon] Lower vrnd64z and vrnd64zq #1401

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 27, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions clang/lib/CIR/CodeGen/CIRGenBuiltinAArch64.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2582,6 +2582,14 @@ mlir::Value CIRGenFunction::emitCommonNeonBuiltinExpr(
argTypes.push_back(vTy);
break;
}
case NEON::BI__builtin_neon_vrnd64z_f32:
case NEON::BI__builtin_neon_vrnd64zq_f32:
case NEON::BI__builtin_neon_vrnd64z_f64:
case NEON::BI__builtin_neon_vrnd64zq_f64: {
intrincsName = "aarch64.neon.frint64z";
argTypes.push_back(vTy);
break;
}
case NEON::BI__builtin_neon_vshl_v:
case NEON::BI__builtin_neon_vshlq_v: {
return builder.create<cir::ShiftOp>(
Expand Down
52 changes: 40 additions & 12 deletions clang/test/CIR/CodeGen/AArch64/v8.5a-neon-frint3264-intrinsic.c
Original file line number Diff line number Diff line change
Expand Up @@ -95,16 +95,30 @@ float32x4_t test_vrnd64xq_f32(float32x4_t a) {
// CHECK-LABEL: test_vrnd64z_f32
// CHECK: [[RND:%.*]] = call <2 x float> @llvm.aarch64.neon.frint64z.v2f32(<2 x float> %a)
// CHECK: ret <2 x float> [[RND]]
// float32x2_t test_vrnd64z_f32(float32x2_t a) {
// return vrnd64z_f32(a);
// }
float32x2_t test_vrnd64z_f32(float32x2_t a) {
return vrnd64z_f32(a);

// CIR-LABEL: vrnd64z_f32
// CIR: [[TMP0:%.*]] = cir.llvm.intrinsic "aarch64.neon.frint64z" {{.*}} : (!cir.vector<!cir.float x 2>) -> !cir.vector<!cir.float x 2>

// LLVM-LABEL: @test_vrnd64z_f32
// LLVM: [[RND:%.*]] = call <2 x float> @llvm.aarch64.neon.frint64z.v2f32(<2 x float> %0)
// LLVM: ret <2 x float> [[RND]]
}

// CHECK-LABEL: test_vrnd64zq_f32
// CHECK: [[RND:%.*]] = call <4 x float> @llvm.aarch64.neon.frint64z.v4f32(<4 x float> %a)
// CHECK: ret <4 x float> [[RND]]
// float32x4_t test_vrnd64zq_f32(float32x4_t a) {
// return vrnd64zq_f32(a);
// }
float32x4_t test_vrnd64zq_f32(float32x4_t a) {
return vrnd64zq_f32(a);

// CIR-LABEL: vrnd64zq_f32
// CIR: [[TMP0:%.*]] = cir.llvm.intrinsic "aarch64.neon.frint64z" {{.*}} : (!cir.vector<!cir.float x 4>) -> !cir.vector<!cir.float x 4>

// LLVM-LABEL: @test_vrnd64zq_f32
// LLVM: [[RND:%.*]] = call <4 x float> @llvm.aarch64.neon.frint64z.v4f32(<4 x float> %0)
// LLVM: ret <4 x float> [[RND]]
}

float64x1_t test_vrnd32x_f64(float64x1_t a) {
return vrnd32x_f64(a);
Expand Down Expand Up @@ -182,13 +196,27 @@ float64x2_t test_vrnd64xq_f64(float64x2_t a) {
// CHECK-LABEL: test_vrnd64z_f64
// CHECK: [[RND:%.*]] = call <1 x double> @llvm.aarch64.neon.frint64z.v1f64(<1 x double> %a)
// CHECK: ret <1 x double> [[RND]]
// float64x1_t test_vrnd64z_f64(float64x1_t a) {
// return vrnd64z_f64(a);
// }
float64x1_t test_vrnd64z_f64(float64x1_t a) {
return vrnd64z_f64(a);

// CIR-LABEL: vrnd64z_f64
// CIR: [[TMP0:%.*]] = cir.llvm.intrinsic "aarch64.neon.frint64z" {{.*}} : (!cir.vector<!cir.double x 1>) -> !cir.vector<!cir.double x 1>

// LLVM-LABEL: @test_vrnd64z_f64
// LLVM: [[RND:%.*]] = call <1 x double> @llvm.aarch64.neon.frint64z.v1f64(<1 x double> %0)
// LLVM: ret <1 x double> [[RND]]
}

// CHECK-LABEL: test_vrnd64zq_f64
// CHECK: [[RND:%.*]] = call <2 x double> @llvm.aarch64.neon.frint64z.v2f64(<2 x double> %a)
// CHECK: ret <2 x double> [[RND]]
// float64x2_t test_vrnd64zq_f64(float64x2_t a) {
// return vrnd64zq_f64(a);
// }
float64x2_t test_vrnd64zq_f64(float64x2_t a) {
return vrnd64zq_f64(a);

// CIR-LABEL: vrnd64zq_f64
// CIR: [[TMP0:%.*]] = cir.llvm.intrinsic "aarch64.neon.frint64z" {{.*}} : (!cir.vector<!cir.double x 2>) -> !cir.vector<!cir.double x 2>

// LLVM-LABEL: @test_vrnd64zq_f64
// LLVM: [[RND:%.*]] = call <2 x double> @llvm.aarch64.neon.frint64z.v2f64(<2 x double> %0)
// LLVM: ret <2 x double> [[RND]]
}
Loading