-
Notifications
You must be signed in to change notification settings - Fork 670
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Remove indirect-load for constants on Xtensa Target to improve performance #4162
base: main
Are you sure you want to change the base?
Remove indirect-load for constants on Xtensa Target to improve performance #4162
Conversation
@@ -12,6 +12,7 @@ aot_compile_op_i32_const(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx, | |||
{ | |||
LLVMValueRef value; | |||
|
|||
#if !defined(BUILD_TARGET_XTENSA) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about implement this by modify the intrinsic flags instead?
wasm-micro-runtime/core/iwasm/aot/aot_intrinsic.c
Lines 870 to 884 in 8acaaa2
else if (!strncmp(comp_ctx->target_arch, "xtensa", 6)) { | |
/* | |
* Note: Use builtin intrinsics since hardware float operation | |
* will cause rodata relocation | |
*/ | |
add_f32_common_intrinsics(comp_ctx); | |
add_i32_common_intrinsics(comp_ctx); | |
add_f64_common_intrinsics(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); | |
} |
@@ -347,7 +347,9 @@ aot_compile_op_i32_trunc_f32(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx, | |||
|
|||
POP_F32(value); | |||
|
|||
#if !defined(BUILD_TARGET_XTENSA) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about add more intrinsic flags for conversions?
} | ||
else { | ||
if (comp_ctx->is_indirect_mode | ||
&& aot_intrinsic_check_capability(comp_ctx, "f32.const")) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perhaps there ought to be a function to eliminate a particular intrinsic capability, such as remove_intrinsic_capability(comp_ctx, AOT_INTRINSIC_FLAG_F32_CMP)
?
In XIP mode on Xtensa platform, compared with non XIP, there may be some performance degradation. The Coremark test results on the ESP32/Nuttx platform are:
According to the handling of constants by the Xtensa backend, even without indrect load, there will be no relocation. Because the backend does not perform fixup processing on immediate numbers when processing jump/branch instructions, Refer to getL32RTargetEncoding
So for the Xtensa platform, the indirct loading is not so necessary, after removing it, the performance is improve as below(Coremark):