Fix XIP issues of fp to int cast and int rem/div (#1654)

This commit is contained in:
Huang Qi
2022-11-01 20:29:07 +08:00
committed by GitHub
parent a1f7832625
commit 94cecbe4cb
4 changed files with 54 additions and 18 deletions

View File

@ -261,10 +261,30 @@ trunc_sat_float_to_int(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx,
param_types, 1, operand);
}
else {
if (sign)
res = LLVMBuildFPToSI(comp_ctx->builder, operand, dest_type, name);
else
res = LLVMBuildFPToUI(comp_ctx->builder, operand, dest_type, name);
char intrinsic[128];
/* Integer width is always 32 or 64 here. */
snprintf(intrinsic, sizeof(intrinsic), "i%d_trunc_f%d_%c",
LLVMGetIntTypeWidth(dest_type),
LLVMGetTypeKind(src_type) == LLVMFloatTypeKind ? 32 : 64,
sign ? 's' : 'u');
if (comp_ctx->disable_llvm_intrinsics
&& aot_intrinsic_check_capability(comp_ctx, intrinsic)) {
res = aot_call_llvm_intrinsic(comp_ctx, func_ctx, intrinsic,
dest_type, &src_type, 1, operand);
}
else {
if (sign) {
res = LLVMBuildFPToSI(comp_ctx->builder, operand, dest_type,
name);
}
else {
res = LLVMBuildFPToUI(comp_ctx->builder, operand, dest_type,
name);
}
}
}
if (!res) {