Skip to content

Commit a40bbc5

Browse files
AmrDeveloperlanza
authored andcommitted
[CIR][CIRGen][Builtin][Neon] Lower vshld_n_s64 and vshld_n_u64 (#1259)
Lowering `vshld_n_s64` and `vshld_n_u64`
1 parent aee90fa commit a40bbc5

File tree

2 files changed

+24
-13
lines changed

2 files changed

+24
-13
lines changed

clang/lib/CIR/CodeGen/CIRGenBuiltinAArch64.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3820,7 +3820,10 @@ CIRGenFunction::emitAArch64BuiltinExpr(unsigned BuiltinID, const CallExpr *E,
38203820
}
38213821
case NEON::BI__builtin_neon_vshld_n_s64:
38223822
case NEON::BI__builtin_neon_vshld_n_u64: {
3823-
llvm_unreachable("NEON::BI__builtin_neon_vshld_n_u64 NYI");
3823+
std::optional<llvm::APSInt> amt =
3824+
E->getArg(1)->getIntegerConstantExpr(getContext());
3825+
assert(amt && "Expected argument to be a constant");
3826+
return builder.createShiftLeft(Ops[0], amt->getZExtValue());
38243827
}
38253828
case NEON::BI__builtin_neon_vshrd_n_s64: {
38263829
llvm_unreachable("NEON::BI__builtin_neon_vshrd_n_s64 NYI");

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

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -15232,12 +15232,16 @@ uint64x1_t test_vrsra_n_u64(uint64x1_t a, uint64x1_t b) {
1523215232
// LLVM: ret <1 x i64> [[TMP3]]
1523315233
}
1523415234

15235-
// NYI-LABEL: @test_vshld_n_s64(
15236-
// NYI: [[SHLD_N:%.*]] = shl i64 %a, 1
15237-
// NYI: ret i64 [[SHLD_N]]
15238-
// int64_t test_vshld_n_s64(int64_t a) {
15239-
// return (int64_t)vshld_n_s64(a, 1);
15240-
// }
15235+
int64_t test_vshld_n_s64(int64_t a) {
15236+
return (int64_t)vshld_n_s64(a, 1);
15237+
15238+
// CIR-LABEL: vshld_n_s64
15239+
// CIR: {{%.*}} = cir.shift(left, {{%.*}} : !s64i, {{%.*}} : !s64i) -> !s64i
15240+
15241+
// LLVM-LABEL: @test_vshld_n_s64(
15242+
// LLVM: [[SHLD_N:%.*]] = shl i64 %0, 1
15243+
// LLVM: ret i64 [[SHLD_N]]
15244+
}
1524115245

1524215246
// NYI-LABEL: @test_vshl_n_s64(
1524315247
// NYI: [[TMP0:%.*]] = bitcast <1 x i64> %a to <8 x i8>
@@ -15248,12 +15252,16 @@ uint64x1_t test_vrsra_n_u64(uint64x1_t a, uint64x1_t b) {
1524815252
// return vshl_n_s64(a, 1);
1524915253
// }
1525015254

15251-
// NYI-LABEL: @test_vshld_n_u64(
15252-
// NYI: [[SHLD_N:%.*]] = shl i64 %a, 63
15253-
// NYI: ret i64 [[SHLD_N]]
15254-
// uint64_t test_vshld_n_u64(uint64_t a) {
15255-
// return (uint64_t)vshld_n_u64(a, 63);
15256-
// }
15255+
uint64_t test_vshld_n_u64(uint64_t a) {
15256+
return (uint64_t)vshld_n_u64(a, 63);
15257+
15258+
// CIR-LABEL: vshld_n_u64
15259+
// CIR: {{%.*}} = cir.shift(left, {{%.*}} : !u64i, {{%.*}} : !u64i) -> !u64i
15260+
15261+
// LLVM-LABEL: @test_vshld_n_u64(
15262+
// LLVM: [[SHLD_N:%.*]] = shl i64 %0, 63
15263+
// LLVM: ret i64 [[SHLD_N]]
15264+
}
1525715265

1525815266
// NYI-LABEL: @test_vshl_n_u64(
1525915267
// NYI: [[TMP0:%.*]] = bitcast <1 x i64> %a to <8 x i8>

0 commit comments

Comments
 (0)