diff options
| author | Damien George <damien@micropython.org> | 2024-03-18 12:30:09 +1100 |
|---|---|---|
| committer | Damien George <damien@micropython.org> | 2024-03-19 10:31:36 +1100 |
| commit | b50efbd0e319764dab3f49b64519cfea5f2c2bab (patch) | |
| tree | 38ae2eb32880c40b616628e633a879def62b65db /py | |
| parent | f52b0d0ff1788225fd61a748e0786aa90e953481 (diff) | |
py/asmxtensa: Optimise asm_xtensa_mov_reg_i32_optimised() for tiny ints.
Signed-off-by: Damien George <damien@micropython.org>
Diffstat (limited to 'py')
| -rw-r--r-- | py/asmxtensa.c | 4 | ||||
| -rw-r--r-- | py/asmxtensa.h | 5 |
2 files changed, 6 insertions, 3 deletions
diff --git a/py/asmxtensa.c b/py/asmxtensa.c index 84018402f..0fbe351dc 100644 --- a/py/asmxtensa.c +++ b/py/asmxtensa.c @@ -185,7 +185,9 @@ size_t asm_xtensa_mov_reg_i32(asm_xtensa_t *as, uint reg_dest, uint32_t i32) { } void asm_xtensa_mov_reg_i32_optimised(asm_xtensa_t *as, uint reg_dest, uint32_t i32) { - if (SIGNED_FIT12(i32)) { + if (-32 <= (int)i32 && (int)i32 <= 95) { + asm_xtensa_op_movi_n(as, reg_dest, i32); + } else if (SIGNED_FIT12(i32)) { asm_xtensa_op_movi(as, reg_dest, i32); } else { asm_xtensa_mov_reg_i32(as, reg_dest, i32); diff --git a/py/asmxtensa.h b/py/asmxtensa.h index aef9e7462..f226624a8 100644 --- a/py/asmxtensa.h +++ b/py/asmxtensa.h @@ -203,8 +203,9 @@ static inline void asm_xtensa_op_movi(asm_xtensa_t *as, uint reg_dest, int32_t i asm_xtensa_op24(as, ASM_XTENSA_ENCODE_RRI8(2, 10, (imm12 >> 8) & 0xf, reg_dest, imm12 & 0xff)); } -static inline void asm_xtensa_op_movi_n(asm_xtensa_t *as, uint reg_dest, int imm4) { - asm_xtensa_op16(as, ASM_XTENSA_ENCODE_RI7(12, reg_dest, imm4)); +// Argument must be in the range (-32 .. 95) inclusive. +static inline void asm_xtensa_op_movi_n(asm_xtensa_t *as, uint reg_dest, int imm7) { + asm_xtensa_op16(as, ASM_XTENSA_ENCODE_RI7(12, reg_dest, imm7)); } static inline void asm_xtensa_op_mull(asm_xtensa_t *as, uint reg_dest, uint reg_src_a, uint reg_src_b) { |
