Skip to content

[CIR][CIRGen][Builtin][Neon] Lower neon_vshrd_n_u64 #1353

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 2 commits into from
Feb 19, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
10 changes: 9 additions & 1 deletion clang/lib/CIR/CodeGen/CIRGenBuiltinAArch64.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3857,7 +3857,15 @@ CIRGenFunction::emitAArch64BuiltinExpr(unsigned BuiltinID, const CallExpr *E,
return builder.createShiftRight(Ops[0], bits);
}
case NEON::BI__builtin_neon_vshrd_n_u64: {
llvm_unreachable("NEON::BI__builtin_neon_vshrd_n_u64 NYI");
std::optional<llvm::APSInt> amt =
E->getArg(1)->getIntegerConstantExpr(getContext());
assert(amt && "Expected argument to be a constant");
uint64_t shiftAmt = amt->getZExtValue();
if (shiftAmt == 64) {
return builder.getConstInt(getLoc(E->getExprLoc()), builder.getUInt64Ty(),
0);
}
return builder.createShiftRight(Ops[0], shiftAmt);
}
case NEON::BI__builtin_neon_vsrad_n_s64: {
llvm_unreachable("NEON::BI__builtin_neon_vsrad_n_s64 NYI");
Expand Down
44 changes: 33 additions & 11 deletions clang/test/CIR/CodeGen/AArch64/neon.c
Original file line number Diff line number Diff line change
Expand Up @@ -15174,18 +15174,40 @@ int64_t test_vshrd_n_s64(int64_t a) {
// LLVM: ret i64 [[SHRD_N]]
}

// NYI-LABEL: @test_vshrd_n_u64(
// NYI: ret i64 0
// uint64_t test_vshrd_n_u64(uint64_t a) {
// return (uint64_t)vshrd_n_u64(a, 64);
// }
uint64_t test_vshrd_n_u64(uint64_t a) {
return (uint64_t)vshrd_n_u64(a, 64);

// NYI-LABEL: @test_vshrd_n_u64_2(
// NYI: ret i64 0
// uint64_t test_vshrd_n_u64_2() {
// uint64_t a = UINT64_C(0xf000000000000000);
// return vshrd_n_u64(a, 64);
// }
// CIR-LABEL: vshrd_n_u64
// CIR: {{.*}} = cir.const #cir.int<0> : !u64i
// CIR: cir.return {{.*}} : !u64i

// LLVM-LABEL: @test_vshrd_n_u64(
// LLVM: ret i64 0
}

uint64_t test_vshrd_n_u64_2() {
uint64_t a = UINT64_C(0xf000000000000000);
return vshrd_n_u64(a, 64);

// CIR-LABEL: vshrd_n_u64
// CIR: {{.*}} = cir.const #cir.int<0> : !u64i
// CIR: cir.return {{.*}} : !u64i

// LLVM-LABEL: @test_vshrd_n_u64_2(
// LLVM: ret i64 0

}

uint64_t test_vshrd_n_u64_3(uint64_t a) {
return vshrd_n_u64(a, 1);

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

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

// NYI-LABEL: @test_vrshrd_n_s64(
// NYI: [[VRSHR_N:%.*]] = call i64 @llvm.aarch64.neon.srshl.i64(i64 %a, i64 -63)
Expand Down
Loading