Skip to content

Commit 90558ae

Browse files
committed
riscv: avoid llvm.cttz.i32/i64 for xip
1 parent 24ea16f commit 90558ae

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

core/iwasm/aot/aot_intrinsic.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -898,6 +898,15 @@ 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 relocations. (unless ZBB is available.)
904+
* https://reviews.llvm.org/D128911
905+
*/
906+
#if LLVM_VERSION_MAJOR >= 16
907+
add_intrinsic_capability(comp_ctx, AOT_INTRINSIC_FLAG_I32_CTZ);
908+
add_intrinsic_capability(comp_ctx, AOT_INTRINSIC_FLAG_I64_CTZ);
909+
#endif
901910
}
902911
else if (!strncmp(comp_ctx->target_arch, "xtensa", 6)) {
903912
/*

0 commit comments

Comments
 (0)