diff --git a/core/iwasm/aot/aot_intrinsic.c b/core/iwasm/aot/aot_intrinsic.c index 245c7a651..5f62abf24 100644 --- a/core/iwasm/aot/aot_intrinsic.c +++ b/core/iwasm/aot/aot_intrinsic.c @@ -878,9 +878,6 @@ aot_intrinsic_fill_capability_flags(AOTCompContext *comp_ctx) add_i64_common_intrinsics(comp_ctx); add_common_float_integer_conversion(comp_ctx); add_intrinsic_capability(comp_ctx, AOT_INTRINSIC_FLAG_F32_CONST); - add_intrinsic_capability(comp_ctx, AOT_INTRINSIC_FLAG_F64_CONST); - add_intrinsic_capability(comp_ctx, AOT_INTRINSIC_FLAG_I32_CONST); - add_intrinsic_capability(comp_ctx, AOT_INTRINSIC_FLAG_I64_CONST); } else { /* diff --git a/core/iwasm/compilation/aot_emit_conversion.c b/core/iwasm/compilation/aot_emit_conversion.c index c3dfa6bf1..fa5c2ab95 100644 --- a/core/iwasm/compilation/aot_emit_conversion.c +++ b/core/iwasm/compilation/aot_emit_conversion.c @@ -347,17 +347,8 @@ aot_compile_op_i32_trunc_f32(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx, POP_F32(value); - if (!comp_ctx->is_indirect_mode) { - if (sign) { - min_value = F32_CONST(-2147483904.0f); - max_value = F32_CONST(2147483648.0f); - } - else { - min_value = F32_CONST(-1.0f); - max_value = F32_CONST(4294967296.0f); - } - } - else { + if (comp_ctx->is_indirect_mode + && aot_intrinsic_check_capability(comp_ctx, "f32.const")) { WASMValue wasm_value; if (sign) { wasm_value.f32 = -2147483904.0f; @@ -376,6 +367,16 @@ aot_compile_op_i32_trunc_f32(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx, comp_ctx, func_ctx->native_symbol, &wasm_value, VALUE_TYPE_F32); } } + else { + if (sign) { + min_value = F32_CONST(-2147483904.0f); + max_value = F32_CONST(2147483648.0f); + } + else { + min_value = F32_CONST(-1.0f); + max_value = F32_CONST(4294967296.0f); + } + } CHECK_LLVM_CONST(min_value); CHECK_LLVM_CONST(max_value); @@ -400,17 +401,8 @@ aot_compile_op_i32_trunc_f64(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx, POP_F64(value); - if (!comp_ctx->is_indirect_mode) { - if (sign) { - min_value = F64_CONST(-2147483649.0); - max_value = F64_CONST(2147483648.0); - } - else { - min_value = F64_CONST(-1.0); - max_value = F64_CONST(4294967296.0); - } - } - else { + if (comp_ctx->is_indirect_mode + && aot_intrinsic_check_capability(comp_ctx, "f64.const")) { WASMValue wasm_value; if (sign) { wasm_value.f64 = -2147483649.0; @@ -429,6 +421,16 @@ aot_compile_op_i32_trunc_f64(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx, comp_ctx, func_ctx->native_symbol, &wasm_value, VALUE_TYPE_F64); } } + else { + if (sign) { + min_value = F64_CONST(-2147483649.0); + max_value = F64_CONST(2147483648.0); + } + else { + min_value = F64_CONST(-1.0); + max_value = F64_CONST(4294967296.0); + } + } CHECK_LLVM_CONST(min_value); CHECK_LLVM_CONST(max_value); @@ -554,17 +556,8 @@ aot_compile_op_i64_trunc_f32(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx, POP_F32(value); - if (!comp_ctx->is_indirect_mode) { - if (sign) { - min_value = F32_CONST(-9223373136366403584.0f); - max_value = F32_CONST(9223372036854775808.0f); - } - else { - min_value = F32_CONST(-1.0f); - max_value = F32_CONST(18446744073709551616.0f); - } - } - else { + if (comp_ctx->is_indirect_mode + && aot_intrinsic_check_capability(comp_ctx, "f32.const")) { WASMValue wasm_value; if (sign) { wasm_value.f32 = -9223373136366403584.0f; @@ -583,6 +576,16 @@ aot_compile_op_i64_trunc_f32(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx, comp_ctx, func_ctx->native_symbol, &wasm_value, VALUE_TYPE_F32); } } + else { + if (sign) { + min_value = F32_CONST(-9223373136366403584.0f); + max_value = F32_CONST(9223372036854775808.0f); + } + else { + min_value = F32_CONST(-1.0f); + max_value = F32_CONST(18446744073709551616.0f); + } + } CHECK_LLVM_CONST(min_value); CHECK_LLVM_CONST(max_value); @@ -607,17 +610,8 @@ aot_compile_op_i64_trunc_f64(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx, POP_F64(value); - if (!comp_ctx->is_indirect_mode) { - if (sign) { - min_value = F64_CONST(-9223372036854777856.0); - max_value = F64_CONST(9223372036854775808.0); - } - else { - min_value = F64_CONST(-1.0); - max_value = F64_CONST(18446744073709551616.0); - } - } - else { + if (comp_ctx->is_indirect_mode + && aot_intrinsic_check_capability(comp_ctx, "f64.const")) { WASMValue wasm_value; if (sign) { wasm_value.f64 = -9223372036854777856.0; @@ -636,6 +630,16 @@ aot_compile_op_i64_trunc_f64(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx, comp_ctx, func_ctx->native_symbol, &wasm_value, VALUE_TYPE_F64); } } + else { + if (sign) { + min_value = F64_CONST(-9223372036854777856.0); + max_value = F64_CONST(9223372036854775808.0); + } + else { + min_value = F64_CONST(-1.0); + max_value = F64_CONST(18446744073709551616.0); + } + } CHECK_LLVM_CONST(min_value); CHECK_LLVM_CONST(max_value);