Remove indirect-load for constants on Xtensa Target to improve performance (#4162)

* Remove indirect-load for constants on Xtensa Target to improve performance
* Remove const intrinsics flags for xtensa instead of adding too much #ifdef
* Add AOT_INTRINSIC_FLAG_F32_CONST for xtensa frontend, because espressif xtensa llvm backend does not support float-point immediate for now

---------
Co-authored-by: zhanheng1 <Zhanheng.Qin@sony.com>
This commit is contained in:
dongsheng28849455 2025-04-02 14:39:03 +08:00 committed by GitHub
parent 6424122d6b
commit 4e50d2191c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 48 additions and 47 deletions

View File

@ -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 {
/*

View File

@ -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);