Skip to content
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

[CIR][CIRGen][Builtin][Neon] Lower neon_vsrad_n_u64 #1356

Merged
merged 2 commits into from
Feb 19, 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: 7 additions & 1 deletion clang/lib/CIR/CodeGen/CIRGenBuiltinAArch64.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3863,7 +3863,13 @@ CIRGenFunction::emitAArch64BuiltinExpr(unsigned BuiltinID, const CallExpr *E,
llvm_unreachable("NEON::BI__builtin_neon_vsrad_n_s64 NYI");
}
case NEON::BI__builtin_neon_vsrad_n_u64: {
llvm_unreachable("NEON::BI__builtin_neon_vsrad_n_u64 NYI");
std::optional<llvm::APSInt> amt =
E->getArg(2)->getIntegerConstantExpr(getContext());
uint64_t shiftAmt = amt->getZExtValue();
if (shiftAmt == 64)
return Ops[0];

return builder.createAdd(Ops[0], builder.createShiftLeft(Ops[1], shiftAmt));
}
case NEON::BI__builtin_neon_vqdmlalh_lane_s16:
case NEON::BI__builtin_neon_vqdmlalh_laneq_s16:
Expand Down
33 changes: 21 additions & 12 deletions clang/test/CIR/CodeGen/AArch64/neon.c
Original file line number Diff line number Diff line change
Expand Up @@ -15245,19 +15245,28 @@ int64x1_t test_vsra_n_s64(int64x1_t a, int64x1_t b) {
// LLVM: ret <1 x i64> [[TMP4]]
}

// NYI-LABEL: @test_vsrad_n_u64(
// NYI: [[SHRD_N:%.*]] = lshr i64 %b, 63
// NYI: [[TMP0:%.*]] = add i64 %a, [[SHRD_N]]
// NYI: ret i64 [[TMP0]]
// uint64_t test_vsrad_n_u64(uint64_t a, uint64_t b) {
// return (uint64_t)vsrad_n_u64(a, b, 63);
// }
uint64_t test_vsrad_n_u64(uint64_t a, uint64_t b) {
return (uint64_t)vsrad_n_u64(a, b, 63);

// NYI-LABEL: @test_vsrad_n_u64_2(
// NYI: ret i64 %a
// uint64_t test_vsrad_n_u64_2(uint64_t a, uint64_t b) {
// return (uint64_t)vsrad_n_u64(a, b, 64);
// }
// CIR-LABEL:test_vsrad_n_u64
// CIR: [[SHL:%.*]] = cir.shift(left, {{%.*}} : !u64i, {{%.*}} : !u64i) -> !u64i
// CIR: {{.*}} = cir.binop(add, {{.*}}, [[SHL]]) : !u64i

// LLVM-LABEL: test_vsrad_n_u64(
// LLVM: [[SHRD_N:%.*]] = shl i64 %1, 63
// LLVM: [[TMP0:%.*]] = add i64 %0, [[SHRD_N]]
// LLVM: ret i64 [[TMP0]]
}

uint64_t test_vsrad_n_u64_2(uint64_t a, uint64_t b) {
return (uint64_t)vsrad_n_u64(a, b, 64);

// CIR-LABEL:test_vsrad_n_u64
// CIR: cir.return {{.*}} : !u64i

// LLVM-LABEL: test_vsrad_n_u64_2(
// LLVM: ret i64 %0
}

uint64x1_t test_vsra_n_u64(uint64x1_t a, uint64x1_t b) {
return vsra_n_u64(a, b, 1);
Expand Down
Loading