Skip to content

Commit 29175ec

Browse files
committed
Remove indirect-load for constants on Xtensa Target to improve performance
1 parent 48a87dc commit 29175ec

File tree

3 files changed

+36
-3
lines changed

3 files changed

+36
-3
lines changed

core/iwasm/compilation/aot_emit_const.c

+16-2
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ aot_compile_op_i32_const(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx,
1212
{
1313
LLVMValueRef value;
1414

15+
#if !defined(BUILD_TARGET_XTENSA)
1516
if (comp_ctx->is_indirect_mode
1617
&& aot_intrinsic_check_capability(comp_ctx, "i32.const")) {
1718
WASMValue wasm_value;
@@ -22,7 +23,9 @@ aot_compile_op_i32_const(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx,
2223
return false;
2324
}
2425
}
25-
else {
26+
else
27+
#endif
28+
{
2629
value = I32_CONST((uint32)i32_const);
2730
CHECK_LLVM_CONST(value);
2831
}
@@ -40,6 +43,7 @@ aot_compile_op_i64_const(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx,
4043
{
4144
LLVMValueRef value;
4245

46+
#if !defined(BUILD_TARGET_XTENSA)
4347
if (comp_ctx->is_indirect_mode
4448
&& aot_intrinsic_check_capability(comp_ctx, "i64.const")) {
4549
WASMValue wasm_value;
@@ -50,7 +54,9 @@ aot_compile_op_i64_const(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx,
5054
return false;
5155
}
5256
}
53-
else {
57+
else
58+
#endif
59+
{
5460
value = I64_CONST((uint64)i64_const);
5561
CHECK_LLVM_CONST(value);
5662
}
@@ -68,6 +74,7 @@ aot_compile_op_f32_const(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx,
6874
{
6975
LLVMValueRef alloca, value;
7076

77+
#if !defined(BUILD_TARGET_XTENSA)
7178
if (comp_ctx->is_indirect_mode
7279
&& aot_intrinsic_check_capability(comp_ctx, "f32.const")) {
7380
WASMValue wasm_value;
@@ -80,6 +87,9 @@ aot_compile_op_f32_const(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx,
8087
PUSH_F32(value);
8188
}
8289
else if (!isnan(f32_const)) {
90+
#else
91+
if (!isnan(f32_const)) {
92+
#endif
8393
value = F32_CONST(f32_const);
8494
CHECK_LLVM_CONST(value);
8595
PUSH_F32(value);
@@ -121,6 +131,7 @@ aot_compile_op_f64_const(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx,
121131
{
122132
LLVMValueRef alloca, value;
123133

134+
#if !defined(BUILD_TARGET_XTENSA)
124135
if (comp_ctx->is_indirect_mode
125136
&& aot_intrinsic_check_capability(comp_ctx, "f64.const")) {
126137
WASMValue wasm_value;
@@ -133,6 +144,9 @@ aot_compile_op_f64_const(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx,
133144
PUSH_F64(value);
134145
}
135146
else if (!isnan(f64_const)) {
147+
#else
148+
if (!isnan(f64_const)) {
149+
#endif
136150
value = F64_CONST(f64_const);
137151
CHECK_LLVM_CONST(value);
138152
PUSH_F64(value);

core/iwasm/compilation/aot_emit_conversion.c

+16
Original file line numberDiff line numberDiff line change
@@ -347,7 +347,9 @@ aot_compile_op_i32_trunc_f32(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx,
347347

348348
POP_F32(value);
349349

350+
#if !defined(BUILD_TARGET_XTENSA)
350351
if (!comp_ctx->is_indirect_mode) {
352+
#endif
351353
if (sign) {
352354
min_value = F32_CONST(-2147483904.0f);
353355
max_value = F32_CONST(2147483648.0f);
@@ -356,6 +358,7 @@ aot_compile_op_i32_trunc_f32(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx,
356358
min_value = F32_CONST(-1.0f);
357359
max_value = F32_CONST(4294967296.0f);
358360
}
361+
#if !defined(BUILD_TARGET_XTENSA)
359362
}
360363
else {
361364
WASMValue wasm_value;
@@ -376,6 +379,7 @@ aot_compile_op_i32_trunc_f32(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx,
376379
comp_ctx, func_ctx->native_symbol, &wasm_value, VALUE_TYPE_F32);
377380
}
378381
}
382+
#endif
379383
CHECK_LLVM_CONST(min_value);
380384
CHECK_LLVM_CONST(max_value);
381385

@@ -400,7 +404,9 @@ aot_compile_op_i32_trunc_f64(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx,
400404

401405
POP_F64(value);
402406

407+
#if !defined(BUILD_TARGET_XTENSA)
403408
if (!comp_ctx->is_indirect_mode) {
409+
#endif
404410
if (sign) {
405411
min_value = F64_CONST(-2147483649.0);
406412
max_value = F64_CONST(2147483648.0);
@@ -409,6 +415,7 @@ aot_compile_op_i32_trunc_f64(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx,
409415
min_value = F64_CONST(-1.0);
410416
max_value = F64_CONST(4294967296.0);
411417
}
418+
#if !defined(BUILD_TARGET_XTENSA)
412419
}
413420
else {
414421
WASMValue wasm_value;
@@ -429,6 +436,7 @@ aot_compile_op_i32_trunc_f64(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx,
429436
comp_ctx, func_ctx->native_symbol, &wasm_value, VALUE_TYPE_F64);
430437
}
431438
}
439+
#endif
432440
CHECK_LLVM_CONST(min_value);
433441
CHECK_LLVM_CONST(max_value);
434442

@@ -554,7 +562,9 @@ aot_compile_op_i64_trunc_f32(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx,
554562

555563
POP_F32(value);
556564

565+
#if !defined(BUILD_TARGET_XTENSA)
557566
if (!comp_ctx->is_indirect_mode) {
567+
#endif
558568
if (sign) {
559569
min_value = F32_CONST(-9223373136366403584.0f);
560570
max_value = F32_CONST(9223372036854775808.0f);
@@ -563,6 +573,7 @@ aot_compile_op_i64_trunc_f32(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx,
563573
min_value = F32_CONST(-1.0f);
564574
max_value = F32_CONST(18446744073709551616.0f);
565575
}
576+
#if !defined(BUILD_TARGET_XTENSA)
566577
}
567578
else {
568579
WASMValue wasm_value;
@@ -583,6 +594,7 @@ aot_compile_op_i64_trunc_f32(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx,
583594
comp_ctx, func_ctx->native_symbol, &wasm_value, VALUE_TYPE_F32);
584595
}
585596
}
597+
#endif
586598
CHECK_LLVM_CONST(min_value);
587599
CHECK_LLVM_CONST(max_value);
588600

@@ -607,7 +619,9 @@ aot_compile_op_i64_trunc_f64(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx,
607619

608620
POP_F64(value);
609621

622+
#if !defined(BUILD_TARGET_XTENSA)
610623
if (!comp_ctx->is_indirect_mode) {
624+
#endif
611625
if (sign) {
612626
min_value = F64_CONST(-9223372036854777856.0);
613627
max_value = F64_CONST(9223372036854775808.0);
@@ -616,6 +630,7 @@ aot_compile_op_i64_trunc_f64(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx,
616630
min_value = F64_CONST(-1.0);
617631
max_value = F64_CONST(18446744073709551616.0);
618632
}
633+
#if !defined(BUILD_TARGET_XTENSA)
619634
}
620635
else {
621636
WASMValue wasm_value;
@@ -636,6 +651,7 @@ aot_compile_op_i64_trunc_f64(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx,
636651
comp_ctx, func_ctx->native_symbol, &wasm_value, VALUE_TYPE_F64);
637652
}
638653
}
654+
#endif
639655
CHECK_LLVM_CONST(min_value);
640656
CHECK_LLVM_CONST(max_value);
641657

core/iwasm/compilation/aot_emit_memory.c

+4-1
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,7 @@ aot_check_memory_overflow(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx,
139139

140140
is_target_64bit = (comp_ctx->pointer_size == sizeof(uint64)) ? true : false;
141141

142+
#if !defined(BUILD_TARGET_XTENSA)
142143
if (comp_ctx->is_indirect_mode
143144
&& aot_intrinsic_check_capability(
144145
comp_ctx, MEMORY64_COND_VALUE("i64.const", "i32.const"))) {
@@ -159,7 +160,9 @@ aot_check_memory_overflow(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx,
159160
return NULL;
160161
}
161162
}
162-
else {
163+
else
164+
#endif
165+
{
163166
CHECK_LLVM_CONST(offset_const);
164167
}
165168

0 commit comments

Comments
 (0)