Skip to content

[CIR][CIRGen][Builtin][Neon] Lower vshrd_n_s64 #1260

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
Jan 6, 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
6 changes: 5 additions & 1 deletion clang/lib/CIR/CodeGen/CIRGenBuiltinAArch64.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3810,7 +3810,11 @@ CIRGenFunction::emitAArch64BuiltinExpr(unsigned BuiltinID, const CallExpr *E,
llvm_unreachable("NEON::BI__builtin_neon_vshld_n_u64 NYI");
}
case NEON::BI__builtin_neon_vshrd_n_s64: {
llvm_unreachable("NEON::BI__builtin_neon_vshrd_n_s64 NYI");
std::optional<llvm::APSInt> amt =
E->getArg(1)->getIntegerConstantExpr(getContext());
assert(amt && "Expected argument to be a constant");
uint64_t bits = std::min(static_cast<uint64_t>(63), amt->getZExtValue());
return builder.createShiftRight(Ops[0], bits);
}
case NEON::BI__builtin_neon_vshrd_n_u64: {
llvm_unreachable("NEON::BI__builtin_neon_vshrd_n_u64 NYI");
Expand Down
16 changes: 10 additions & 6 deletions clang/test/CIR/CodeGen/AArch64/neon.c
Original file line number Diff line number Diff line change
Expand Up @@ -15058,12 +15058,16 @@ int16_t test_vqmovns_s32(int32_t a) {
// return (uint64_t)vcaltd_f64(a, b);
// }

// NYI-LABEL: @test_vshrd_n_s64(
// NYI: [[SHRD_N:%.*]] = ashr i64 %a, 1
// NYI: ret i64 [[SHRD_N]]
// int64_t test_vshrd_n_s64(int64_t a) {
// return (int64_t)vshrd_n_s64(a, 1);
// }
int64_t test_vshrd_n_s64(int64_t a) {
return (int64_t)vshrd_n_s64(a, 1);

// CIR-LABEL: vshrd_n_s64
// CIR: {{%.*}} = cir.shift(right, {{%.*}} : !s64i, {{%.*}} : !s64i) -> !s64i

// LLVM-LABEL: @test_vshrd_n_s64(
// LLVM: [[SHRD_N:%.*]] = ashr i64 %0, 1
// LLVM: ret i64 [[SHRD_N]]
}

// NYI-LABEL: @test_vshrd_n_u64(
// NYI: ret i64 0
Expand Down
Loading