Skip to content

Commit b979502

Browse files
committed
Revert "Remove indirect-load for constants on Xtensa Target to improve performance (bytecodealliance#4162)"
This reverts commit 4e50d21.
1 parent 7d8fa74 commit b979502

File tree

2 files changed

+47
-48
lines changed

2 files changed

+47
-48
lines changed

core/iwasm/aot/aot_intrinsic.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -921,6 +921,9 @@ aot_intrinsic_fill_capability_flags(AOTCompContext *comp_ctx)
921921
add_i64_common_intrinsics(comp_ctx);
922922
add_common_float_integer_conversion(comp_ctx);
923923
add_intrinsic_capability(comp_ctx, AOT_INTRINSIC_FLAG_F32_CONST);
924+
add_intrinsic_capability(comp_ctx, AOT_INTRINSIC_FLAG_F64_CONST);
925+
add_intrinsic_capability(comp_ctx, AOT_INTRINSIC_FLAG_I32_CONST);
926+
add_intrinsic_capability(comp_ctx, AOT_INTRINSIC_FLAG_I64_CONST);
924927
}
925928
else {
926929
/*

core/iwasm/compilation/aot_emit_conversion.c

Lines changed: 44 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -347,8 +347,17 @@ aot_compile_op_i32_trunc_f32(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx,
347347

348348
POP_F32(value);
349349

350-
if (comp_ctx->is_indirect_mode
351-
&& aot_intrinsic_check_capability(comp_ctx, "f32.const")) {
350+
if (!comp_ctx->is_indirect_mode) {
351+
if (sign) {
352+
min_value = F32_CONST(-2147483904.0f);
353+
max_value = F32_CONST(2147483648.0f);
354+
}
355+
else {
356+
min_value = F32_CONST(-1.0f);
357+
max_value = F32_CONST(4294967296.0f);
358+
}
359+
}
360+
else {
352361
WASMValue wasm_value;
353362
if (sign) {
354363
wasm_value.f32 = -2147483904.0f;
@@ -367,16 +376,6 @@ aot_compile_op_i32_trunc_f32(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx,
367376
comp_ctx, func_ctx->native_symbol, &wasm_value, VALUE_TYPE_F32);
368377
}
369378
}
370-
else {
371-
if (sign) {
372-
min_value = F32_CONST(-2147483904.0f);
373-
max_value = F32_CONST(2147483648.0f);
374-
}
375-
else {
376-
min_value = F32_CONST(-1.0f);
377-
max_value = F32_CONST(4294967296.0f);
378-
}
379-
}
380379
CHECK_LLVM_CONST(min_value);
381380
CHECK_LLVM_CONST(max_value);
382381

@@ -401,8 +400,17 @@ aot_compile_op_i32_trunc_f64(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx,
401400

402401
POP_F64(value);
403402

404-
if (comp_ctx->is_indirect_mode
405-
&& aot_intrinsic_check_capability(comp_ctx, "f64.const")) {
403+
if (!comp_ctx->is_indirect_mode) {
404+
if (sign) {
405+
min_value = F64_CONST(-2147483649.0);
406+
max_value = F64_CONST(2147483648.0);
407+
}
408+
else {
409+
min_value = F64_CONST(-1.0);
410+
max_value = F64_CONST(4294967296.0);
411+
}
412+
}
413+
else {
406414
WASMValue wasm_value;
407415
if (sign) {
408416
wasm_value.f64 = -2147483649.0;
@@ -421,16 +429,6 @@ aot_compile_op_i32_trunc_f64(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx,
421429
comp_ctx, func_ctx->native_symbol, &wasm_value, VALUE_TYPE_F64);
422430
}
423431
}
424-
else {
425-
if (sign) {
426-
min_value = F64_CONST(-2147483649.0);
427-
max_value = F64_CONST(2147483648.0);
428-
}
429-
else {
430-
min_value = F64_CONST(-1.0);
431-
max_value = F64_CONST(4294967296.0);
432-
}
433-
}
434432
CHECK_LLVM_CONST(min_value);
435433
CHECK_LLVM_CONST(max_value);
436434

@@ -556,8 +554,17 @@ aot_compile_op_i64_trunc_f32(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx,
556554

557555
POP_F32(value);
558556

559-
if (comp_ctx->is_indirect_mode
560-
&& aot_intrinsic_check_capability(comp_ctx, "f32.const")) {
557+
if (!comp_ctx->is_indirect_mode) {
558+
if (sign) {
559+
min_value = F32_CONST(-9223373136366403584.0f);
560+
max_value = F32_CONST(9223372036854775808.0f);
561+
}
562+
else {
563+
min_value = F32_CONST(-1.0f);
564+
max_value = F32_CONST(18446744073709551616.0f);
565+
}
566+
}
567+
else {
561568
WASMValue wasm_value;
562569
if (sign) {
563570
wasm_value.f32 = -9223373136366403584.0f;
@@ -576,16 +583,6 @@ aot_compile_op_i64_trunc_f32(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx,
576583
comp_ctx, func_ctx->native_symbol, &wasm_value, VALUE_TYPE_F32);
577584
}
578585
}
579-
else {
580-
if (sign) {
581-
min_value = F32_CONST(-9223373136366403584.0f);
582-
max_value = F32_CONST(9223372036854775808.0f);
583-
}
584-
else {
585-
min_value = F32_CONST(-1.0f);
586-
max_value = F32_CONST(18446744073709551616.0f);
587-
}
588-
}
589586
CHECK_LLVM_CONST(min_value);
590587
CHECK_LLVM_CONST(max_value);
591588

@@ -610,8 +607,17 @@ aot_compile_op_i64_trunc_f64(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx,
610607

611608
POP_F64(value);
612609

613-
if (comp_ctx->is_indirect_mode
614-
&& aot_intrinsic_check_capability(comp_ctx, "f64.const")) {
610+
if (!comp_ctx->is_indirect_mode) {
611+
if (sign) {
612+
min_value = F64_CONST(-9223372036854777856.0);
613+
max_value = F64_CONST(9223372036854775808.0);
614+
}
615+
else {
616+
min_value = F64_CONST(-1.0);
617+
max_value = F64_CONST(18446744073709551616.0);
618+
}
619+
}
620+
else {
615621
WASMValue wasm_value;
616622
if (sign) {
617623
wasm_value.f64 = -9223372036854777856.0;
@@ -630,16 +636,6 @@ aot_compile_op_i64_trunc_f64(AOTCompContext *comp_ctx, AOTFuncContext *func_ctx,
630636
comp_ctx, func_ctx->native_symbol, &wasm_value, VALUE_TYPE_F64);
631637
}
632638
}
633-
else {
634-
if (sign) {
635-
min_value = F64_CONST(-9223372036854777856.0);
636-
max_value = F64_CONST(9223372036854775808.0);
637-
}
638-
else {
639-
min_value = F64_CONST(-1.0);
640-
max_value = F64_CONST(18446744073709551616.0);
641-
}
642-
}
643639
CHECK_LLVM_CONST(min_value);
644640
CHECK_LLVM_CONST(max_value);
645641

0 commit comments

Comments
 (0)