firmware: Minor optimization for relocate
authorDongdong Zhang <zhangdongdong@eswincomputing.com>
Tue, 29 Nov 2022 03:54:07 +0000 (11:54 +0800)
committerAnup Patel <anup@brainfault.org>
Mon, 5 Dec 2022 05:17:38 +0000 (10:47 +0530)
The t3 register stores the address of _load_end. If relocation is not
required, it is unnecessary to calculate the address of _load_end.

This can reduce the operation time of two instructions.

Signed-off-by: Dongdong Zhang <zhangdongdong@eswincomputing.com>
Reviewed-by: Bin Meng <bmeng@tinylab.org>
Reviewed-by: Anup Patel <anup@brainfault.org>
firmware/fw_base.S

index 07be4c4b930bba5928a97915422b823e8e487c06..3f622b3b39a6a0d2f835712deb67c26395de680e 100644 (file)
@@ -128,9 +128,9 @@ _relocate:
        REG_L   t1, 0(t1)
        lla     t2, _load_start
        REG_L   t2, 0(t2)
+       beq     t0, t2, _relocate_done
        sub     t3, t1, t0
        add     t3, t3, t2
-       beq     t0, t2, _relocate_done
        lla     t4, _relocate_done
        sub     t4, t4, t2
        add     t4, t4, t0