Skip to content

Commit

Permalink
[CIR][CIRGen][Builtin][Neon] Lower vshrd_n_s64 (#1260)
Browse files Browse the repository at this point in the history
Lowering `vshrd_n_s64`
  • Loading branch information
AmrDeveloper authored Jan 6, 2025
1 parent a03b999 commit 3eeb6b4
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 7 deletions.
6 changes: 5 additions & 1 deletion clang/lib/CIR/CodeGen/CIRGenBuiltinAArch64.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3825,7 +3825,11 @@ CIRGenFunction::emitAArch64BuiltinExpr(unsigned BuiltinID, const CallExpr *E,
return builder.createShiftLeft(Ops[0], amt->getZExtValue());
}
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 @@ -15078,12 +15078,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

0 comments on commit 3eeb6b4

Please sign in to comment.