Skip to content

Commit bb36a43

Browse files
authored
riscv: avoid llvm.cttz.i32/i64 for xip (#4248)
LLVM 16 and later expands cttz intrinsic to a table lookup, which involves some relocations. (unless ZBB is available, in which case the native instructions are preferred over the table-based lowering.) cf. https://reviews.llvm.org/D128911
1 parent 1996c18 commit bb36a43

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

core/iwasm/aot/aot_intrinsic.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -898,6 +898,17 @@ aot_intrinsic_fill_capability_flags(AOTCompContext *comp_ctx)
898898
if (!strncmp(comp_ctx->target_arch, "riscv32", 7)) {
899899
add_i64_common_intrinsics(comp_ctx);
900900
}
901+
/*
902+
* LLVM 16 and later expands cttz intrinsic to a table lookup,
903+
* which involves some relocations. (unless ZBB is available,
904+
* in which case the native instructions are preferred over
905+
* the table-based lowering.)
906+
* https://reviews.llvm.org/D128911
907+
*/
908+
#if LLVM_VERSION_MAJOR >= 16
909+
add_intrinsic_capability(comp_ctx, AOT_INTRINSIC_FLAG_I32_CTZ);
910+
add_intrinsic_capability(comp_ctx, AOT_INTRINSIC_FLAG_I64_CTZ);
911+
#endif
901912
}
902913
else if (!strncmp(comp_ctx->target_arch, "xtensa", 6)) {
903914
/*

0 commit comments

Comments
 (0)