Skip to content

Commit 59493c0

Browse files
AmrDeveloperlanza
authored andcommitted
[CIR][CIRGen][Builtin][Neon] Lower neon_vsrad_n_u64 (#1356)
Lower `neon_vsrad_n_u64`
1 parent 0943911 commit 59493c0

File tree

2 files changed

+28
-13
lines changed

2 files changed

+28
-13
lines changed

clang/lib/CIR/CodeGen/CIRGenBuiltinAArch64.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3876,7 +3876,13 @@ CIRGenFunction::emitAArch64BuiltinExpr(unsigned BuiltinID, const CallExpr *E,
38763876
builder.createShift(Ops[1], shiftAmt, false));
38773877
}
38783878
case NEON::BI__builtin_neon_vsrad_n_u64: {
3879-
llvm_unreachable("NEON::BI__builtin_neon_vsrad_n_u64 NYI");
3879+
std::optional<llvm::APSInt> amt =
3880+
E->getArg(2)->getIntegerConstantExpr(getContext());
3881+
uint64_t shiftAmt = amt->getZExtValue();
3882+
if (shiftAmt == 64)
3883+
return Ops[0];
3884+
3885+
return builder.createAdd(Ops[0], builder.createShiftLeft(Ops[1], shiftAmt));
38803886
}
38813887
case NEON::BI__builtin_neon_vqdmlalh_lane_s16:
38823888
case NEON::BI__builtin_neon_vqdmlalh_laneq_s16:

clang/test/CIR/CodeGen/AArch64/neon.c

Lines changed: 21 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -15286,19 +15286,28 @@ int64x1_t test_vsra_n_s64(int64x1_t a, int64x1_t b) {
1528615286
// LLVM: ret <1 x i64> [[TMP4]]
1528715287
}
1528815288

15289-
// NYI-LABEL: @test_vsrad_n_u64(
15290-
// NYI: [[SHRD_N:%.*]] = lshr i64 %b, 63
15291-
// NYI: [[TMP0:%.*]] = add i64 %a, [[SHRD_N]]
15292-
// NYI: ret i64 [[TMP0]]
15293-
// uint64_t test_vsrad_n_u64(uint64_t a, uint64_t b) {
15294-
// return (uint64_t)vsrad_n_u64(a, b, 63);
15295-
// }
15289+
uint64_t test_vsrad_n_u64(uint64_t a, uint64_t b) {
15290+
return (uint64_t)vsrad_n_u64(a, b, 63);
1529615291

15297-
// NYI-LABEL: @test_vsrad_n_u64_2(
15298-
// NYI: ret i64 %a
15299-
// uint64_t test_vsrad_n_u64_2(uint64_t a, uint64_t b) {
15300-
// return (uint64_t)vsrad_n_u64(a, b, 64);
15301-
// }
15292+
// CIR-LABEL:test_vsrad_n_u64
15293+
// CIR: [[SHL:%.*]] = cir.shift(left, {{%.*}} : !u64i, {{%.*}} : !u64i) -> !u64i
15294+
// CIR: {{.*}} = cir.binop(add, {{.*}}, [[SHL]]) : !u64i
15295+
15296+
// LLVM-LABEL: test_vsrad_n_u64(
15297+
// LLVM: [[SHRD_N:%.*]] = shl i64 %1, 63
15298+
// LLVM: [[TMP0:%.*]] = add i64 %0, [[SHRD_N]]
15299+
// LLVM: ret i64 [[TMP0]]
15300+
}
15301+
15302+
uint64_t test_vsrad_n_u64_2(uint64_t a, uint64_t b) {
15303+
return (uint64_t)vsrad_n_u64(a, b, 64);
15304+
15305+
// CIR-LABEL:test_vsrad_n_u64
15306+
// CIR: cir.return {{.*}} : !u64i
15307+
15308+
// LLVM-LABEL: test_vsrad_n_u64_2(
15309+
// LLVM: ret i64 %0
15310+
}
1530215311

1530315312
uint64x1_t test_vsra_n_u64(uint64x1_t a, uint64x1_t b) {
1530415313
return vsra_n_u64(a, b, 1);

0 commit comments

Comments
 (0)